[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: RE: (Keys on multiple element types)
Hi Ahmad, > OK, so if I do > > <xsl:key name="rows" match="FILES/*" > use="concat(name(), '+', name)" /> So the key values are: 'RECORDA+Fred' 'RECORDA+Fred' 'RECORDB+Fred' 'RECORDC+Harry' > <xsl:template match="FILES"> > <xsl:apply-templates select="*[generate-id(.) = > generate-id(key('rows', concat(name(), '+', name))[1])]"/> > </xsl:template> > > <xsl:template match="FILES/*"> > <xsl:value-of select="name"/> > <xsl:for-each select="key('rows', name)"> > <xsl:value-of select="$newline"/> > <xsl:value-of select="project_name"/> > <xsl:value-of select="$newline"/> > </xsl:for-each> > </xsl:template> In this template you're printing the name of the selected record (i.e. 'Fred', 'Fred' and 'Harry'. Then you're trying to recover all those records whose key value is the same as that name (e.g. those records whose key value is simply 'Fred'). As you've seen above, the key values are actually combinations of the name of the record element and the name element child of the record, so you end up iterating over an empty node set, which is why you don't get the project_names coming out. What you wanted to do was: <xsl:for-each select="key('rows', concat(name(), '+', name))"> <xsl:value-of select="$newline" /> <xsl:value-of select="project_name" /> <xsl:value-of select="$newline" /> </xsl:for-each> > I get FredFredHarry. So its removed the extra Fred but doesnt print the > project_names. If I change this so that instead of name I group by > project-name..thus This had exactly the same problem as above, but was otherwise perfectly correct as far as I could tell :) Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ 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
|