IZASKUN GUTIERREZ GUTIERREZ wrote:
I need group by tags this xml for example. The problem is that I dont
know the name of the tags. Only I know the tag "Book" and the ID "boo2"
Here is an XSLT 2.0 solution:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
version="2.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Book[(_at_)rdf:ID = 'boo2']">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:for-each-group select="*" group-by="name()">
<xsl:element name="{current-grouping-key()}">
<xsl:copy-of select="@* | text()"/>
<xsl:for-each-group select="current-group()/*" group-by="name()">
<xsl:element name="{current-grouping-key()}">
<xsl:copy-of select="current-group()/*"/>
</xsl:element>
</xsl:for-each-group>
</xsl:element>
</xsl:for-each-group>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
For your provided XML sample it gives the result you describe.
--
Martin Honnen
http://JavaScript.FAQTs.com/
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--