xsl-list
[Top] [All Lists]

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

2013-12-04 11:33:30
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?




--~------------------------------------------------------------------
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>