Subject: RE: [xsl] Grouping and transforming XML elements From: Jarno.Elovirta@xxxxxxxxx Date: Tue, 10 Jun 2003 11:11:55 +0300 |
Hi, > type(1) subtype(2): A, B, C. type(2) subtype(3): ZZ, WW. type(3): JJ. > type(1) subtype(2): AA, BB. > > That is, each <stuff> is to be on a line of its own. Some > sample code would > be fantastic. <xsl:output method="text"/> <xsl:template match="/"> <xsl:for-each select="doc/stuff"> <xsl:if test="not(position() = 1)"> <xsl:text>
</xsl:text> </xsl:if> <xsl:for-each select="*[not(@type = preceding-sibling::*[1]/@type)]"> <xsl:text/>type(<xsl:value-of select="@type"/>) <xsl:text/> <xsl:for-each select="../*[@type = current()/@type and not(@subtype = preceding-sibling::*[1]/@subtype)]"> <xsl:choose> <xsl:when test="@subtype"> <xsl:text/>subtype(<xsl:value-of select="@subtype"/>): <xsl:text/> <xsl:for-each select="../*[@type = current()/@type and @subtype = current()/@subtype]"> <xsl:if test="not(position() = 1)">, </xsl:if> <xsl:value-of select="."/> </xsl:for-each> <xsl:text>. </xsl:text> </xsl:when> <xsl:otherwise> <xsl:for-each select="../*[@type = current()/@type]"> <xsl:if test="not(position() = 1)">, </xsl:if> <xsl:value-of select="."/> </xsl:for-each> <xsl:text>. </xsl:text> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:for-each> </xsl:for-each> </xsl:template> Use keys if you need more speed. Cheers, Jarno - Hocico: Poltergeist XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Grouping and transforming XML, Michael Leung | Thread | [xsl] XML::LibXSLT question, Simon . Fairey |
RE: [xsl] XML::LibXSLT question, Jarno . Elovirta | Date | Re: [xsl] Again: XML to RTF - displ, David Carlisle |
Month |