[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XPath 1.0 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 ________________________________________________________________________
|
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
|