Subject: Re: [xsl] Problem in define Node-set from variable number of params From: "Yang" <sfyang@xxxxxxxxxxxxx> Date: Thu, 29 Mar 2001 16:56:36 +0800 |
Hello, Jarno, Thanks for your reply. I have made a series of test runs with your suggestion; the results are as followings, 1. condition2 works for single param case perfectly, i.e., either string($office) or string($month) is true. 2. for both tests are false, I have to change your suggestion into [not(string($office) ) and not(string($month))] to get the correct answer. 3. for both tests are true, I get solutions but not the correct one comparing with the one from using *condition* variable. I could not get logical reason for it. Your pure XSLT solution certainly provides me a good lesson in using xslt. I have to work on IE5 and msxml3. So SAXON will not be a good solution to me. Thanks again, and hope to hear from you about the partially unsolved case. The following modified code is for reference. <xsl:variable name="condition" select="key('prodCode',$thisPP)[substring(@SalesOrderNo,10,2)=$month][substr ing(@SalesOrderN o,1,4)=$office]"/> <xsl:variable name="condition2" select="key('prodCode',$thisPP)[substring(@SalesOrderNo,10,2)=$month][substr ing(@SalesOrderN o,1,4)=$office][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 not(string($month))]"/> <xsl:call-template name="productset"> <xsl:with-param name="datas" select="$condition2"/> </xsl:call-template> Sun-Fu Yang sfyang@xxxxxxxxxxxxx ----- Original Message ----- From: "Jarno Elovirta" <jarno@xxxxxxxxxxxx> To: <sfyang@xxxxxxxxxxxxx> 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Problem in define Node-se, Michael Kay | Thread | Re: [xsl] Problem in define Node-se, Yang |
RE: [xsl] CJK UTF-16 test, Michael Kay | Date | RE: [xsl] Changing encoding using a, Michael Kay |
Month |