This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: keys and idrefs - XSLT2 request?


Hi Dave,

> xf:idref(string* $srcval) => node*
>
> 11.7.2.3 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
IDs:

<xsl:key name="control"
         match="process"
         use="id(@control)/@id"/>

I think that would work.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]