1
我需要創建XSL遞歸改造,
輸入XMLXSLT/XSL Recusive嵌套元素
<root><foo1 /><foo2 /><foo3 /></root>
輸出
<root>
<foo1>
<foo2>
<foo3>
</foo3>
</foo2>
<foo1>
</root>
非常感謝您的幫助......
我需要創建XSL遞歸改造,
輸入XMLXSLT/XSL Recusive嵌套元素
<root><foo1 /><foo2 /><foo3 /></root>
輸出
<root>
<foo1>
<foo2>
<foo3>
</foo3>
</foo2>
<foo1>
</root>
非常感謝您的幫助......
試試這樣的:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" method="xml"/>
<xsl:template match="/root">
<xsl:copy>
<xsl:apply-templates select="*[1]" />
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="following-sibling::*[1]" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
這將產生以下輸出:
<?xml version="1.0"?>
<root>
<foo1>
<foo2>
<foo3/>
</foo2>
</foo1>
</root>
http://stackoverflow.com/questions/17370562/transformation-in-xslt-with-recursive-nested-templates – user902870