[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)
--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. So: - 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? -mda XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|