Subject: Re: [xsl] Multiple instances of the same nodeset - is this possible. From: Mike Brown <mike@xxxxxxxx> Date: Mon, 5 Aug 2002 00:46:14 -0600 (MDT) |
John Aschenbrenner wrote: > I often find myself in a situation where I would like to traverse a nodeset > multiple times simultaneously in a document. Well, in general, that's what template modes are for. For example, at some point you use <xsl:apply-templates select="/path/to/some/nodes"/> when you want normal processing, and <xsl:apply-templates select="/path/to/some/nodes" mode="foo"/> when you want to process the same nodes another way, using a template like: <xsl:template match="nodes" mode="foo"> ... </xsl:template> It's a good way to produce multiple views of the same data. Your example would not benefit from this, though. You can reuse $GetMessagesSet1 because the set does not change. There's no need to have identical sets. That is, your inner for-each could look like this (untested): <xsl:for-each select="$GetMessagesSet1[@MessageID=$MessageID]"> <xsl:value-of select="@Message"/> </xsl:for-each> > I have since solved my problem by using a recursive template Probably not the best solution. You might look into using xsl:key and key() to get the Message attributes more efficiently. For example, run this against your sample data to get the general idea: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" indent="yes"/> <!-- for our purposes, key('msg',foo) is essentially the same as //row[@MessageID=foo] --> <xsl:key name="msg" match="row" use="@MessageID" /> <xsl:template match="/"> <table> <xsl:for-each select="/root/row[@FieldName='ListOfMessages' and @IsNewline='True']"> <tr> <td>___</td> <td> <xsl:for-each select="key('msg',@MessageID)"> <xsl:value-of select="@Message"/> <br/> </xsl:for-each> </td> </tr> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet> - Mike ____________________________________________________________________________ mike j. brown | xml/xslt: http://skew.org/xml/ denver/boulder, colorado, usa | resume: http://skew.org/~mike/resume/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Multiple instances of the, Michael Kay | Thread | RE: [xsl] Multiple instances of the, James Fuller |
RE: [xsl] Writing variable HTML usi, aruniima . chakrabar | Date | RE: [xsl] Writing variable HTML usi, aruniima . chakrabar |
Month |