Subject: RE: [xsl] Muenchean grouping as template... From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx> Date: Mon, 16 Feb 2004 19:31:27 +0100 |
> -----Original Message----- > From: Nikolas Nehmer > But i need to pass the nodeset on which the transform should be done > to the default visualizer, maybe with a param. > But the key for my muenchen grouping will be defined before ... Hi, I see (from the other thread) that you already managed to solve your problem, but anyway... Yes, indeed the key will be defined *before* ... but as indicated, and as your trial-and-error in the other thread has shown you, you can change the context in which it operates. In your case, the context was changed to a node offering a match only on the root element of your source XML, so the output was not as intended, but it remains a *feature* after all. (you might wanna check Dave Pawson's FAQ under 'Keys', http://www.dpawson.co.uk/xsl/sect2/N4852.html there's a few very interesting examples and demos there to show you what keys do and how to use them Once you get the hang of it, you'll be surprised at how many for-each's or choose/when/otherwises can be avoided by a proper combination of xsl:key, generate-id() and xsl:variable...) On to your stylesheet (which seemed to be moving into the right direction, apart from a few minor, yet very important details) > <tr> > <xsl:for-each select="$unique-elements"> > <xsl:variable name="elements-by-name" > select="key('elementtags-by-name', name(.))"/> > <td> > <xsl:choose> > <xsl:when test="@href"> > <xsl:apply-templates > select="$elements-by-name[name() = name(.)]" > mode="association_aggregation"/> (BUZZ!!!) _Almost_ right... Try select="$elements-by-name[name(.)=name(current())] As I understand, . returns you the current node in the current context. Context here is XPath (everything between [ ]), while current() gives you the current node in XSLT context (determined by surrounding apply-templates/for-each/...) even inside angled brackets. In this case, current() would return you the node being processed in the context of the for-each. Further hint: It seems like you could do with the local-name() function to strip the namespace prefixes (no choose/when/otherwise needed): <xsl:template match="*" mode="header"> <th><xsl:value-of select="local-name(.)" /></th> </xsl:template> Cheers, Andreas XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Muenchean grouping as tem, David Carlisle | Thread | AW: [xsl] Muenchean grouping as tem, Nikolas Nehmer |
[xsl] Attribute/Variable syntax asy, Willink, Ed | Date | [xsl] background in block container, Mark Williams |
Month |