seg[@type='dep_event' and @corresp]
没有收到添加的脚注标记,但它出现在底部的 页面.
XSL 文件太长,似乎无法正确粘贴到此处.在此处与文件交互 https://xsltfiddle.liberty-development.net/bdxtqT/6.
注意:我仅限于 XSLT 2.0,因为此转换是在 eXist-DB 内部使用 Xquery 3.1 触发的.
非常感谢!
解决方案
我认为,除非您想在该模板中匹配 /
的所有路径前缀为我建议存储结果的变量标记插入,将现有代码与我的建议合并的一种方法是将匹配从 /
更改为 /*
例如使用
<!-- 文本的 div --><div><!-- 拉丁语:始终存在--><h3>拉丁文</h3><xsl:apply-templates select="//tei:body//tei:p"/><!-- 英语:始终存在--><h3>英语</h3><xsl:apply-templates select="//tei:back//tei:p[@xml:lang='EN']"/><!-- 法语:有时出现--><xsl:if test="//tei:back//tei:p[@xml:lang='FR']"><h3>法语</h3><xsl:apply-templates select="//tei:back//tei:p[@xml:lang='FR']"/></xsl:if><!-- 注释页脚 --><div class="footer"><!-- 脚注(使用 mode="build_footnotes" 在 <div> 中构造脚注块)--><xsl:if test="$footnote-sources"><div class="footnotes" id="footnotesdiv"><xsl:apply-templates select="$footnote-sources" mode="build_footnotes"/>
</xsl:if>
</xsl:模板>
那就意味着我建议使用
<xsl:apply-templates select="$fn-markers- added/node()"/></xsl:模板>
可以保留并且 XSLT 处理器会应用它.
然而,在模板末尾使用了该变量 $footnote-sources
,据我从片段中看到,它在原始输入文档的节点上的使用不会受引入临时结果添加标记的影响,但不知何故对我来说,在那个地方继续处理原始输入而其余部分处理临时结果是错误的,所以我倾向于将变量声明更改为
<xsl:variable name="footnote-sources" select="$fn-markers- added/tei:text//tei:seg//date[@type='deposition_date'] |$fn-markers- added/tei:text//tei:seg//note[@type='public_note'] |$fn-markers- added/tei:text//tei:seg[@corresp]"/>
通过这两个更改,我认为应该应用我在上一个答案中的建议.尽管现在再次查看带有 tei
根元素的已发布源代码,但我想知道具有以 tei:text
开头的路径的全局变量如何选择任何内容,但也许这是在样品.
This question builds on the responses to my original question, where it was suggested that I post a followup. This concerns attempting to integrate the XSL code from the previous post.
In the previous question I presented a simplified version of the TEI:XML document I am transforming into HTML using XSLT 2.0 (the full tei file and current xslt can be found here https://xsltfiddle.liberty-development.net/bdxtqT/6). This is a fuller view of the hierarchy, but not all details:
<tei>
<teiHeader/>
<text>
<front/>
<body>
<p xml:lang="LA">
<seg type="typefoo" corresp="#foo601" xml:id="foo361">
<date type="deposition_date" when="1245">Idus
marcii</date>In non hendrerit metus. Sed in posuere
eros, sit amet pharetra lacus.</seg>
<seg type="typefoo" xml:id="foo362">Nullam semper varius
justo, vitae mollis turpis dapibus sit amet.
Donec<note type="public_note">note content</note>
rhoncus tempor urna sit amet imperdiet.</seg>
<seg type="typefoo" xml:id="foo363">Integer
id ante nunc. Curabitur at ligula sed arcu consequat
gravida et id orci. Morbi quis porta dolor.</seg>
<seg type="typefoo" corresp="#fooid2">Sed dictum<note
type="public_note">note content 2</note> sem nec urna sodales
cursus. Donec sit amet nibh tempor, congue ligula semper,
rhoncus odio.</seg>
</p>
</body>
<back>
<p xml:lang="EN">
<seg>
<seg>
</p>
<p xml:lang="FR">
<seg>
<seg>
</p>
</back>
</text>
<tei>
The desired HTML output is as follows. Incremental footnote numbers are created in <sup>
based on one of three conditions:
date[@type="deposition_date"]
(add footnote no.),
seg[@type="typefoo"]
(add footnote no.)
note[@type="public_note"]
(replace with footnote no.).
Desired output
<div>
<p>Idus marcii<sup>1</sup>In non hendrerit metus. Sed in
posuere eros, sit amet pharetra lacus.</p><sup>2</sup>
<p>Nullam semper varius justo, vitae mollis turpis
dapibus sit amet. Donec<sup>3</sup> rhoncus tempor
urna sit amet imperdiet.</p>
<p>Integer id ante nunc. Curabitur at ligula sed
arcu consequat gravida et id orci. Morbi quis porta
dolor.</p>
<p>Sed dictum sem<sup>4</sup> nec urna sodales cursus.
Donec sit amet nibh tempor, congue ligula semper,
rhoncus odio.</p><sup>5</sup>
<div>
[...]
<div>
<p><sup>1</sup> 1245</p>
<p><sup>2</sup> foo601</p>
<p><sup>3</sup> note here</p>
<p><sup>4</sup> note here</p>
<p><sup>5</sup> fooid2</p>
</div>
The full XSLT transformation document is found at https://xsltfiddle.liberty-development.net/bdxtqT/6, where one can see the following problems:
date[@type='deposition_date']
is being entirely replaced, instead receiving an added footnote marker
seg[@type='dep_event' and @corresp]
is not receiving an added footnote marker, but it appears in the <div>
at the bottom of the page.
The XSL file is too long and doesn't seem to paste here correctly. Interact with files here https://xsltfiddle.liberty-development.net/bdxtqT/6.
NB: I am restricted to XSLT 2.0 as this transformation is fired off inside eXist-DB with Xquery 3.1.
Thanks very much!
解决方案
I think, unless you want to prefix all your paths in that template matching /
with the variable I suggested to store the result of the marker insertion, one way to merge the existing code with my suggestion is to change the match from /
to /*
e.g. use
<xsl:template match="/*">
<!-- div for text -->
<div>
<!-- LATIN : always present -->
<h3>Latin</h3>
<xsl:apply-templates select="//tei:body//tei:p"/>
<!-- ENGLISH : always present -->
<h3>English</h3>
<xsl:apply-templates select="//tei:back//tei:p[@xml:lang='EN']"/>
<!-- FRENCH : sometimes present -->
<xsl:if test="//tei:back//tei:p[@xml:lang='FR']">
<h3>French</h3>
<xsl:apply-templates select="//tei:back//tei:p[@xml:lang='FR']"/>
</xsl:if>
<!-- FOOTER for notes -->
<div class="footer">
<!-- FOOTNOTES (uses mode="build_footnotes" to construct a block of footnotes in <div>) -->
<xsl:if test="$footnote-sources">
<div class="footnotes" id="footnotesdiv">
<xsl:apply-templates select="$footnote-sources" mode="build_footnotes"/>
</div>
</xsl:if>
</div>
</div>
</xsl:template>
that would then mean that my suggestion to use
<xsl:template match="/">
<xsl:apply-templates select="$fn-markers-added/node()"/>
</xsl:template>
can be kept and the XSLT processor would apply it.
There is however the use of that variable $footnote-sources
at the end of the template, as far as I can see from the snippet its use on nodes from the original input document would not be affected by the introduction of a temporary result adding markers but somehow to me it would feel wrong to at that place keep processing the original input while the rest works on the temporary result so I would be inclined to change the variable declaration to
<xsl:variable name="footnote-sources" select="$fn-markers-added/tei:text//tei:seg//date[@type='deposition_date'] |
$fn-markers-added/tei:text//tei:seg//note[@type='public_note'] | $fn-markers-added/tei:text//tei:seg[@corresp]"/>
With those two changes I think my suggestion in the previous answer should then be applied. Although now looking again at the posted source with a tei
root element I wonder how a global variable having paths starting with tei:text
would select anything but perhaps that is an omission in the sample.
这篇关于XSLT 2.0 通过多阶段转换在 HTML 输出中创建增量脚注编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文