Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] find position of first occurrence in a node set

From: David Carlisle <davidc@--------->
To:
Date: 8/2/2005 10:09:00 PM
> 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
________________________________________________________________________


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent