[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: keys and idrefs - XSLT2 request?

Subject: Re: keys and idrefs - XSLT2 request?
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 9 Oct 2001 16:33:48 +0100
xslt2 functions return value
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.