cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Boag/CAM/Lotus" <>
Subject Re: Xalan bug?
Date Thu, 18 May 2000 22:14:06 GMT

Stefano, I expect you guys are passing parameters as strings?

I suspect Xalan is looking at this as:

 <xsl:apply-templates select="//section['2']"/>

(if you pass 2 as a parameter).  Xalan then applies standard string to
boolean conversion, and you end up with:

 <xsl:apply-templates select="//section[true()]"/>

The applicable text in the XPath draft is:  "A PredicateExpr is evaluated
by evaluating the Expr and converting the result to a boolean. If the
result is a number, the result will be converted to true if the number is
equal to the context position and will be converted to false otherwise; if
the result is not a number, then the result will be converted as if by a
call to the boolean function." (

I'm pretty sure that the processor should not apply lexical testing to a
string to see if it might be a number, so I think the results from Xalan
are correct.

If you do:

 <xsl:apply-templates select="//section[number($section)]"/>

Then I think you will get the results you are looking for.

In the case of:

 <xsl:apply-templates select="//section[position() = $section]"/>

the conversion is done automatically.

Does this make sense?  It's predicated on the assumption that you are
passing string objects as parameters, which I think Donald was working on a
couple of weeks ago.  If I am wrong, I'll go to the next step of performing
some tests to see if there is a bug (though I think the basics are covered
in our test suite).


                    Mazzocchi            To:     Scott Boag <Scott_Boag/CAM/>
                    <stefano@apac        cc:     Cocoon <>
          >              Subject:     Xalan bug?                      
                    09:51 AM                                                             

Since many people recently complained about my cocoon slideshow example
that were not functional, I tested it and found something puzzling. In
my stylesheet I previously used

 <xsl:apply-templates select="//section[$section]"/>

where $section is an xsl:param got from the request parameter. This
doesn't seem to work anymore since it applies the templates on _ALL_
sections, ignoring the position restriction.

I changed this to

 <xsl:apply-templates select="//section[position() = $section]"/>

and works as expected and so it does

 <xsl:apply-templates select="//section[1]"/>

so, it appears that Xalan is ignoring variable expansion in the reduced
xpath syntax.

Hope this helps.

Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<>                             Friedrich Nietzsche
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------

View raw message