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

RE: Grouping problem

Subject: RE: Grouping problem
From: "Ruggier, Mario" <Mario.Ruggier@xxxxxxxxxxxxxxxx>
Date: Tue, 23 Jul 2002 16:11:47 +0200
xsl key size
Hello Jeni,

yes it does work, thank you. (Plus, it is 
about twice+ as fast as another less-general 
solution not based on xsl:key).

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?

mario




> -----Original Message-----
> From: Jeni Tennison [mailto:jeni@xxxxxxxxxxxxxxxx]
> Sent: Monday, July 22, 2002 10:50 PM
> To: Ruggier, Mario
> Cc: xsl-list@xxxxxxxxxxxxxxxxxxxxxx; joerg.heinicke@xxxxxx
> Subject: Re:  Grouping problem
> 
> 
> Hello Mario,
> 
> > Here's the more complicated version: I would like to convert the
> > list of <obj> elements (see INPUT below) to the hierarchical XML
> > (see OUTPUT below).
> 
> The following works by first applying templates to only those p.array
> elements whose size attribute has the value 1. The template for
> p.array elements has a $others parameter that holds the "other"
> p.array elements that share the same values for their v elements. It
> creates an 'obj' element for the particular level of the p.array
> element that you're applying template to, then applies templates to
> the next level of p.array elements, passing in the next set of
> "others", those that match the next layer of v elements:
> 
> <xsl:key name="arrays" match="p.array" use="v[last()]"/>
> 
> <xsl:template match="r">
>   <xsl:copy>
>     <xsl:apply-templates select="obj/p.array[@size = 1]" />
>   </xsl:copy>
> </xsl:template>
> 
> <xsl:template match="p.array">
>   <xsl:param name="others" select="key('arrays', v[last()])" />
>   <obj name="{v[1]}">
>     <xsl:for-each select="$others[@size = current()/@size + 1]">
>       <xsl:apply-templates select=".">
>         <xsl:with-param name="others"
>           select="$others[v[last() - current()/@size + 1] =
>                           current()/v[1]]" />
>       </xsl:apply-templates>
>     </xsl:for-each>
>   </obj>
> </xsl:template>
> 
> 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.