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

Re: Converting attribute value qnames to URIs

Subject: Re: Converting attribute value qnames to URIs
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 25 Mar 2004 17:50:42 GMT
ancestor or self namespace
		<!-- URI that the prefix maps to: first ancestor with a
			  namespace node whose name() = the namespace prefix. -->
		<xsl:variable name="nsNode">
		  <xsl:value-of select=
           "ancestor-or-self::*[1]/namespace::*[name() = $nsprefix]"/>

The quoted code doesn't do what the comment says, it doesn't select the
first ancestor with a namespace node, it selects the first ancestor or
self (always) and then selects the namespace node of that.
This is actually OK at present as namespace prefixes can't be
undeclared so if any ancestor has such a node, the nearest ancestor will
have such a node. (This becomes false in xml namespaces 1.1)
as the current node is an attribute the -self bit isn't needed either
as the attribute will never match * so the above is
parent::*/namespace::*[name() = $nsprefix]


	<xsl:variable name="nsNode">
		  <xsl:value-of select=
           "ancestor-or-self::*[1]/namespace::*[name() = $nsprefix]"/>
		</xsl:variable>

this makes a result tree fragment, if instead you went

	<xsl:variable name="nsNode"select=
           "ancestor-or-self::*[1]/namespace::*[name() = $nsprefix]"/>
 
(or parent:*) then it would probably be a bit more efficient and you
could simplify your test

  <xsl:when test="$nsNode=''">

to

  <xsl:when test="$nsNode">

as you could just directly test whether the node exists rather than test
if its string value is empty.




 <!-- Add attribute to result tree, substituting URI for prefix. -->
	 <xsl:attribute name="{name()}">
		<xsl:value-of select="$nsURI"/>
		<xsl:value-of select="substring-after(.,':')"/>
	 </xsl:attribute>


don't you want to put in some separator between teh uri and local name,
so the transformation is reversible? eg James clark's
{uri}name
notation?


David

________________________________________________________________________
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
________________________________________________________________________

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.