discuss: Docbook XML and ENTITIES


Previous by date: 10 Jun 2003 01:45:07 -0000 Re: Docbook XML and ENTITIES, Greg Ferguson
Next by date: 10 Jun 2003 01:45:07 -0000 Re: Docbook XML and ENTITIES, Hal Burgiss
Previous in thread: 10 Jun 2003 01:45:07 -0000 Re: Docbook XML and ENTITIES, Greg Ferguson
Next in thread: 10 Jun 2003 01:45:07 -0000 Re: Docbook XML and ENTITIES, Hal Burgiss

Subject: Re: Docbook XML and ENTITIES
From: "Martin A. Brown" ####@####.####
Date: 10 Jun 2003 01:45:07 -0000
Message-Id: <Pine.LNX.4.55.0306091914400.9585@enclitic.wonderfrog.net>

Hello again, Hal,

Yes, you have a need for a different type of solution.  You do not
need or want parameter entities and the INCLUDE/IGNORE DTD
directives.  Rather, you could consider using profiling [1].

I have seen profiling used (see netWindows documentation, the
chapter on signals and slots) to select an output language, Spanish
or English [2] based on command line parameters to the XSLT
processor.

 : 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;[
 :     ^

Yes, indeed!  Because you put this text in the XML content, not in
the DTD, xsltproc gave up.

 : What I really want to do is have content conditionally included based
 : on build parameters, eg:

And that's what I didn't quite get from your previous post, hence my
suggestion about using parameter entities to solve your problem, but
parameter entities in XML are better for handling DTD magic.  This
was not the solution for you!

 :  <![%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?

Here's an alternative, using profiling.

Use the following markup inline in your text.

  <para condition="draft">
    This is only draft text, and will only appear when the "draft" profile is
    selected.
  </para>
  <para>
    The autofs package provides the capability for transparent and on-demand
    mounting of filesystems, which are later (after a period of unuse)
    expired.  Similar to a pay-as-you-go scheme for highways, this does incur
    a slight performance penalty because the filesystem needs to be located
    and mounted at request time.  There is a huge human maintenance burden
    lifted from using this sort of technique, and additionally NFS servers
    will be used only when the filesystem is needed.
  </para>
  <para condition="release">
    This paragraph contains text which will only appear when the "release"
    profile is selected.
  </para>

Now, when you wish to generate the draft text, you can use the following
xsltproc invocation:

  xsltproc --nonet -stringparam base.dir html/ \
    -stringparam profile.condition 'draft' \
    /full/path/to/xsl/profile-chunk.xsl Anti-Spam-HOWTO.xml

If instead you wish to generate the releaset text, you can use the following
xsltproc invocation:

  xsltproc --nonet -stringparam base.dir html/ \
    -stringparam profile.condition 'release' \
    /full/path/to/xsl/profile-chunk.xsl Anti-Spam-HOWTO.xml

Sections which are not marked with a condition attribute will be
sent to the output stream.

If you do not use the profile-$XSL_STYLESHEET, the condition
attribute is completely ignored and all paragraphs regardless of
condition attribute will be sent to the output stream.

This may not be as easy for you as continued use of the less
stringent SGML parameter entities you have grown accustomed to. I
know very little about DocBook SGML, so I'll have to leave that for
another more knowledgeable soul.

Best of luck,

-Martin

 [1] http://www.sagehill.net/xml/docbookxsl/SpecialHandling.html#Profiling
 [2] http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/netwindows/netWindows/docs/
     http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/netwindows/netWindows/winScripts/
     see sigslot.xml and sigslot_core.js


Previous by date: 10 Jun 2003 01:45:07 -0000 Re: Docbook XML and ENTITIES, Greg Ferguson
Next by date: 10 Jun 2003 01:45:07 -0000 Re: Docbook XML and ENTITIES, Hal Burgiss
Previous in thread: 10 Jun 2003 01:45:07 -0000 Re: Docbook XML and ENTITIES, Greg Ferguson
Next in thread: 10 Jun 2003 01:45:07 -0000 Re: Docbook XML and ENTITIES, Hal Burgiss


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