xsl-list
[Top] [All Lists]

AW: Muenchean grouping as template...

2004-02-16 12:06:49
Thanks a lot for your hints. I'm more or less new to XML, coming from
the OO world (Java,...) so I am happy about every help.

Best regards,
Nick


|-----Ursprüngliche Nachricht-----
|Von: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com [mailto:owner-xsl-
|list(_at_)lists(_dot_)mulberrytech(_dot_)com] Im Auftrag von Andreas L. 
Delmelle
|Gesendet: Montag, 16. Februar 2004 19:31
|An: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
|Betreff: RE: [xsl] Muenchean grouping as template...
|
|> -----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


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>