This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Passing sort criteria as a paramter
- From: "Gene LaCava" <e dot f dot lacava at verizon dot net>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Thu, 24 Jan 2002 19:25:44 -0500
- Subject: Re: [xsl] Passing sort criteria as a paramter
- References: <5.1.0.14.0.20020124164223.02c98ec0@earthlink.net>
- Reply-to: xsl-list at lists dot mulberrytech dot com
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@mulberrytech.com>
To: <xsl-list@lists.mulberrytech.com>
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@mulberrytech.com
> 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