[Home] [By Thread] [By Date] [Recent Entries]
Use a named template or a function that you call recursively. Arguments
are the items to be grouped (population) and the stack of names of
elements that you want to group-starting-with:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0"> <xsl:output indent="yes"/> <xsl:template match="doc"> <xsl:copy> <xsl:call-template name="group"> <xsl:with-param name="population" select="*"/> <xsl:with-param name="name-stack" select="('a', 'b', 'c', 'd')"/> </xsl:call-template> </xsl:copy> </xsl:template> <xsl:template name="group"> <xsl:param name="population" as="element(*)*"/> <xsl:param name="name-stack" as="xs:string*"/> <xsl:choose> <xsl:when test="exists($population) and exists($name-stack)"> <xsl:for-each-group select="$population" group-starting-with="*[local-name() = $name-stack[1]]"> <xsl:element name="layer{$name-stack[1]}"> <xsl:copy-of select="."/> <xsl:call-template name="group"> <xsl:with-param name="population" select="current-group() except ."/> <xsl:with-param name="name-stack" select="$name-stack[position() gt 1]"/> </xsl:call-template> </xsl:element> </xsl:for-each-group> </xsl:when> <xsl:otherwise> <xsl:copy-of select="$population"/> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> On 08.04.2014 08:12, Szabo, Patrick (LNG-VIE) wrote: Hi,
Registergericht / Commercial Register: Amtsgericht Leipzig Registernummer / Registration Number: HRB 24930 GeschC$ftsfC<hrer: Gerrit Imsieke, Svea Jelonek, Thomas Schmidt, Dr. Reinhard VC6ckler
|

Cart



