[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Multiple instances of the same nodeset - is this p
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
|
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
|