<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>&#xa;</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>&#xa;</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>&#xa;</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>&#160;</xsl:text><xsl:value-of select="."/><xsl:text>&#160;</xsl:text></xsl:for-each>}<xsl:text>&#10;</xsl:text>
</xsl:template>
<xsl:template match="choice" mode="note">
    \explanatory{A másoló által javítva:<xsl:text>&#160;</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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...