[xsl] IDREFS and key()

Subject: [xsl] IDREFS and key()
From: Dan Vint <dvint@xxxxxxxxx>
Date: Mon, 28 Nov 2005 18:30:31 -0800
I have an element that contains an IDREFS attribute like the following:

<Attribute id="aAtt" references="foo bar"><Name>Att</Name></Attribute>

The references attribute is defined as an IDREFS and the schema and document that this lives in are all valid.

I want to use the references attribute in a key definition so I can reverse the relationship and in this case from the element identified as foo or bar, indicate that the Attribute element, named Att links to it.

My key definition is this:

<xsl:key name="attribute-references" match="Attribute" use="@references"/>

I process this with a for-each as follows:

<xsl:for-each select="key('attribute-references', $parentElement)>

$parentElement is set to the id value that is in the references attribute.

In this example when there are multiple values in the @references, nothing is found, but if I remove in this case the second value, I produce results. It seems like the key() is trying to match my value of 'foo' against the complete string of 'foo bar', rather than doing a "contains" sort of match. Is this what is expected? When I provide the full 'foo bar' to the for-each I now match this Attribute definition.

How do I get the key() function to break up the IDREFS and process the individual values? I tried using id() in the key definition but that didn't help.

..dan
---------------------------------------------------------------------------
Danny Vint

Specializing in Panoramic Images of California and the West
http://www.dvint.com

voice: 510-522-4703

When H.H. Bennett was asked why he preferred to be out
shooting landscapes rather than spending time in his portrait studio:

"It is easier to pose nature and less trouble to please."

http://www.portalwisconsin.org/bennett_feature.cfm

Current Thread