xsl-list
[Top] [All Lists]

Re: XPath 1.0 id() function

2005-08-23 07:20:03

Ah yes, keys!  Keys are good!!

Thanks

Nadia


                                                                                
                                                
                      David Carlisle                                            
                                                
                      <davidc(_at_)nag(_dot_)co(_dot_)u         To:      
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com                                
         
                      k>                       cc:                              
                                                
                                               Subject: Re: [xsl] XPath 1.0 
id() function                                       
                      2005-08-23 10:11                                          
                                                
                      Please respond                                            
                                                
                      to xsl-list                                               
                                                
                                                                                
                                                
                                                                                
                                                






<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="//*[(_at_)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="//*[(_at_)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="*[(_at_)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
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--






--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>