discuss: Docbook XML and ENTITIES


Previous by date: 9 Jun 2003 22:14:33 -0000 Re: Docbook XML and ENTITIES, David Horton
Next by date: 9 Jun 2003 22:14:33 -0000 Re: Docbook XML and ENTITIES, Tabatha Marshall
Previous in thread: 9 Jun 2003 22:14:33 -0000 Re: Docbook XML and ENTITIES, David Horton
Next in thread: 9 Jun 2003 22:14:33 -0000 Re: Docbook XML and ENTITIES, Tabatha Marshall

Subject: Re: Docbook XML and ENTITIES
From: "Martin A. Brown" ####@####.####
Date: 9 Jun 2003 22:14:33 -0000
Message-Id: <Pine.LNX.4.55.0306091646340.12177@enclitic.wonderfrog.net>

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.

That's all I have for now; good luck,

-Martin

Previous by date: 9 Jun 2003 22:14:33 -0000 Re: Docbook XML and ENTITIES, David Horton
Next by date: 9 Jun 2003 22:14:33 -0000 Re: Docbook XML and ENTITIES, Tabatha Marshall
Previous in thread: 9 Jun 2003 22:14:33 -0000 Re: Docbook XML and ENTITIES, David Horton
Next in thread: 9 Jun 2003 22:14:33 -0000 Re: Docbook XML and ENTITIES, Tabatha Marshall


  ©The Linux Documentation Project, 2014. Listserver maintained by dr Serge Victor on ibiblio.org servers. See current spam statz.