Subject: RE: Filtering based on "list" of values
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 9 Jan 2006 10:52:43 -0000
|
Pass in the comma separated list of locations as a stylesheet parameter
$locs.
Create a global variable
<xsl:variable name="locSequence" select="tokenize($locs, ',\s+')"
as="xs:string*"/>
then select required locations as:
select="store[@location = $locSequence]"
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: Chris Ward [mailto:cward@xxxxxxxxxxxxxxxxxxx]
> Sent: 09 January 2006 10:39
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Filtering based on "list" of values
>
>
> Hi all,
>
> Sorry if this is a commonly asked question - I've looked in
> the archive but the best match was my first posting back in 2003!
> http://www.biglist.com/lists/xsl-list/archives/200311/msg00700.html
>
> Anyway, I've returned to the world of XSLT now and I face the same
> problem.
>
>
> Imagine some XML such as...
>
> <root>
> <store location="london">
>
> <...>report data here</...>
>
> </store>
> <store location="paris">
>
> <...>report data here</...>
>
> </store>
> <store location="madrid">
>
> <...>report her data here</...>
>
> </store>
> <store location="new york">
>
> <...>report data here</...>
>
> </store>
> <store location="tokyo">
>
> <...>report data here</...>
>
> </store>
> </root>
>
>
> I've got a webpage/form that allows the user to enter a list
> of locations they want included in a report (I have the report
> XSLT already).
>
> I guess I am thinking about passing something into the XSLT (via a
> param) along the lines of
>
> "london,new york"
>
> or
>
> "tokyo, paris, london"
>
>
> I happen to be using dom4j/Java. I do use XMLFilterImpl in
> my code for filtering other XML stuff, but I wondered if I can do
> the filtering inside the XSLT. I am now running the latest version
> of Saxon therefore XSLT 2.0. I'm new to XSLT 2.0 and not sure if
> it's possible using functions or something.
>
> It's STILL not clear to me where to do this sort of list-based
> filtering.
>
>
> Many thanks for any suggestions.
>
> Chris Ward
|