在DocBook程序列表中切换多种语言

时间:2012-03-15 21:23:23

标签: docbook

Clutter Cookbook(使用DocBook创建)在C中有代码示例。我想在Vala(另一种编程语言)中添加示例,并允许用户通过单击链接在两种语言之间切换。我怎样才能做到这一点?我应该只生成每个页面的两个版本吗?

1 个答案:

答案 0 :(得分:0)

条件文本(分析)可能对此有所帮助:

<para>See this example: <phrase code="c">some C code</phrase> 
                        <phrase code="vala">some Vala code</phrase>
</para>

根据您的处理器,您可以设置选项以选择一种代码语言。对于xsltproc,您可以使用特殊样式表html / profile-chunk.xsl并添加--stringparam profile.code“Vala”来为Vala创建条件XML版本。

xsltproc --output document.vala.xml --stringparam profile.code "vala" ..path-to/html/profile-chunk.xsl document.xml

然后使用自己的样式表和文档的Vala版本(document.vala.xml)执行常用的工具链。

通过这种方式,您可以创建相同的文档两次,但代码不同。

有关详细信息,请参阅http://www.sagehill.net/docbookxsl/Profiling.html,有关链接部分,请查看http://www.sagehill.net/docbookxsl/OlinkVariations.html#ProfilingOlinks