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

Re: Need to use document() in key definition

Subject: Re: Need to use document() in key definition
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Wed, 4 Dec 2013 17:49:34 +0000
Re:  Need to use document() in key definition
Keys aren't coupled to a specific document. Just use

> <xsl:key name="inMap" match="a" use="@href"/>

Don't worry about the fact that this potentially indexes every document on the
a/@href values. The index will only be built if it is actually used.

Michael Kay
Saxonica

On 4 Dec 2013, at 17:33, dvint@xxxxxxxxx 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:
>
> <xsl:stylesheet version='1.0'
> xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
> <xsl:param name="map-path"/>
> <xsl:key name="inMap" match="document($map-path)//a" use="@href"/>
>
> But I get an error saying that document() is not allowed at the head of a
> pattern.
>
> So, I thought I can get rid of the document() function by using a variable:
>
> <xsl:variable name="map-doc" select="document($map-path)"/>
> <xsl:key name="inMap" match="$map-doc//a" use="@href"/>
>
> this comes back with "variable reference is not allowed in xslt pattern".
>
> 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?

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.