2

我喜欢有一个包含多个目标受众内容的 docbook xml 文档。是否有一个过滤器可以让我过滤掉“高级”用户才需要的东西?

level 属性是我发明的,用来表达我的想法。

 <?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>
4

2 回答 2

2

DocBook 没有level属性。也许你的意思是userlevel

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

  1. 使用启用分析的样式表版本(例如使用html/profile-docbook.xsl而不是通常的html/docbook.xsl),并且

  2. 通过参数(例如,设置profile.userlevelbasic)指定要分析的属性值。

Bob Stayton 的DocBook XSL: The Complete Guide的第 26 章包含所有详细信息。

于 2010-08-27T19:21:30.847 回答
0

两种方法,我的头顶:

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

(2) 更干净,但 (1) 可能写起来更快。

于 2010-08-26T15:19:48.130 回答