我正在使用docbook maven插件编写一些文档,我正在寻找在HTML输出的标题中自动创建导航栏。
我有一些像这样组织的书:
期望的结果是使用XSL样式表为每本书生成HTML输出中的导航栏。类似的东西:
<xsl:template name="user.header.content">
<xsl:for-each select="something">
<xsl:value-of select="somethingelse"/>
</xsl:for-each>
</xsl:template>
提前致谢:)。
答案 0 :(得分:0)
使用标准XSLT函数document()
。
示例强>:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:value-of select=
"document('http://www.w3.org/2007/schema-for-xslt20.xsd')
/*/xs:annotation[1]/xs:documentation
"/>
</xsl:template>
</xsl:stylesheet>
当对任何XML文档(未使用)应用此转换时,它将访问指定URL处的XML文档(这是XSLT 2.0语言的XSD)并输出第一个{{ 1}}此远程XML文档的元素:
xs:annotation/xs:documentation
请注意:
如果要访问的XML文档驻留在本地文件中,请使用“file:”模式,如下所示:
This is a schema for XSLT 2.0 stylesheets.
It defines all the elements that appear in the XSLT namespace; it also
provides hooks that allow the inclusion of user-defined literal result elements,
extension instructions, and top-level data elements.
The schema is derived (with kind permission) from a schema for XSLT 1.0 stylesheets
produced by Asir S Vedamuthu of WebMethods Inc.
This schema is available for use under the conditions of the W3C Software License
published at http://www.w3.org/Consortium/Legal/copyright-software-19980720
The schema is organized as follows:
PART A: definitions of complex types and model groups used as the basis
for element definitions
PART B: definitions of individual XSLT elements
PART C: definitions for literal result elements
PART D: definitions of simple types used in attribute definitions
This schema does not attempt to define all the constraints that apply to a valid
XSLT 2.0 stylesheet module. It is the intention that all valid stylesheet modules
should conform to this schema; however, the schema is non-normative and in the event
of any conflict, the text of the Recommendation takes precedence.
This schema does not implement the special rules that apply when a stylesheet
has sections that use forwards-compatible-mode. In this mode, setting version="3.0"
allows elements from the XSLT namespace to be used that are not defined in XSLT 2.0.
Simplified stylesheets (those with a literal result element as the outermost element)
will validate against this schema only if validation starts in lax mode.
This version is dated 2007-03-16
Authors: Michael H Kay, Saxonica Limited
Jeni Tennison, Jeni Tennison Consulting Ltd.
2007-03-15: added xsl:document element
revised xsl:sequence element
see http://www.w3.org/Bugs/Public/show_bug.cgi?id=4237
答案 1 :(得分:0)
根据我的经验,通过网络浏览器提供文档的最佳方式是maven-site-plugin
。
maven-site-plugin
可让您生成网站,然后将其发布到POM的<distributionManagement>
部分中指定的网址。
您可以编写&#34;导航栏&#34;在index.html
中通过编辑(在类似wiki的APT format中)相对index.apt
:
+- src/
+- site/
+- apt/
| +- index.apt
然后生成网站:
+- target/
+- site/
+- index.html
+- resources/
+- Guide1.html
+- Guide2.html
+- tuto1.html
+- tuto2.html
+- Guide1.pdf
+- Guide2.pdf
+- tuto1.pdf
+- tuto2.pdf
可以通过 Maven方式实现:
my-prj-doc
,my-prj-site
my-prj-doc
按docbkx-maven-plugin
构建DocBook文档。该项目的主要工件应该是my-prj-doc-1.0.0.jar
,它将安装在您的本地Maven存储库(.m2
目录中)my-prj-site
按maven-site-plugin
生成网站;此外,maven-dependency-plugin
(最终附加到site
阶段)从您的本地Maven存储库获取my-prj-doc-1.0.0.jar
并将其解压缩到target/site/resources/
目录我的经验证明,这种方式是最好的方式之一,因为给出了:
faq-1.0.0.jar
和Guide1
Maven子项目中导入Guide2
工件,这样就可以保存一个FAQ子项目你就可以了在两个(或更多)不同的最终文件中使用相同的常见问题解答。