Subject: RE: [xsl] Multiple instances of the same nodeset - is this possible. From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx> Date: Mon, 5 Aug 2002 07:23:36 +0100 |
Your question suggests you are rather confused about node-sets. I can't pin down exactly what your confusion is. A node-set is a set of nodes, nothing more. XSLT doesn't care whether two variables containing the same set of nodes are "the same node-set" or "different node-sets", because there is no concept of node-set identity. All of this has nothing to do with why your code doesn't work. Your code is relying on some relationship between the attributes ListID, MessageID, and isNewline: you haven't explained this relationship to us, so I won't try and reverse-engineer your design. If you simply want to do what you described, and start a new record whenever isNewLine is true, then your choices are: (a) a recursive template (b) Muenchian grouping, using generate-id((.|preceding-sibling::row)[@isNewLine='true']) as the grouping key (c) the XSLT 2.0 construct <xsl:for-each-group group-starting-with="row[@isNewLine='true']"> Michael Kay Software AG home: Michael.H.Kay@xxxxxxxxxxxx work: Michael.Kay@xxxxxxxxxxxxxx > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of > John Aschenbrenner > Sent: 04 August 2002 23:01 > To: 'XSL-List@xxxxxxxxxxxxxxxxxxxxxx' > Subject: [xsl] Multiple instances of the same nodeset - is > this possible. > > > I often find myself in a situation where I would like to > traverse a nodeset multiple times simultaneously in a document. > Example: > <root> > <row FieldName="CustName" Message="FREELOADER FREDDIE"/> > <row ListID="391" FieldName="ListOfMessages" > Message="This is a message." MessageID="391" IsNewline="True"/> > <row ListID="402" FieldName="ListOfMessages" > Message="Freddie has up to 1 full month" MessageID="402" > IsNewline="True"/> > <row ListID="403" FieldName="ListOfMessages" > Message="to pay off his bill." MessageID="402" IsNewline="False"/> > <row ListID="408" FieldName="ListOfMessages" > Message="Most recent data for FREELOADER FREDDIE." > MessageID="408" IsNewline="True"/> > <row ListID="415" FieldName="ListOfMessages" > Message="Favorite sports and hobbies: Bicycling backgammon" > MessageID="415" IsNewline="True"/> > <row ListID="416" FieldName="ListOfMessages" > Message="and sailing." MessageID="415" IsNewline="False"/> > <row ListID="514" FieldName="ListOfMessages" > Message="Signed liability waiver If participating in > category" MessageID="514" IsNewline="True"/> > <row ListID="515" FieldName="ListOfMessages" > Message="A sporting activities." MessageID="514" IsNewline="False"/> > </root> > > > What I would like to do with this data is output it in a > tabular format. If the attribute IsNewline="True" then I > have the beginning of a new record else just concatenate it > to the previous. > > I have a template that looks like this. > <xsl:template name="GetMessages"> > <xsl:param name="GetMessagesSet1"/> > <xsl:param name="GetMessagesSet2"/> > > <xsl:for-each select="$GetMessagesSet1[@IsNewline='True']"> > <xsl:variable name="i" select="position()"/> > <xsl:variable name="MessageID" > select="$GetMessagesSet1[$i]/@ListID" > <tr> > <td valign="bottom" align="left" width="10%"> > <p class="feedbackMsg">______</p> > </td> > <td align="left" width="80%"> > <p class="feedbackMsg"> > > <xsl:for-each > select="$GetMessagesSet2[@MessageID=$MessageID]"> > <xsl:variable name="j" > select="position()"/> > <xsl:value-of > select="$GetMessagesSet1[@MessageID=$MessageID][$j]/@Message"/> > </xsl:for-each> > > </p> > </td> > <td valign="bottom" align="middle" width="10%"> > <p > class="feedbackMsg">________________</p> > </td> > </tr> > </xsl:for-each> > > </xsl:template> > > As you may have guessed when I call this template as follows > <xsl:call-template name="GetMessages"> > <xsl:with-param name="GetMessagesSet1" > select="z:row[@FieldName='ListOfMessages']"/> > <xsl:with-param name="GetMessagesSet2" > select="z:row[@FieldName='ListOfMessages']"/> > </xsl:call-template> > > it does not work as I would like because even though I think > I have created two independent nodesets. I only have one. > > My question is this - Is it somehow possible to have two > independent nodesets with identical data that you can > traverse simultaneously? > > I have since solved my problem by using a recursive template > - however I would still like my question answered. > > Thank you, > John Aschenbrenner > Ignition Mortgage Technology Solutions, Inc. > jaschenbrenner@xxxxxxxxxxxxxxx > Ph: (253)858-8955 x 239 > http://www.ignitionmts.com > > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Multiple instances of the sam, John Aschenbrenner | Thread | Re: [xsl] Multiple instances of the, Mike Brown |
RE: [xsl] Re: Efficiency, use param, Michael Kay | Date | RE: [xsl] Writing variable HTML usi, Michael Kay |
Month |