cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniele Madama (JIRA)" <j...@apache.org>
Subject [jira] Commented: (COCOON-1866) jx:comment doesn't work
Date Mon, 02 Oct 2006 13:15:58 GMT
    [ http://issues.apache.org/jira/browse/COCOON-1866?page=comments#action_12439132 ] 
            
Daniele Madama commented on COCOON-1866:
----------------------------------------

I try to reproduce the problem but I've no success. I'm using 2.1.10-dev version, but the
template block should be the same of  2.2. If I try to use

 <jx:comment xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">test for jx:comment</jx:comment>

I receive in output only one empty comment

<!---->

Lookin at the code I find a solution, but I don't know if it is correct

Index: src/blocks/template/java/org/apache/cocoon/template/instruction/Comment.java
===================================================================
--- src/blocks/template/java/org/apache/cocoon/template/instruction/Comment.java        (revision
451947)
+++ src/blocks/template/java/org/apache/cocoon/template/instruction/Comment.java        (working
copy)
@@ -59,8 +59,7 @@
         for (int i = 0; i < len; i++) {
             try {
                 String str = XMLUtils.serializeNode(nodeList.item(i), omit);
-                buf.append(StringUtils.substringAfter(str, ">")); // cut
-                // the XML header
+                buf.append(str);
             } catch (ProcessingException e) {
                 throw new SAXParseException(e.getMessage(), getLocation(), e);
             }

with this *simple* patch if I write:

  <jx:comment xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
    <test>test element</test>
  </jx:comment>
  <jx:comment xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">test for jx:comment</jx:comment>

the result is 

<!--
    <test>test element</test>

  -->
<!--test for jx:comment-->

so it seems that it work with text and also with nested elements.

I don't know if before there is some cases in which we need to remove the header element.

> jx:comment doesn't work
> -----------------------
>
>                 Key: COCOON-1866
>                 URL: http://issues.apache.org/jira/browse/COCOON-1866
>             Project: Cocoon
>          Issue Type: Bug
>          Components: Blocks: Templating
>            Reporter: Reinhard Poetz
>             Fix For: 2.2-dev (Current SVN)
>
>
> jx:comment produces following stack trace in trunk:
> java.lang.ArrayIndexOutOfBoundsException: -1
> 	at org.apache.xalan.serialize.SerializerToXML.comment(SerializerToXML.java:1298)
> 	at org.apache.xalan.transformer.TransformerIdentityImpl.comment(TransformerIdentityImpl.java:1272)
> 	at org.apache.cocoon.xml.AbstractXMLPipe.comment(AbstractXMLPipe.java:228)
> 	at org.apache.cocoon.xml.AbstractXMLPipe.comment(AbstractXMLPipe.java:228)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:324)
> 	at org.apache.cocoon.core.container.spring.PoolableFactoryBean$ProxyHandler.invoke(PoolableFactoryBean.java:340)
> 	at $Proxy5.comment(Unknown Source)
> 	at org.apache.xalan.transformer.ResultTreeHandler.comment(ResultTreeHandler.java:624)
> 	at org.apache.xpath.objects.XString.dispatchAsComment(XString.java:329)
> 	at org.apache.xalan.transformer.ClonerToResultTree.cloneToResultTree(ClonerToResultTree.java:248)
> 	at org.apache.xalan.templates.ElemCopy.execute(ElemCopy.java:155)
> 	at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:425)
> 	at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:216)
> 	at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:425)
> 	at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:216)
> 	at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2339)
> 	at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:710)
> 	at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2339)
> 	at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:710)
> 	at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:425)
> 	at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:216)
> 	at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2339)
> 	at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2160)
> 	at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1213)
> 	at org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:3372)
> 	at org.apache.xalan.transformer.TransformerHandlerImpl.endDocument(TransformerHandlerImpl.java:433)
> 	at org.apache.cocoon.xml.AbstractXMLPipe.endDocument(AbstractXMLPipe.java:54)
> 	at org.apache.cocoon.transformation.TraxTransformer.endDocument(TraxTransformer.java:577)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message