0
与节点carring文字我想转换一个XML文件,以XML,但我想也有一些文字与其他元素转换XSLT XML转换成XML通过XSLT
输入:
<parent> Some parent text
<child1>child text</child1><child2>child text</child2>
more parent text</parent>
所需的输出:
<parent><text>Some parent text</text>
<child1>child text</child><child2>child text</child2>
<text>more parent text</text></parent>
我的XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:output method="text" indent="no"/>
<xsl:template match="node()">
<xsl:copy>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="parent/text()">
<xsl:element name="node">
<xsl:apply-templates select="text()"/>
</xsl:element>
</xsl:template>
<xsl:template match="child1">
<xsl:element name="child1">
<xsl:apply-templates select="node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="child2">
<xsl:element name="child2">
<xsl:apply-templates select="node()"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
无论如何,我可以修复这个包含子节点的子文本吗?