cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Boag/CAM/Lotus" <Scott_B...@lotus.com>
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." (http://www.w3.org/TR/xpath#predicates).

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).

-scott




                                                                                         
                         
                    Stefano                                                              
                         
                    Mazzocchi            To:     Scott Boag <Scott_Boag/CAM/Lotus@lotus.com>
                      
                    <stefano@apac        cc:     Cocoon <cocoon-dev@xml.apache.org>
                               
                    he.org>              Subject:     Xalan bug?                      
                            
                                                                                         
                         
                    05/18/2000                                                           
                         
                    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.
<stefano@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------







Mime
View raw message