Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: comparing nodes in xslt

From: inquirydog@-------.--- (----------)
To: NULL
Date: 10/7/2004 12:38:00 PM
Hi-

        The method you describe is the Muenchian Method that I
mentioned in my posting....  And it only works for very simple cases,
where 1). you know ahead of time where the list to be counted is, and
2). where the list items are trivial content (all of the same type). 
For instance just change one of the elements by adding content to it

<element name="1"> => <element name="1"><content /></element>

the example counts this as the same type of element as the ones
without content.

I repeat what I stated before- XSLT 1.0 and 2.0 are (I am pretty sure)
not capable of counting repeat nodes in a list in the general case,
where the list can appear anywhere in the node tree and where the
elements in the list are not of some predetermined type (they can
contain arbitrary content).  This is a limitation of xslt that I
believe should be fixed in future revisions.

                                  thanks
                                          -I


> Your grouping example seems quite simple to do in either XSLT1 or XSLT2,
> it might loook a bit simpler in 2 using the explict xsl:for-each-group
> mechanism, but it doesn't take much code in either case.
> 
> For example in 1.0 it would be:
> 
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
> 
> <xsl:key name="x" match="element" use="@name"/>
> 
> <xsl:template match="list">
>  <list>
>   <xsl:for-each select="element[generate-id()=generate-id(key('x',@name))]">
>    <element name="{@name}" count="{count(key('x',@name))}"/>
>   </xsl:for-each>
>  </list>
> </xsl:template>
> 
> </xsl:stylesheet>


transparent
Print
Mail
Digg
delicious
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