Subject: Re: [xsl] Grouping problem From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Tue, 23 Jul 2002 15:37:01 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Grouping problem, Ruggier, Mario | Thread | RE: [xsl] Grouping problem, Ruggier, Mario |
Re: [xsl] Re: file manipulation wit, Jeni Tennison | Date | RE: [xsl] Grouping problem, Ruggier, Mario |
Month |