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

Re: Grouping problem

Subject: Re: Grouping problem
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 23 Jul 2002 15:37:01 +0100
Re:  Grouping problem
Hi Mario,

> However I encounter another problem. To apply this
> solution I would need to dynamically set up the xsl:key.
> I.e. would need to specify something like:
>
> <xsl:key name="PropArrays" 
>          match="PROPERTY.ARRAY[@NAME=$displayProperty]" 
>          use="VALUE.ARRAY/VALUE[last()-$offset]" />
>
> This presents in fact two problems:
> 1. msxml3 (imposed) complains that 
>    "Variables may not be used within this expression"
>    (but Saxon 6.0.2 does not, and behaves as expected
>     at least for the first variable).
> 2. The $offset variable would need to be set from
>    something in the xml data. How can I read some XML
>    data, set the variable and use it to set up the key?

Saxon 6.0.2 had a bug, then (update to 6.5.2). You can't use variables
in the match or use attributes of xsl:key, so you need to find another
way of doing this.

You say that $offset is calculated based on the XML data. If so, then
you can calculate it inside the use attribute rather than in a
separate variable (though it might get messy!). I don't know how
you're setting it, but say it was the 'offset' attribute on the
document element; then you could use:

  use="VALUE.ARRAY/VALUE[last() - /*/@offset]"

Then, rather than using the $displayProperty variable in the match
attribute, make the key match all PROPERTY.ARRAY elements but when you
*use* the key, add a predicate that excludes those PROPERTY.ARRAY
elements whose @NAME doesn't equal the $displayProperty. For example,
use:

  <xsl:apply-templates
    select="PROPERTY.ARRAY[@SIZE = 1 and
                           @NAME = $displayProperty]" />

and then, in the template, set the parameter with:

  <xsl:param name="others"
    select="key('PropArrays', VALUE.ARRAY/VALUE[last() - $offset])
              [@NAME = $displayProperty]" />
                           
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.