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

xsl:key, predicates and documents.

Subject: xsl:key, predicates and documents.
From: Nic Gibson <nicg@xxxxxxxxxx>
Date: Fri, 14 May 2010 13:28:18 +0000
 xsl:key
Afternoon

I've found myself confused by something I thought that I understood so I'm
hoping for some enlightenment. We have a fairly massive document that
is used as a lookup when processing other documents.

Right now, we have the big document used as the primary input to 
stylesheet and the document actually being processed is loaded via
document(). 

The big document can be partioned on an attribute. The lookups done
in this document depend on the attribute value in both the input and
the lookup. That is, if the @PER attribute is 'n' then we will be
doing lookups based on the @HW attribute and if 'y' on the @SUR attribute.

So, I created keys that look like this:

    <xsl:key name="term-key" select="e[@PER='n']" use="@HW"/>
    <xsl:key name="person-key" select="e[@PER='y']" use="@SUR"/>

    
Our root template matches the other document and processes it so:

<xsl:param name="in-file"/>
<xsl:variable name="in-doc" select="document($infile)"/>
<xsl:template match="/">
    <output>
        <xsl:apply-templates select="$in-doc/xData/eData"/>
    </output>
</xsl:template>

<xsl:template match="eData[@PERS='n']">
    <xsl:variable name="exact" select="key('term-key', @HW)"/>
    ...

</xsl:template>

We know that there are matches yet this doesn't work unless
we remove the predicate from the key definition. Are predicates
usable in key definitions?

On a related noted, is there any way to reverse this so that
the key data is loaded from document()?

cheers

nic

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.