Re: [xsl] keys and idrefs - XSLT2 request?

Subject: Re: [xsl] keys and idrefs - XSLT2 request?
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 9 Oct 2001 16:33:48 +0100
Hi Dave,

> xf:idref(string* $srcval) => node*
> Semantics
> Returns the sequence of element nodes with an IDREF value matching the value
> of one of the items in the sequence argument or an IDREFS value containing
> an IDREF matching the value of one of the items in the sequence argument. If
> the value of $srcval is a single string, it behaves as though a sequence of
> length one of strings was supplied. This function allows reverse navigation
> from IDs to IDREFs.
> Do you read this as working in this case? The last sentance appears
> to imply singular?

Well, yes, but the first sentence definitely implies plural. Omitting
the XPath 2.0-isms:

  "Returns the... element nodes with... an IDREFS value containing an
   IDREF matching the value of... the... argument."

> Guessing that the sequence argument is the param to the function,
> this would appear to get all IDREF type 'pointers' to this id,

Yes, all the element nodes that have an IDREF or IDREFS attribute that
contains the value of the ID that you pass as the argument.

> I'm unsure if it would resolve
> <xf:for-each select = xf:idref ($this-node-id)>
> where the 'pointers' were buried in the midst of an IDREFS type string.
> <a idrefs=" x y z"/>
> <b idrefs=" m n z"/>
> <z id="z"/>
> <template match="z"
> <xf:for-each select = xf:idref (@id)>
> </xf:for-each>
> Do you think this would find both a and b element nodes? (assuming
> proper dtd definitions of id and idrefs)

I'm pretty sure that's the intention of the function. Of course, the
F&O document doesn't actually tell us anything about what the XPath
2.0 would actually look like, and there aren't any implementations and
so on.

Another thing I just thought of was perhaps you could use the id()
function when setting the key value. The id() function can take a
space-separated list of IDs and gets you all the elements with those
IDs. Then you can go from those elements to the IDs themselves, to
index the element holding the IDREFS attribute by the values of the

<xsl:key name="control"

I think that would work.



Jeni Tennison

 XSL-List info and archive:

Current Thread