Re: [xsl] keys and idrefs

Subject: Re: [xsl] keys and idrefs
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 9 Oct 2001 12:13:54 +0100
   <xsl:for-each 
  	 select="//process ">
                  <xsl:if test="contains(@control, $thisDoc)">
                <a href="{@id}.html"> <xsl:value-of select="name"/>
  </a>&#160;

  returns 5 process element whose control attribute contains the id value of
  the current node.

it would probably be better to do //process[.... rather than select all
processes then use an xsl:if, but wendel's point was that in th ecode
you posted.

> No, its an idrefs (plural) not an idref, 
your problem is that xslt/xpath care 'nowt about such attribute
declarations. If XPath knew that attribute was a list type you'd
probably be in better shape.

If you are prepared to limit yourself to a fixed length then you could
use keys (but you'd have to experiment to see if it was really any
better than the simple use of // as you show above)

but to find all process elements that contain XAG in their control
attribute you could do

select="key('control', 'XAG')"

so long as you key was defined something like


<xsl:key match="process" use="@control"/>
<xsl:key match="process" use="substring-before(@control,' ')"/>
<xsl:key match="process" use="substring-after(@control,' ')"/>
<xsl:key match="process" use="substring-before(substring-after(@control,' '),' ')"/>
....


David

_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread