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

Re: XPath 1.0 id() function

Subject: Re: XPath 1.0 id() function
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 23 Aug 2005 15:11:04 +0100
xpath id function
> <xsl:variable name="xlabel">
>       <xsl:value-of select="id($target)/@xreflabel"/>
> </xsl:variable>
> 

don't use a variable with content here (even when id() works) use a
select attribute:

<xsl:variable name="xlabel"select="id($target)/@xreflabel"/>

> 
> I have to resort to this:
> <xsl:variable name="xlabel">
>       <xsl:for-each select="//*[@id = $idd]">
>             <xsl:value-of select="@xreflabel"/>
>       </xsl:for-each>
> </xsl:variable>


Again you don't want to use a variable with content, or a for-each:


<xsl:variable name="xlabel" select="//*[@id = $idd]"/>

However if you are accessing that more than once it's more efficient to
use keys which are documented as being for use in exactly this case
(when id() is not available)

<xsl:key name="id" match="*[@id]" use="@id"/>
...
<xsl:variable name="xlabel" select="key('id',$idd)"/>

> the id() function only works when the DTD is
> declared in the XML Document.  Does anyone know if this is true?

That's what it says in the spec, how else would XSLT know which
attributes are of type ID (XML attatches no special significance to
attributes with name id).

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. 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.