[Home] [By Thread] [By Date] [Recent Entries]
lee qm wrote:
Input xml (simplified version): The stylesheet below groups child elements by the generated id of the parent element and by the qualified name of the child; that way it creates the output you have shown above. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output indent="yes"/> <xsl:key name="k1" match="*" use="concat(generate-id(..), '{', namespace-uri(), '}', local-name())"/> <xsl:template match="/ASBMessage">
<data>
<o t="TVEQE_{name(.)}">
<xsl:apply-templates select="@* | *"/>
</o>
</data>
</xsl:template> <xsl:template match="@*">
<a n="{name(.)}"><v s="{.}"></v></a>
</xsl:template><xsl:template match="*"> <a n="TVEQE_{name(.)}"> <xsl:for-each select="key('k1', concat(generate-id(..), '{', namespace-uri(), '}', local-name()))"> <o t="TVEQE_{name(.)}"> <xsl:apply-templates select="@*"/> <xsl:apply-templates select="*[generate-id() = generate-id(key('k1', concat(generate-id(..), '{', namespace-uri(), '}', local-name()))[1])]"/> </o> </xsl:for-each> </a> </xsl:template> </xsl:stylesheet> -- Martin Honnen http://msmvps.com/blogs/martin_honnen/
|

Cart



