This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Inconsistent solution from a conditional data-set by group methods
- To: E200 ·¨¥Ó¨j <SFYang at unisvr dot net dot tw>
- Subject: Re: [xsl] Inconsistent solution from a conditional data-set by group methods
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Fri, 20 Apr 2001 12:35:36 +0100
- CC: xsl-list at lists dot mulberrytech dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <E594C67B5109A441A9C8770BC2AD2373079EBE@uniexbe01.xo.unisvr>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Sun-fu,
> Thanks for your prompt attention on my question,
> I should like to use your suggestion, which is
>
> /docs/line[substring(salesno,10,2)='03']
> [salesno = key('Listing2',name)[1]/salesno]
>
> however I am reluctant to use it in general , because
> Listing2 key function has to be used with a hard-wired predicate for
> the month =3,
> <xsl:key name="Listing2" match="line[substring(salesno,10,2)='03']"
> use="name"/>
Ahh, good point.
> I hope I can use Listing2 key function with a global param
> something like as
> <xsl:param name="month" select="'03'"/>
> <xsl:key name="Listing2" match="line[substring(saleno,10,2)=$month"
> use="name"/>
> (which I know I can not do it)
Yup.
> Could you offer an alternative to what I am trying to achieve to
> obtain a list of name for any given month without writing down list
> of Listing key function for various month specification??
Sure. Define your key in the general way, to index all the lines:
<xsl:key name="Listings" match="line" use="name" />
But then, when you're retrieving the nodes from the key, rather than
getting just the first one of those nodes, filter them first to only
include the ones you're interested in. So:
/docs/line[substring(salesno, 10, 2) = $month]
[salesno = key('Listings', name)
[substring(salesno, 10, 2) = $month][1]
/salesno]
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list