Xslt 应用模板在子节点()之后选择子字符串
这是我的输入文件Xslt 应用模板在子节点()之后选择子字符串,xslt,Xslt,这是我的输入文件 <toc-title>(1) Thsi is <content-style>Short title</content-style> </toc-title> (1)Thsi是简称 我想输出如下: <toctitle> <label>(1)</label> <toctext>Thsi is <content-style>Short title<
<toc-title>(1) Thsi is <content-style>Short title</content-style>
</toc-title>
(1)Thsi是简称
我想输出如下:
<toctitle>
<label>(1)</label>
<toctext>Thsi is <content-style>Short title</content-style></toctext>
</toctitle>
(1)
Thsi是简称
假设第一个子节点始终为文本,则该操作将遍历
的所有子节点。您的问题到底是什么?这不是编码服务。-另外,如果“非常紧急”,请叫救护车——你无权催任何人来这里。
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="UTF-8" indent="yes" method="xml"/>
<xsl:template match="toc-title">
<xsl:copy>
<label>
<xsl:value-of select="substring-before(.,' ')"/>
</label>
<toctext>
<xsl:for-each select="node()">
<xsl:choose>
<xsl:when test="position()=1">
<xsl:value-of select="substring-after(.,' ')"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:value-of select="."/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</toctext>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>