[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

the useless name() function (was Re: Using the not function)

Subject: the useless name() function (was Re: Using the not function)
From: "Mark D. Anderson" <mda@xxxxxxxxxxxxxx>
Date: Mon, 17 Jan 2000 09:43:53 -0800
useless name
--On Monday, January 17, 2000 11:23 AM +0000 David Carlisle <davidc@xxxxxxxxx> wrote:
> No, name() gives the literal prefixed name from the source.

and Michael Kay agrees:
>Generally speaking, it's best to avoid testing the result of the name()
>function, because two XML documents that are equivalent except for their
>choice of namespace prefixes will give different answers. Using
>"not(self::element3)" is safer.

Damn, I wasn't aware of this.


- if you have an expanded name which is a literal, and you want to
match only on that name in that namespace, then use self::
   xmlns:myprefix = urn:some-uri
   [self::myprefix:el] <!-- if desired node has a namespace which myprefix expands to -->
   [self::el] <!-- if desired node has no namespace -->

- if you want to match any element which has a particular local name,
regardless of namespace, use local-name():
   [local-name() = 'el']

- if you want to match a local name against a variable, that is easy:
   <xsl:variable name="local_elname" select="'el'"/>
   [local-name() = $local_elname]

- if you want to match an expanded name against a variable, that is hard:
   <xsl:variable name="local_elname" select="'el'"/>
   <xsl:variable name="ns_el" select="'urn:some-uri'"/>
   [local-name() = $local_elname and namespace-uri() = $ns_el]

- if you want to match qnames, that is easy but not what you want:
   <xsl:variable name="q_elname" select="'myprefix:el'"/>
   [name() = $q_elname]

Did i get that right?


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

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.