[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

Subject: Re: find position of first occurrence in a node set
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 2 Aug 2005 22:40:06 +0100
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
________________________________________________________________________

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.