节点,等等
XSLT1.0
或者,如果您愿意:
<xsl:template match="Target">
<xsl:copy>
<xsl:value-of select="../Source[count(current()/preceding-sibling::Target) + 1]"/>
</xsl:copy>
</xsl:template>
以下是一种简单的方法:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- Solution -->
<xsl:template match="Target">
<xsl:copy>
<xsl:value-of select="../Source[substring-after(current(),' ') = substring-after(.,' ')]"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
输出如预期。谢谢!这很有效。是否有任何方法可以将节点的处理仅限于那些具有VAR子元素的父元素?您可以使用.P.S将处理限制为具有值为VAR的同级代码元素的目标元素。如果你的问题得到了回答,请通过接受答案来结束它。
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- Solution -->
<xsl:template match="Target">
<xsl:copy>
<xsl:value-of select="../Source[substring-after(current(),' ') = substring-after(.,' ')]"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>