【发布时间】:2013-09-01 18:11:14
【问题描述】:
考虑以下 xml:
<book>
<chapter>
<title>chapter title 1</title>
<id>chapterId1</id>
<content>some content</content>
</chapter>
<chapter>
<title>chapter title 2</title>
<id>chapterId2</id>
<content>some content</content>
</chapter>
</book>
我想生成一本带有目录的书。所以我像这样创建目录:
<xsl:for-each select="book/chapter">
<fo:block>
<xsl:value-of select="title" />
<fo:page-number-citation ref-id="id" >
<xsl:attribute name="ref-id">
<xsl:value-of select="id" />
</xsl:attribute>
</fo:page-number>
</fo:block>
</xsl:for-each>
ref-id 属性会被即时覆盖并替换为章节 ID 的值。
这里的问题是引用的 id 在文档中还不知道。因为我使用相同的<xsl:attribute> 元素在 cahpeter 块上创建设置章节 ID。
<fo:block> <!-- the chapter container -->
<xsl:attribute name="id">
<xsl:value-of select="chapter/id" />
</xsl:attribute>
<fo:block>
the chapter content.....
</fo:block>
</fo:block>
如何预处理我的 xsl:fo 文件,以便 fo:block 元素已设置正确的 ID?
谢谢
【问题讨论】:
标签: xml xslt xml-parsing xsl-fo