[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
At 2004-02-05 17:56 +0100, Peter Billen wrote:
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.
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 checking.
For example, a beginner's attempt to say "am I a particular element" might be:
test="name(.)=book:title"
when, indeed, the namespace-safe way to say that is:
test="self::book:title"
because the instance itself might very well be a book title in the correct book namespace by using a different namespace prefix like:
<b:title>
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.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
RE: [xsl] dynamic sorting
Subject: RE: [xsl] dynamic sorting From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Thu, 05 Feb 2004 12:35:48 -0500 |
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 result?
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 checking.
For example, a beginner's attempt to say "am I a particular element" might be:
test="name(.)=book:title"
when, indeed, the namespace-safe way to say that is:
test="self::book:title"
because the instance itself might very well be a book title in the correct book namespace by using a different namespace prefix like:
<b:title>
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. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] dynamic sorting, David Carlisle | Thread | RE: [xsl] dynamic sorting, Peter Billen |
Re: [xsl] dynamic sorting, David Carlisle | Date | RE: [xsl] template matching, Wendell Piez |
Month |