views:

39

answers:

2

I like to have one docbook xml document that has content for serveral target audiences. Is there a filter that enables me to filter out the stuff only needed for "advanced" users?

The level attribute is invented by me to express what I have in mind.

 <?xml version="1.0"?>
 <book>  
   <title lang="en">Documentation</title>

   <chapter id="introduction" level="advanced">  
       <title>Introduction for advanced users</title>
   </chapter>

   <chapter id="introduction" level="basic">  
      <title>Introduction for basic users</title>
   </chapter>  

   <chapter id="ch1">
      <para level="basic">Just press the button</para>
      <para level="advanced">
           Go to preferences to set your
           needs and then start the process 
           by pressing the button.
      </para>
   </chapter>
</book>
A: 

Two ways, off the top of my head:

  1. Write a quick script that takes the level as a parameter and, using XPath or regular expressions, that only spits out the XML you want.
  2. Write an XSLT transformation that will spit out the XML you want.

(2) is cleaner, but (1) is probably faster to write up.

The Alchemist
I expected that docbook has something ready for this but as you said basic xslt works. see my other post with source. thanks.
schoetbi
+1  A: 

DocBook does not have a level attribute. Perhaps you meant userlevel?

If you are using the DocBook XSL stylesheets to transform your documents, they have built-in support for profiling (conditional text). To use it you need to

  1. use the profiling-enabled version of the stylesheet (e.g. use html/profile-docbook.xsl instead of the usual html/docbook.xsl), and

  2. specify the attribute values you want to profile on via a parameter (e.g. set profile.userlevel to basic).

Chapter 26 of Bob Stayton's DocBook XSL: The Complete Guide has all the details.

Jukka Matilainen
Many thanks. I couldn't imaginge that docbook does not have something like this.
schoetbi