it would be kind if someone can help me with this piece of xmlt.
I want to transform this xml piece:
<root>
<rowdata>
<ID>1</ID>
<pxPages>
<rowdata>
<comment>comment 1</comment>
</rowdata>
</pxPages>
</rowdata>
<rowdata>
<ID>2</ID>
<pxPages>
<rowdata>
<comment>comment 2</comment>
</rowdata>
</pxPages>
</rowdata>
<rowdata>
<ID>2</ID>
<pxPages>
<rowdata>
<comment>comment 3</comment>
</rowdata>
</pxPages>
</rowdata>
</root>
into
<root>
<ResultOperationalStatusCategory开发者_JAVA百科>
<identifier>1</identifier>
<comment>comment 1</comment>
</ResultOperationalStatusCategory>
<ResultOperationalStatusCategory>
<identifier>2</identifier>
<comment>comment 2</comment>
<comment>comment 3</comment>
</ResultOperationalStatusCategory>
THANKS!
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:key name="k" match="rowdata" use="ID"/>
<xsl:template match="/root">
<xsl:copy>
<xsl:apply-templates select="rowdata[generate-id(.) =
generate-id(key('k', ID))]"/>
</xsl:copy>
</xsl:template>
<xsl:template match="rowdata">
<ResultOperationalStatusCategory>
<identifier>
<xsl:value-of select="ID"/>
</identifier>
<xsl:copy-of select="key('k', ID)//comment"/>
</ResultOperationalStatusCategory>
</xsl:template>
</xsl:stylesheet>
Output:
<root>
<ResultOperationalStatusCategory>
<identifier>1</identifier>
<comment>comment 1</comment>
</ResultOperationalStatusCategory>
<ResultOperationalStatusCategory>
<identifier>2</identifier>
<comment>comment 2</comment>
<comment>comment 3</comment>
</ResultOperationalStatusCategory>
</root>
精彩评论