[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Generating a collection of unique elements.
2008/6/10 Scott Trenda <Scott.Trenda@xxxxxxxx>: > XSLT 2.0 makes 1.0 look stupidly complicated in comparison, but here's > the 1.0 usage case: > > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:key name="FooName" match="foo" use="@name" /> > <xsl:template match="/"> > <newDoc> > <xsl:for-each select="//foo[generate-id() = > generate-id(key('FooName', @name))]"> > <xsl:element name="{@name}" /> > </xsl:for-each> > </newDoc> > </xsl:template> > </xsl:stylesheet> > Relying on 1.0's first item quirk isn't really good practice, much better imho to explicitly select the first.. generate-id(key('FooName', @name)[1]) -- Andrew Welch http://andrewjwelch.com Kernow: http://kernowforsaxon.sf.net/
|
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
|