[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: in for-each apply-templates doesnot work
> Goal is to select the double datarecords. > I identify them if attribute1 and attribute2 are equal This is essentially a grouping problem, where you are only interested in groups of size 2 or more. As the grouping key is a compound key (it's not the string-value of a node), take a look at Muenchian grouping, either in XSLT Programmer's Reference, or at http://www.jenitennison.com/xslt/grouping. > > In XSL I tried to process with "for-each", > getting the actual position1, > searching the next matching row, > getting that position2 > > <xsl:variable name="pos1"> > <xsl:value-of select="position()"/> > </xsl:variable> > > <xsl:variable name="pos2"> > <xsl:apply-templates > select="following-sibling::row[@attribute1=$value1]"/> > <xsl:value-of select="position()"/> > </xsl:variable> The two calls on position() above will return the same result, since they appear in the same template. You haven't shown us what the template rule for match="row" actually does, but it doesn't make much difference, the above code is not going to do anything useful. A more productive approach would be something like <xsl:variable name="pos2" select="count(following-sibling::row[...]/preceding-sibling::*)"/> but I'm not sure what you want to do with the position once you've got it. > - position results are 2,4,6.. instead of 1,2,3.. That's because you are processing the whitespace text nodes between the elements, as well as the elements themselves. Get rid of them using <xsl:strip-space>. > - the double row found with apply-templates > is processed too. You've lost me here. Fix the other problems first. Mike Kay 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
|