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

Re: using keys on variables

Subject: Re: using keys on variables
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 8 Oct 2016 09:29:20 -0000
Re:  using keys on variables
On 08.10.2016 11:21, Graydon graydon@xxxxxxxxx wrote:
In XSLT 2.0 and subsequent,

key('keyname',object,$variable)

is acceptable but only if the $variable is a document node.

That is not true, you can search a subtree of a document by passing in an element in that document. The only requirement is that the root of the tree containing the node supplied in the third argument is a document node.




So I have found myself going

<xsl:variable name="temp">
    <xsl:sequence select="$preExisting"/>
</xsl:variable>

So I could use a key on a variable typed as an element.  (In the
specific case, to pull a subset of an already constructed sequence of
middling-complicated mapping elements; A maps to B but there's metadata
about A, B, and the mapping in there, so generating it again isn't
attractive.)

Is there a better way to approach the requirement that the variable be a
document node in order to use the key?

I also like using variables typed as element() or element()* but if I want to use keys then I think the right approach is to make sure you start with a document node as the root of the elements.


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.