我喜欢有一个DocBook XML文档,该文档具有几个目标受众的内容。是否有一个过滤器使我能够过滤出仅“高级”用户所需的内容?

我发明了级别的属性来表达我的想法。

 <?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没有 level 属性。也许你的意思是 userlevel?

如果您使用docbook XSL样式表来转换文档,则它们具有内置的支持(条件文本)。要使用它,您需要

  1. 使用启用型号的样式表的版本(例如使用 html/profile-docbook.xsl 而不是通常的 html/docbook.xsl), 和

  2. 指定您要通过A上概括的属性值 范围 (例如集 profile.userlevelbasic).

第26章 鲍勃·斯蒂尔顿(Bob Stayton)的 Docbook XSL:完整指南 有所有细节。

其他提示

两种方式,在我的头顶上:

  1. 编写一个快速脚本 level 作为参数,并使用 XPATH 或正则表达式,只能吐出您想要的XML。
  2. 写一个 XSLT转换 那将吐出您想要的XML。

(2)更干净,但(1)可能更快地写书。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top