문제

I like to have one docbook xml document that has content for several 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>
도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top