Hi All,
It's a bit off topic because it's not directly linked with XForms or Orbeon. But it's related to the xslt processor, so it might be the good place to ask ;-) I have this xml : <items> <item code="1"/> <item code="2"/> <item code="2"/> <item code="3"/> </items> The xsl is like that : ... <xsl:template match="/items"> <items> <xsl:apply-templates select="item" /> </items> </xsl:template> <xsl:template match="item"> ....some code </xsl:template> With this xslt I work on the 4 nodes called "item". But I only want to work on the different "code". So only 1 time with the different "code"(1,2,3). How can I do that ? -- Marc -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
marc wrote:
Hi > It's a bit off topic because it's not directly linked with > XForms or Orbeon. > But it's related to the xslt processor, so it might be the > good place to ask ;-) For general XSLT qnd XPath related questions, you can use XSL List at Mulberrytech. > <items> > <item code="1"/> > <item code="2"/> > <item code="2"/> > <item code="3"/> > </items> > <xsl:apply-templates select="item" /> > But I only want to work on the different "code". So only 1 > time with the different "code"(1,2,3). You want grouping. You can look at the XSL List archives for comprehensive reference, or at the Dave Pawson's XSL FAQ: http://dpawson.co.uk/xsl/sect2/N4486.html. For XSLT 1, you can look at http://www.jenitennison.com/xslt/grouping/, and for XSLT 2, you can use xsl:for-each-group: <xsl:for-each-group select="item" group-by="@code"> <xsl:apply-templates select="."/> </xsl:for-each-group> If you only want the dinstinct values (not the nodes), in XPath 2 you have the function dinstinct-values(): <xsl:for-each select="distinct-values(item/@code)"> ... </xsl:for-each> Regards, --drkm ___________________________________________________________________________ Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire. http://fr.mail.yahoo.com -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Florent Georges a écrit :
> You want grouping. You can look at the XSL List archives for >comprehensive reference, or at the Dave Pawson's XSL FAQ: >http://dpawson.co.uk/xsl/sect2/N4486.html. For XSLT 1, you can look at >http://www.jenitennison.com/xslt/grouping/, and for XSLT 2, you can use >xsl:for-each-group: > > <xsl:for-each-group select="item" group-by="@code"> > <xsl:apply-templates select="."/> > </xsl:for-each-group> > > If you only want the dinstinct values (not the nodes), in XPath 2 you >have the function dinstinct-values(): > > <xsl:for-each select="distinct-values(item/@code)"> > ... > </xsl:for-each> > > Regards, > >--drkm > > -- Marc -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Free forum by Nabble | Edit this page |