输入:
<xsl:variable name="nodelist">
<root>
<a size="12" number="11">
<sex>male</sex>
Jens
</a>
<a size="12" number="11">
<sex>male</sex>
Hulk
</a>
<a size="12" number="11">
<sex>male</sex>
Steven XXXXXXXXXXX
</a>
<a size="12" number="11">
<sex>male</sex>
Joschua
</a>
<a size="12" number="11">
<sex>female</sex>
Angelina
</a>
</root>
</variable>
期望的输出:
<root>
<a size="12" number="11">
<sex>male</sex>
Jens
</a>
<a size="12" number="11">
<sex>male</sex>
Hulk
</a>
<a size="12" number="11">
<sex>male</sex>
Steven YYYYYYYYYYYY
</a>
<a size="12" number="11">
<sex>male</sex>
Joschua
</a>
<a size="12" number="11">
<sex>female</sex>
Angelina
</a>
</root>
我想用 XXXXXXXXXXX 更改 a 节点。我可以复制第一个和最后两个节点,更改第三个,然后像这样重新组合在一起吗?(XLST 1.0)
<xsl:variable name="begin">
<xsl:value-of select="substring-before($nodelist, 'XXXXXXXXXXX')"/>
</xsl:variable>
<xsl:variable name="replaceString">
YYYYYYYYYYYY
</xsl:variable>
<xsl:variable name="end">
<xsl:value-of select="substring-after($nodelist, 'xxxxx')"/>
</xsl:variable>
<xsl:variable name="all">
<xsl:copy-of select="$begin"/>
<xsl:copy-of select="$replaceString"/>
<xsl:copy-of select="$end"/>
</xsl:variable>
使用子字符串,我丢失了有关节点的所有信息。这是子字符串的结果
<root>
male Jens
male Hulk
male Steven YYYYYYYYYYYY
male Joschua
female Angelina
</root>