RE: [xsl] dynamic sorting

Subject: RE: [xsl] dynamic sorting
From: "Peter Billen" <peter@xxxxxxxxxxx>
Date: Fri, 6 Feb 2004 00:22:50 +0100
Thanks for pointing it out. I have one more question:

But how do I combine test="self::book:title" with a variable $sort, which
will contain in this situation "title". I can't test it right now, but
test="self::book:$sort" will probably not work, although I'm not sure.

Thanks for your time,


-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of G. Ken Holman
Sent: donderdag 5 februari 2004 18:36
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] dynamic sorting

At 2004-02-05 17:56 +0100, Peter Billen wrote:
>Cool, thanks a lot. I didn't thought about the name()-function.
>So if I understand name() well, both expressions should give the same
>1. select="count(someNode)"
>2. select="count(*[name() = someNode])"

I'm assuming you mistyped and you meant to say "$someVar" instead of 
"someNode" because it is quite nonsensical as you've typed (2) which would 
read in English as "return the count of all child elements whose name is 
equal to the concatenated value of all descendent text nodes of any of that 
node's element children named 'someNode'" ... which I'm guessing isn't what 
you wanted.

>What do you mean with "namespace-safe"? Can you give a situation in which
>the given solution would not work?

The given solution will not (always) work if your element type names have a 
non-null component for the namespace URI.  This is because the name() 
function returns the name as used in the XML instance, complete with the 
prefix used in the XML instance.

Prefixes are arbitrary and may not match the prefixes you've chosen to use 
in your stylesheet.

Therefore the name() function is only safe for exposition, not for node 

For example, a beginner's attempt to say "am I a particular element" might


when, indeed, the namespace-safe way to say that is:


because the instance itself might very well be a book title in the correct 
book namespace by using a different namespace prefix like:


I hope this helps.

.......................... Ken

p.s. if you are based near northern Germany we are running a 
publicly-subscribed XSL course in Bremen in May.

Public courses: sign up for one or both soon to reserve your seat!
Each week:  Monday-Wednesday: XSLT/XPath;  Thursday-Friday: XSL-FO
Washington, DC: 2004-03-15           San Francisco, CA: 2004-03-22
Hong Kong, China: 2004-05-17           Bremen, Germany: 2004-05-24
World-wide on-site corporate, government & user group XML training

G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness

 XSL-List info and archive:

 XSL-List info and archive:

Current Thread