W3C home > Mailing lists > Public > xsl-editors@w3.org > January to March 2002

RE: [xsl] Passing sort criteria as a paramter

From: Kay, Michael <Michael.Kay@softwareag.com>
Date: Fri, 25 Jan 2002 22:29:48 +0100
Message-ID: <DFF2AC9E3583D511A21F0008C7E6210602679BBE@daemsg02.software-ag.de>
To: "'david@codenoevil.com'" <david@codenoevil.com>, xsl-editors@w3.org
Thanks for sending this. The question of whether to provide dynamic
evaluation of XPath expressions (for example, a function like
saxon:evaluate() and xalan:evaluate() is under active discussion in both the
XSL and XPath groups at the moment. At present, I'm not optimistic that it
will make it. We do understand the requirement, but it causes considerable
problems for implementors of XSLT compilers, and there are also some tricky
technical problems in defining a suitable specification - for example, how
should namespace prefixes in the dynamic XPath expression be resolved?

Mike Kay

> -----Original Message-----
> From: David B. Bitton [mailto:david@codenoevil.com]
> Sent: 25 January 2002 15:30
> To: xsl-editors@w3.org
> Subject: FW: [xsl] Passing sort criteria as a paramter
> 
> 
> As requested by Jeni Tennison, I am forwarding you my post from the
> xsl-list.  I am in need of an evaluate function so I can pass 
> an element
> name and predicate into a stylesheet as a param.
> 
> Basically, I pass the element that I used to sort by as a param, so my
> xsl:sort's select attribute looks like this:
> 
> select="*[local-name() = $sortby]"
> 
> But I have an instance where I need this:
> 
> select="Amount[../IsCredit=1]"
> 
> Now I understand that I could do
> 
> Select="*[local-name() = $sortby][../IsCredit=1]"
> 
> But that is not applicable for any other element other than 
> Amount (and
> only a credit amount).  This is all because we display debits and
> credits in different columns, and we allow the user to sort be either
> column. Unfortunately the only way I have to differentiate a 
> credit from
> a debit is a sibling flag, IsCredit, which can be either 1 or 0, which
> as you can see, would be used as a predicate against the 
> Amount element.
> 
> Hopefully this will be considered for the next version of XPath.
> Thanks.
> 
> -----Original Message-----
> From: Jeni Tennison [mailto:jeni@jenitennison.com] 
> Sent: Friday, January 25, 2002 5:25 AM
> To: David B. Bitton
> Cc: xsl-list@lists.mulberrytech.com
> Subject: Re: [xsl] Passing sort criteria as a paramter
> 
> 
> Hi David,
> 
> > You seemed to get this msg to the list. Wendell, thanks. I didn't 
> > think of that. BTW, can I use an xsl:attribute tag for another xsl 
> > element?
> 
> Since Wendell nabbed the other question, I'll answer this one ;)
> 
> I take it you're asking whether you can use xsl:attribute to 
> dynamically
> create an attribute on an XSLT element. So you're asking if 
> you can do:
> 
>   <xsl:sort>
>     <xsl:attribute name="select">
>       <xsl:value-of select="$sortby" />
>     </xsl:attribute>
>   </xsl:sort>
> 
> As a way of getting around the fact that $sortby is a string and you
> want to interpret it as an XPath expression.
> 
> The answer is no, you can't. You can only use xsl:attribute to add
> attributes onto result elements (whether created with literal result
> elements or with xsl:element).
> 
> Of course if the 'xsl:sort' were a literal result element, 
> then it would
> be fine. So if you were generating a stylesheet from your stylesheet,
> and set up a namespace alias for the XSLT namespace so that 'oxsl' was
> the prefix used for the XSLT elements you're generating, you can do:
> 
>   <oxsl:sort>
>     <xsl:attribute name="select">
>       <xsl:value-of select="$sortby" />
>     </xsl:attribute>
>   </oxsl:sort>
> 
> and it will generate:
> 
>   <oxsl:sort select="Amount[../IsCredit = 1]" />
> 
> By the way, I suggest that you forward your use case on to
> xsl-editors@w3.org - hopefully if they receive enough use cases then
> they will add an evaluate() function to XSLT 2.0, so that you 
> could just
> do:
> 
>   <xsl:sort select="evaluate($sortby)" />
> 
> Cheers,
> 
> Jeni
> 
> ---
> Jeni Tennison
> http://www.jenitennison.com/
> 
> 
Received on Friday, 25 January 2002 16:30:34 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 December 2009 10:59:52 GMT