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>
無論如何,我可以修復這個包含子節點的子文本嗎?