[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: find position of first occurrence in a node set
> 2) As you can see I'm having to copy in the current-group() to a > variable before I can apply the <xsl:number> instruction. I tried this: That's a postentially expensive way of getting the right number, as copying a tree is a relatively expensive oeration. > <xsl:number select="current-group[@type='HL'][1]"/> > > But the value I get in return is wrong. It seems to be counting the > attributes as well as the <segment> elements. No, it's just counting elements but it is counting all elements based on the document structure (not just those in the current group) Your actual posted question didn't involve groping and <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method = "html" omit-xml-declaration="yes" /> <xsl:template match="/"> <xsl:number select="*/segment[@type='HL'][1]"/> </xsl:template> </xsl:stylesheet> returns 3. If you are grouping as well then you'll need to restrict the numbering to your group. Copying the group to another tree os one way, as you found, but there may be more efficient ways eg using xsl:number's from attribute, but it depends.... David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
|
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
|