discuss: Docbook XML and ENTITIES
Subject:
Re: Docbook XML and ENTITIES
From:
Hal Burgiss ####@####.####
Date:
10 Jun 2003 00:04:59 -0000
Message-Id: <20030610000453.GZ1995@feenix.burgiss.net>
On Mon, Jun 09, 2003 at 05:14:53PM -0500, Martin A. Brown wrote:
> Hal,
>
> : Example:
> :
> : <!ENTITY % draft "INCLUDE">
> :
> : Does Docbook XML support this, and if so what is the correct syntax?
> :
> : This works with SGML but not XML:
> :
> : <![%draft;[ testing this stuff ]]>
>
> If this is in the external subset of your document, this should
> work. For an example, consult line 62 of
> $DOCBOOK_ROOT/xml-dtd-4.2/docbookx.dtd.
>
> In particular, parameter entities (e.g., %draft;) have meaning only
> in the DTD, not in the document itself. Notably, the '%' symbol has
> no special meaning outside of the DTD (internal or external subset).
>
> Here's a trick I have used to conditionally include text....I tested
> it out with the parameter entities "draft" and "release" with your
> problem in mind, and came up with the following:
>
> <!ENTITY % draft "IGNORE" >
> <!ENTITY % release "INCLUDE" >
>
> <![%draft;[
> <!ENTITY thingy "this is a draft thingy" >
> ]]>
> <![%release;[
> <!ENTITY thingy "this is a release thingy" >
> ]]>
>
> Now, anywhere in your text that you use the general entity &thingy;
> you'll get the text "this is a release thingy".
>
> If you wish to make it a draft instead of a release, you can simply
> switch the definitions of draft and release. I'm sure some of the
> DocBook XML gurus around here have more elegant solutions, but this
> is the sort of use of parameter entities I have made in my exposure
> to DocBook.
Thanks, everybody.
First I have no problems doing what I want here with Docbook SGML.
That identical syntax does not work with XML. Martin using, your
example (pasted, literally):
Anti-Spam-HOWTO.xml:75: error: xmlParseStartTag: invalid element name
<![%draft;[
^
And then a slew of similar errors.
What I really want to do is have content conditionally included based
on build parameters, eg:
<![%draft;[
<para>
Since this document is not even started yet, you should not even be
able to read this. At least, in theory.
</para>
]]>
I am using xsltproc, per LAG, if that makes a difference. I cruised
through Docbook, the Definitive Guide (or whatever it is), and I get
the feeling XML doesn't do this. But if so, why is XML so hot?
--
Hal Burgiss