Re: [xsl] Passing sort criteria as a paramter

Subject: Re: [xsl] Passing sort criteria as a paramter
From: "Gene LaCava" <e.f.lacava@xxxxxxxxxxx>
Date: Thu, 24 Jan 2002 19:25:44 -0500
Wendell:

Can you tell me how to post a question to this list server ? I have tried 3
times already with no luck...

Thank Yoou
----- Original Message -----
From: "Wendell Piez" <wapiez@xxxxxxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, January 24, 2002 4:56 PM
Subject: Re: [xsl] Passing sort criteria as a paramter


> David,
>
> I can't claim to be Jeni (well I could but no one would be fooled), but
>
> At 04:33 PM 1/24/02, you wrote:
> >I have been passing the sort element name into my xsl by way of a
> >parameter.  I then do this:
> >
> ><xsl:sort select="*[local-name() = $sortby"]">
> >
> >and this works great.  Now, I want to qualify the element name, such
> >that the select attribute would read
> >
> >select="Amount[../IsCredit=1]"
> >
> >if I wanted to just park the select attribute at one element.
> >
> >Now, how can I pass the above predicated element name into the
> >stylesheet?
>
> If you just mean to apply the predicate to a dynamic element name, you
> would use the same idiom:
>
> select="*[local-name()=$sortby][../IsCredit=1]"
>
> This translates into English as
>
> "sort by the values of the element children whose name equals $sortby and
> whose parents have a child 'IsCredit' element whose value equals 1"
>
> But if you need to pass the whole thing in, as in passing in the string
> "Amount[../IsCredit=1]", you're stuck, unless the pattern is regular
enough
> to break it down into pieces and use the same value-testing trick
> (sometimes testing the value of the name) on each piece separately. But
> your example leads me to think that's unlikely to cover your case.
>
> Unfortunately you can't pass an XPath expression in as a parameter and
> expect it to be evaluated: if it's a string, it's a string, not an XPath
> expression. If the name testing workaround isn't enough, some processors
> have extension functions for this; or if you're really stuck an expression
> can be parameterized by having a stylesheet generate your stylesheet.
>
> Enjoy,
> Wendell
>
>
> ======================================================================
> Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
> Mulberry Technologies, Inc.                http://www.mulberrytech.com
> 17 West Jefferson Street                    Direct Phone: 301/315-9635
> Suite 207                                          Phone: 301/315-9631
> Rockville, MD  20850                                 Fax: 301/315-8285
> ----------------------------------------------------------------------
>    Mulberry Technologies: A Consultancy Specializing in SGML and XML
> ======================================================================
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>


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


Current Thread