如何解决<xsl.apply-templates> 也重新创建父节点
当我使用 xsl:apply-template 时,它也会创建父节点的另一个实例。
我有以下 xml:
<TEI>
<teiHeader>
<fileDesc>
<titleStmt>
<title>title <app><lem>corr</lem><rdg wit="B">corr2</rdg></app> other part of the title.</title>
</titleStmt>
<publicationStmt> </publicationStmt>
<sourceDesc>
<bibl/>
</sourceDesc>
</fileDesc>
</teiHeader>
<text>
<body>
<lg>
<l>line1</l>
<l>line2</l>
<l>line3<app><lem>correction in line</lem><rdg wit="list of witness"
>one correction</rdg>
<rdg wit="more witness">two correction</rdg></app></l>
<l>line4</l>
</lg>
</body>
</text>
我写了以下 xsl:
<xsl:stylesheet
xmlns="http://www.tei-c.org/ns/1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="/">
\documentclass[a4paper,12pt]{book}
\somelatexstuff
\begin{document}
<xsl:apply-templates mode="text"/>
\end{document}
</xsl:template>
<xsl:template match="teiHeader/fileDesc/titleStmt/title" mode="text">
\centertitles\poemtitle{<xsl:copy-of select="text()[normalize-space()][1]"/><xsl:apply-templates mode="inline"/>}<xsl:apply-templates mode="note"/><xsl:text>
</xsl:text>}
</xsl:template>
<xsl:template match="text/body" mode="text">
\setverselinemodulo{5}
\begin{poem}
<xsl:for-each select="lg">
\begin{stanza}
<xsl:apply-templates mode="line"/>
</xsl:for-each>
\end{poem}
</xsl:template>
<xsl:template match="l[not(position() = 4)]" mode="line">
<xsl:copy-of select="text()[normalize-space()][1]"/><xsl:apply-templates mode="inline"/>\verseline<xsl:apply-templates mode="note"/><xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="l[position() = 4]" mode="line">
<xsl:copy-of select="text()[normalize-space()][1]"/><xsl:apply-templates mode="inline"/>\end{stanza}<xsl:apply-templates mode="note"/><xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="app" mode="inline">
\textit{<xsl:value-of select="lem"/>}
</xsl:template>
<xsl:template match="choice" mode="inline">
\textit{<xsl:value-of select="sic"/>}
</xsl:template>
<xsl:template match="app" mode="note">
\explanatory{<xsl:for-each select="rdg"><xsl:value-of select="./@wit"/>:<xsl:text> </xsl:text><xsl:value-of select="."/><xsl:text> </xsl:text></xsl:for-each>}<xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="choice" mode="note">
\explanatory{A másoló által javítva:<xsl:text> </xsl:text><xsl:value-of select="corr"/>}
</xsl:template>
获得以下输出:
\documentclass[a4paper,12pt]{book}
\somelatexstuff
\begin{document}
\centertitles\poemtitle{title
\textit{corr}
other part of the title.}
\explanatory{B: corr2 }
}
\setverselinemodulo{5}
\begin{poem}
\begin{stanza}
line1\verseline
line2\verseline
line3
\textit{correction in line}
\verseline
\explanatory{list of witness: one correction more witness: two correction }
line4line4\end{stanza}
\end{poem}
\end{document}
但我明白了:
```
\documentclass[a4paper,12pt]{book}
\somelatexstuff
\begin{document}
\centertitles\poemtitle{title title
\textit{corr}
other part of the title.}title
\explanatory{B: corr2 }
other part of the title.
}
\setverselinemodulo{5}
\begin{poem}
\begin{stanza}
line1line1\verselineline1
line2line2\verselineline2
line3line3
\textit{correction in line}
\verselineline3
\explanatory{list of witness: one correction more witness: two correction }
line4line4\end{stanza}line4
\end{poem}
\end{document}
```
因此,当我使用 apply-template 并将其再次粘贴到 childnode 之前时,它基本上重新创建了 prat 节点。 (我整理了一下我的输出,它包含很多空行) 我做错了什么? 提前致谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。