![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: comparing nodes in xslt >Thread Next - Re: comparing nodes in xslt Re: comparing nodes in xsltTo: 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>
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
