xsl-list
[Top] [All Lists]

Re: [xsl] Need to use document() in key definition

2013-12-04 11:51:19
On Wed, December 4, 2013 5:33 pm, dvint(_at_)dvint(_dot_)com wrote:
I'm trying to build a look up table by using keys but I have 2 documents
that I'm working with. The primary document that the stylesheet is
processing has the values that I want to verify are in the second
document. This second document is passed in as a parameter to the
stylesheet. So I was trying to do this:
...
I also tried processing this second document with a template of its own,
so I could use the <xsl:key> element without passing the document
information in. That fails because <xsl:key> is a top level element and
can't be used in a template.

I can't change the selection of which document to process, is there an
option here that I missed?

Keys 'just work' for every document.

To lookup something in the secondary document, use the document-node of
the secondary document as the third, 'selected subtree', argument to
'key()' [1]:

  key($key-name     as xs:string,
      $key-value    as xs:anyAtomicType*,
      $top          as node()) as node()*



Tony Graham                                   tgraham(_at_)mentea(_dot_)net
Consultant                                 http://www.mentea.net
Mentea       13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
 --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
    XML, XSL-FO and XSLT consulting, training and programming
       Chair, Print and Page Layout Community Group @ W3C

[1] http://www.w3.org/TR/xslt20/#keys


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>