cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anna Afonchenko" <a...@ubaccess.com>
Subject Re: XPath problems in Cocoon?
Date Mon, 24 Feb 2003 07:33:32 GMT
Thank you very much for answering and sorry to ask XSL question
on Cocoon list. But now my problem stays only in Cocoon.
I did as you advice and edited my test.xsl file to

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*"/>
 <xsl:template match="/">
  <root>
  <xsl:for-each
select="//a[name(following-sibling::node()[1][not(self::text() and
normalize-space())])='a']">
   <xsl:value-of select="."/>
  </xsl:for-each>
  </root>
 </xsl:template>
</xsl:stylesheet>

Now, if I apply this stylesheet on html file test.html using the batch file:
c:\saxon\saxon -o outTest.xml testAnchors.html testAnchors.xsl
I get the right answer: <root>One</root> and this is great.

But when I tried to apply this stylesheet using cocoon, I still got the
empty root element <root/>
as a result.
I.e. now my stylesheet works everywhere except for Cocoon.
So I guess the problem that I have now IS with Cocoon.
So I am really sorry to ask this again, but I still don't understand this
issue.

My pipeline is:
<map:match pattern="testAnchors">
<map:generate src="ub/testing/test.html" type="html"/>
<map:transform type="xslt-saxon" src="ub/testing/test.xsl"/>
<map:serialize type="xml"/>
</map:match>

I would be happy to hear any suggestions.
Thank you very very much for help.

Anna

----- Original Message -----
From: "J.Pietschmann" <j3322ptm@yahoo.de>
To: <cocoon-users@xml.apache.org>
Sent: Thursday, February 20, 2003 11:16 PM
Subject: Re: XPath problems in Cocoon?


Anna Afonchenko wrote:
> Even if the white spaces are supressed, the algorythm will stay right,
> because algorythm should check all a tags that are followed by another a
tag,
> and the only node between them MAY (not MUST) be white-space only text
node.

The problem is here
   select="//a[name(following-sibling::node()[1][not(self::text() and
                                       ^^^^^ You select the following nodes
                                             including all text nodes
                                             ^^^^ The grab the first.
For these two nodes in the source:
  <a href="one.html">One</a>  <a href="two.html">Two</a>
MSXML gets the second <a> element node, because it strips the text
node with the space between the two <a> elements. All other
processors see this text node instead of the second <a> node at this
point and the whole select turns out empty.

Add a
  <xsl:strip-space elements="*"/>
to the beginning of your style sheet in order to get the same results
for all processors.
Alternatively, try
  select="//a[following-sibling::a[1][not(normalize-space())]"
but perhaps you even want
  select="//a[following-sibling::a[not(normalize-space())][1]"
instead.

BTW you should ask XSLT questions on the XSLT list:
  http://www.mulberrytech.com/xsl/xsl-list/

J.Pietschmann


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


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