This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Problem in define Node-set from variable number of params
- To: "Jarno Elovirta" <jarno at elovirta dot com>, <xsl-list at lists dot mulberrytech dot com>
- Subject: Re: [xsl] Problem in define Node-set from variable number of params
- From: "Yang" <sfyang at unisvr dot net dot tw>
- Date: Thu, 29 Mar 2001 17:21:51 +0800
- References: <IKEEJDFDEJLFMMIPCGFPEEICCOAA.jarno@elovirta.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi, Jarno,
I just did one test to figure out why the case of
both (string($office) and string($month) are true
failed. I deliberately removed the single case condition out of the
"condition2" variable,
then I got good solutions. Hopefully this finding will provide you some
information to perfect the
phrase of variable "condition2".
<xsl:variable name="condition2" select="key('prodCode',
$thisPP)[substring(@SalesOrderNo, 1, 4) = $office][substring(@SalesOrderNo,
10, 2) = $month][string($office) and string($month)] |
key('prodCode',$thisPP)[not(string($office) and string($month))]" />
Sun-fu Yang
sfyang@unisvr.net.tw
----- Original Message -----
From: "Jarno Elovirta" <jarno@elovirta.com>
To: <sfyang@unisvr.net.tw>
Sent: Thursday, March 29, 2001 1:54 PM
Subject: RE: [xsl] Problem in define Node-set from variable number of params
> Hip hei!
>
> > First I use the the variable "condition" which is from a predefined
> > **select** attribute
> > and it works fine when applying it to named template of productset.
> >
> > But when I use the variable of "condition2" generated from various
params
> > test, it fails.
>
> Unfortenately you can't do this, because XPath expressions cannot be
> generated run-time. If you can and want to, use the SAXON extension
function
> saxon:evaluate(), i.e.
>
> <xsl:with-param name="datas" select="saxon:evaluate($condition2)" />
>
> and that should work. A pure XSLT solution might be something like
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:output method="xml" />
>
> <xsl:template match="/">
> <xsl:variable name="condition"
> select="key('prodCode',$thisPP)[substring(@SalesOrderNo,10,2)=$month]"/>
> <xsl:variable name="condition2" select="key('prodCode',
> $thisPP)[substring(@SalesOrderNo, 1, 4) =
$office][substring(@SalesOrderNo,
> 10, 2) = $month][string($office) and string($month)] |
> key('prodCode', $thisPP)[substring(@SalesOrderNo, 1, 4) =
> $office][string($office)] |
> key('prodCode', $thisPP)[substring(@SalesOrderNo, 10, 2) =
> $month][string($month)] |
> key('prodCode',$thisPP)[not(string($office) and string($month))]" />
>
> <xsl:call-template name="productset">
> <xsl:with-param name="datas" select="$condition"/><!-- this one works
> with predefined conditions.-->
> <xsl:with-param name="datas" select="$condition2"/><!-- this created
> condition won't work.-->
> </xsl:call-template>
> </xsl:template>
>
> </xsl:stylesheet>
>
> I couldn't test this as you didn't provide a source document, but it just
> might work - note that the <xsl:otherwise> cannot be handled with XPath
> predicates, and it's been replaced with <xsl:when
test="not(string($office)
> and string($month))">.
>
> Hope this works and helps.
>
> Jarno
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list