这是一个简化的XML,它揭示了我遇到的问题的一般结构。
<chapter num="07">
<title>
<page num="703"/>
... text (mixed content) ...
</title>
<page num="704"/>
<section level="sect1">
<title>...text...</title>
<para num="7.1.1">... a lot of text (mixed content)...</para>
</section>
<section level="sect1">
<title>... text... </title>
<para num="7.2.1">Some text...
<footnoteref linkend="fn3" num="3"/>
<footnote num="3" id="fn3"> ... mixed content ...</footnote>
...more text...
</para>
<page num="705"/>
<section level="sect2">
<title>...</title>
<para num="7.2.2">... text ...
<footnoteref linkend="fn4" num="4"/>
<footnote num="4" id="fn4">...</footnote>
... more text ...
<footnoteref linkend="fn5" num="5"/>
<footnote num="5" id="fn5">...</footnote>
... more text ...
</para>
<para num="7.2.5">...
<page num="706"/>...
<footnoteref linkend="fn6" num="6"/>
<footnote num="6" id="fn6"> ... </footnote>
</para>
<para num="7.2.6">... some text
<footnoteref linkend="fn7" num="7"/>
<footnote num="7" id="fn7"> ... </footnote>
</para>
</section>
</section>
</chapter>
我必须先放置一个处理说明<?pb label='
页码 '?>
,然后与前一个<footnote>
匹配<page>
num
1}}。它应该只出现一次,页码应该与出现的最后一个<page>
元素的<?pb label='704'?>
属性中的值相同。
例如,如果我处理上面的源代码,我希望在<footnote num="3">
之前,一个之前在我的结果文档中生成一个 <?pb label='705'?>
紧接<footnote num="4">
之前的<?pb label='706'?>
(将脚注4和5分组),紧接<footnote num="6">
之前的一个 <footnote>
(分组脚注6和7)。有一个模板可以处理<footnoteref>
元素,它们在每个页面的末尾放在一起,前面是处理指令(footnote
元素保持原样)。
我的XSL是here。由于它太大了,我无法将其粘贴在这里。
我在脚注处理说明(pb标签)中得到重复。应该在最后一个page
标记后面的第一个preceding::page
之前有一个pblabel。我尝试与<?pb label='706'?>
匹配,但它不起作用。相同的处理指令被重复多次。例如:footnote 6
只应出现在footnote
之上,因为它是page 706
之后的第一个{{1}}。
答案 0 :(得分:1)
如果不进行耗时的分析,很难分辨,但请尝试更改此xsl:if
(match="footnote" mode="footnote"
中):
<xsl:if test="preceding::node()[page[1]]">
<xsl:variable name="op"><</xsl:variable>
<xsl:variable name="apos">'</xsl:variable>
<xsl:variable name="cl">></xsl:variable>
<xsl:value-of select="concat($op,'?pb label=',$apos,preceding::page[1]/@num,$apos,'?',$cl)"/>
</xsl:if>
对此:
<xsl:if test="(preceding::page|preceding::footnote)[last()][self::page]">
<xsl:processing-instruction name="pb" select="concat('label=''',preceding::page[1]/@num,'''?')"/>
</xsl:if>
有点奇怪的是,当您的输出方法是HTML(具有SGML处理指令)时,您正在尝试输出XML处理指令。