RE: [xsl] Grouping problem

Subject: RE: [xsl] Grouping problem
From: "Ruggier, Mario" <Mario.Ruggier@xxxxxxxxxxxxxxxx>
Date: Tue, 23 Jul 2002 17:10:27 +0200
Hi Jeni,

OK. For the $displayProperty it is workable. 
For the $offset it is rather complicated. 
The offset is determined by the structure of an LDAP
string, in the XML as an attribute value in one of the
element types. Thus, the string could be:
"CN=one,OU=two,OU=three,DC=four,DC=five"
The offset is determined by the number of "DC" pieces
in the string (in this case 2, and which means I want 
to ignore the bottom 2 levels of the array described 
previously). 

I calculate this via a rather horribly complicated string 
split template, and then take a count of the number of 
token elements returned. Is there a simpler way of doing 
this, and that can be called from with key/@use ?

Thanks, mario



> -----Original Message-----
> From: Jeni Tennison [mailto:jeni@xxxxxxxxxxxxxxxx]
> Sent: Tuesday, July 23, 2002 4:37 PM
> To: Ruggier, Mario
> Cc: xsl-list@xxxxxxxxxxxxxxxxxxxxxx; joerg.heinicke@xxxxxx
> Subject: Re: [xsl] 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