Re: [xml] Parameter entities ?



Raphael Hertzog wrote:

Hello,

does libxml fully support parameter entities ? It doesn't looks like so ...
is there any explanation ?

By parameter entity I mean things like that :

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE vide SYSTEM "test.dtd" [
<!ENTITY % debian "INCLUDE">
<!ENTITY % caldera "IGNORE">
<!ENTITY % redhat "IGNORE">
]>
<vide>
<![%debian[ Debian blabla ]]>
<![%caldera[ Caldera blabla ]]>
<![%redhat[ Redhat blabla ]]>
</vide>

This file when run through xmllint complains about the <![...]]> because
it's not a valid element. :)

Parameter entities are fully supported, as far as I can tell.

But conditional section can only appear in a dtd.  They need to be
in the internal subset up before the ]>
OTOH, since you're wanting it to expand into text, not a declaration,
you'll probably need the intermediate step of defining a general
entity in one of 3 ways according to which of the 3 systems 
you're discussing.  Ie.
<![%debian[ <!ENTITY blablah "Debian blabla">]]>
etc.

Whoa, I was just rechecking the spec, and xml 1.0, at least, seems
to say that conditional sections can only appear in the external
subset, not in the internal set.  

Ultimately I'd even need to be able to force by command line (to xsltproc
or xmllint) one of those entities to INCLUDE in order to do a kind of
conditionnal processing... (and by default all those entities would be
set to IGNORE).

Hmm, not so sure you can do that with straight xml (& xmllint), but you
can pass parameters to xsltproc.  Probably a better approach would be to
put all three chunks of stuff in your doc 
<stuff>
  <debian-stuff>Debian blahblah</debian-stuff>
  <caldera-stuff>  ...
</stuff>
and use xslt to extract the right subset according to an xsl parameter?

----------------
Bruce Miller
<bruce miller nist gov>  http://math.nist.gov/~BMiller/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]