cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <joerg.heini...@gmx.de>
Subject Re: XPath problem in Cocoon?
Date Fri, 20 Dec 2002 00:43:08 GMT
Anna Afonchenko wrote:
> Hi Luca. Thank you for answering. Yes, probably that's something with my
> configuration. I am using Win98, Tomcat 4.1.12, Cocoon 2.0.4, Xalan 2.4.1.
> I'll try to change the Xalan version.
> Anyway, this thing is very weird.
> 
> Thank you.
> Anna

Hello Anna,

may I point out again, that in my opinion it is a simple namespace 
problem. Ok, it's only a guess, but I never heart of a bug like you 
describe. And exactly this behaviour is comprehensible with the 
following test case:

XML: elements are in default namespace

<root xmlns="test">
     <p>a node to match</p>
</root>

XSL:

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:test="test">

<xsl:template match="/">
<table border="1">
   <tr>
     <td>1. test using "//p":</td>
     <td><xsl:value-of select="count(//p)"/> matched</td>
   </tr>
   <tr>
     <td>2. test using "//test:p":</td>
     <td><xsl:value-of select="count(//test:p)"/> matched</td>
   </tr>
   <tr>
     <td>3. test using "//*[name() = 'p']":</td>
     <td><xsl:value-of select="count(//*[name() = 'p'])"/> matched</td>
   </tr>
   <tr>
     <td>4. test using "//*[name() = 'test:p']":</td>
     <td><xsl:value-of select="count(//*[name() = 'test:p'])"/> matched</td>
   </tr>
</table>
</xsl:template>

</xsl:stylesheet>

Result:

1. test using "//p":                     0 matched
2. test using "//test:p":                1 matched
3. test using "//*[name() = 'p']":       1 matched
4. test using "//*[name() = 'test:p']":  0 matched

Your cases are number 1 and 3 and you can see the same behaviour. Have a 
look into your XML file, whether a default namespace is set there. The 
reason for the differences when using default namespace is, that you 
must bind it in XSLT on a prefix. You can not match on elements via //p, 
if they are in default namespace.

Regards,

Joerg


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>


Mime
View raw message