|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: sequential grouping question
Hello Paul,
it's a really poor XML for grouping. You must group the <xs:element/> by their preceding- or following-sibling::xsl:element[not(starts-with(@ref, 'snoopy'))]. Grouping by a substring must be poor. Do you really have no influence on the input? <xsl:key name="elements" match="xs:element" use="generate-id((preceding-sibling::xs:element | self::xs:element) [not(starts-with(@ref, 'snoopy'))][last()])"/> <xsl:template match="xs:sequence"> <xsl:apply-templates select="key('elements', '')" mode="start"/> <xsl:apply-templates select="key('elements', '')" mode="end"/> --- <xsl:apply-templates select="xs:element[not(starts-with(@ref, 'snoopy'))]" mode="group"/> </xsl:template> <xsl:template match="xs:element" mode="group"> <xsl:apply-templates select="." mode="start"/> <xsl:apply-templates select="." mode="end"/> <xsl:apply-templates select="key('elements', generate-id())[generate-id() != generate-id(current())]" mode="start"/> <xsl:apply-templates select="key('elements', generate-id())[generate-id() != generate-id(current())]" mode="end"/> --- </xsl:template> <xsl:template match="xs:element" mode="start"> <xsl:value-of select="@ref"/> starts </xsl:template> <xsl:template match="xs:element" mode="end"> <xsl:value-of select="@ref"/> ends </xsl:template> Output: snoopy-a starts snoopy-b starts snoopy-c starts snoopy-a ends snoopy-b ends snoopy-c ends --- Harry-GROUP starts Harry-GROUP ends snoopy-d starts snoopy-e starts snoopy-d ends snoopy-e ends --- MickeyMouse-GROUP starts MickeyMouse-GROUP ends snoopy-f starts snoopy-f ends --- Regards, Joerg hb wrote: Hi XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








