Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xslt 应用模板在子节点()之后选择子字符串_Xslt - Fatal编程技术网

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>