Re: [xsl] dynamic sorting

Subject: Re: [xsl] dynamic sorting
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 5 Feb 2004 17:24:08 GMT
  both expressions should give the same
  result?

  1. select="count(someNode)"
  2. select="count(*[name() = someNode])"

No the first one is similar to

2. select="count(*[name() = 'someNode'])"

as you have it, without the quotes, you are selecting elements whose name
is equal to the string content of their someNode child, ie things like
<abc>auk iu <someNode>abc</someNode> jhg </abc>
would be selected as name() and someNode both have string value 'abc'.

> What do you mean with "namespace-safe"? 
If you use a document with namespaces (eg a stylesheet) then selecting
count(xsl:variable)
will tell you how many variable elements in the xsl namespace are there
even if the stylesheet uses a different prefix or no prefix for xsl
elements.

count(*[name()='xsl:variable']) might tell you how many xsl:variable
elements are there, but if the user used a different prefix they
probably won't be counted and even if the user used teh prefix "xsl"
they may not be counted as the XML parser is allowed to ignore the
prefixes used and substitite its own normalised prefix (although most do
not do this).

David




-- 
http://www.dcarlisle.demon.co.uk/matthew

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. 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
________________________________________________________________________

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread