cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: rev 54574 - in cocoon/branches/BRANCH_2_1_X/src: java/org/apache/cocoon/generation test/anteater webapp/samples/test/flowscript-dom-dump
Date Mon, 11 Oct 2004 12:39:15 GMT
Author: bdelacretaz
Date: Mon Oct 11 05:39:15 2004
New Revision: 54574

Added:
   cocoon/branches/BRANCH_2_1_X/src/test/anteater/flowscript-dom-dump.xml
   cocoon/branches/BRANCH_2_1_X/src/webapp/samples/test/flowscript-dom-dump/
   cocoon/branches/BRANCH_2_1_X/src/webapp/samples/test/flowscript-dom-dump/dom-dump.js
   cocoon/branches/BRANCH_2_1_X/src/webapp/samples/test/flowscript-dom-dump/dom-dumper.jx.xml
   cocoon/branches/BRANCH_2_1_X/src/webapp/samples/test/flowscript-dom-dump/explain-test.xml
   cocoon/branches/BRANCH_2_1_X/src/webapp/samples/test/flowscript-dom-dump/sitemap.xmap
   cocoon/branches/BRANCH_2_1_X/src/webapp/samples/test/flowscript-dom-dump/test-transform.xsl
Modified:
   cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java
Log:
bugzilla 29381, JXTemplateGenerator uses IncludeXMLConsumer to remove start/endDocument events
when dumping DOM objects

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java
Mon Oct 11 05:39:15 2004
@@ -2517,9 +2517,11 @@
         }
     }
 
+    /** dump a DOM document, using an IncludeXMLConsumer to filter out start/end document
events */
     private void executeDOM(final XMLConsumer consumer, MyJexlContext jexlContext, JXPathContext
jxpathContext, Node node)
             throws SAXException {
-        DOMStreamer streamer = new DOMStreamer(consumer);
+        IncludeXMLConsumer includer = new IncludeXMLConsumer(consumer);
+        DOMStreamer streamer = new DOMStreamer(includer);
         streamer.stream(node);
    }
 

Added: cocoon/branches/BRANCH_2_1_X/src/test/anteater/flowscript-dom-dump.xml
==============================================================================
--- (empty file)
+++ cocoon/branches/BRANCH_2_1_X/src/test/anteater/flowscript-dom-dump.xml	Mon Oct 11 05:39:15
2004
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<project name="flowscript-dom-dump" default="flowscript-dom-dump">
+
+    <!--
+      Check various ways of dumping DOM objects in Flowscript
+      (bugzilla 29381)
+    -->
+    <target name="flowscript-dom-dump">
+        <property name="baseUrl" value="${anteater.env.cocoon}/samples/test/flowscript-dom-dump"/>
+
+        <httpRequest href="${baseUrl}/dom-dump" description="Check dump without XSLT transform">
+            <match>
+                <header name="Content-type" value="text/xml"/>
+                <xpath select="//dump-without-star/root/child" pattern="childText"/>
+                <xpath select="//dump-with-star/root/child" pattern="childText"/>
+            </match>
+        </httpRequest>
+
+        <httpRequest href="${baseUrl}/dom-dump-xslt" description="Check dump with XSLT
transform">
+            <match>
+                <header name="Content-type" value="text/xml"/>
+                <xpath select="//dump-without-star/root/@test-transform" pattern="true"/>
+                <xpath select="//dump-without-star/root/child" pattern="childText"/>
+                <xpath select="//dump-with-star/root/@test-transform" pattern="true"/>
+                <xpath select="//dump-with-star/root/child" pattern="childText"/>
+            </match>
+        </httpRequest>
+
+    </target>
+
+</project>

Added: cocoon/branches/BRANCH_2_1_X/src/webapp/samples/test/flowscript-dom-dump/dom-dump.js
==============================================================================
--- (empty file)
+++ cocoon/branches/BRANCH_2_1_X/src/webapp/samples/test/flowscript-dom-dump/dom-dump.js	Mon
Oct 11 05:39:15 2004
@@ -0,0 +1,23 @@
+/*
+* Copyright 1999-2004 The Apache Software Foundation
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+function dumpDomObject() {
+    var dom = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+    var root = dom.appendChild(dom.createElement("root"));
+    var child = root.appendChild(dom.createElement("child"));
+    child.appendChild(dom.createTextNode("childText"));
+    cocoon.sendPage("dom-dump-pipeline", { "domObject" : dom });
+}

Added: cocoon/branches/BRANCH_2_1_X/src/webapp/samples/test/flowscript-dom-dump/dom-dumper.jx.xml
==============================================================================
--- (empty file)
+++ cocoon/branches/BRANCH_2_1_X/src/webapp/samples/test/flowscript-dom-dump/dom-dumper.jx.xml
Mon Oct 11 05:39:15 2004
@@ -0,0 +1,25 @@
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<dom-dumper xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+    <dump-without-star>
+        #{domObject}
+    </dump-without-star>
+
+    <dump-with-star>
+        #{domObject/*}
+    </dump-with-star>
+</dom-dumper>
\ No newline at end of file

Added: cocoon/branches/BRANCH_2_1_X/src/webapp/samples/test/flowscript-dom-dump/explain-test.xml
==============================================================================
--- (empty file)
+++ cocoon/branches/BRANCH_2_1_X/src/webapp/samples/test/flowscript-dom-dump/explain-test.xml
Mon Oct 11 05:39:15 2004
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- CVS $Id: explain-test.xml 30932 2004-07-29 17:35:38Z vgritsenko $ -->
+
+<page>
+    <title>flowscript-dom-dump test pages</title>
+    <content>
+        <para>
+            This is used by the flowscript-dom-dump anteater test
+        </para>
+        <para>
+            Test links:
+            <ul>
+                <li><link href="dom-dump">dump a DOM object, no transform</link></li>
+                <li><link href="dom-dump-xslt">dump a DOM object, followed by
XSLT transform</link></li>
+            </ul>
+        </para>
+    </content>
+</page>

Added: cocoon/branches/BRANCH_2_1_X/src/webapp/samples/test/flowscript-dom-dump/sitemap.xmap
==============================================================================
--- (empty file)
+++ cocoon/branches/BRANCH_2_1_X/src/webapp/samples/test/flowscript-dom-dump/sitemap.xmap
Mon Oct 11 05:39:15 2004
@@ -0,0 +1,46 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+
+    <map:flow language="javascript">
+        <map:script src="dom-dump.js"/>
+    </map:flow>
+
+    <map:pipelines>
+
+
+        <!-- used by the internalRequest anteater test -->
+        <map:pipeline>
+            <map:match pattern="dom-dump">
+                <map:call function="dumpDomObject"/>
+            </map:match>
+
+            <map:match pattern="dom-dump-pipeline">
+                <map:generate type="jx" src="dom-dumper.jx.xml"/>
+                <map:serialize type="xml"/>
+            </map:match>
+
+            <map:match pattern="dom-dump-xslt">
+                <map:generate src="cocoon:/dom-dump"/>
+                <map:transform src="test-transform.xsl"/>
+                <map:serialize type="xml"/>
+            </map:match>
+
+        </map:pipeline>
+
+    </map:pipelines>
+</map:sitemap>

Added: cocoon/branches/BRANCH_2_1_X/src/webapp/samples/test/flowscript-dom-dump/test-transform.xsl
==============================================================================
--- (empty file)
+++ cocoon/branches/BRANCH_2_1_X/src/webapp/samples/test/flowscript-dom-dump/test-transform.xsl
Mon Oct 11 05:39:15 2004
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!--
+    Identity transform used to test bugzilla 29381
+    CVS $Id: dir-links.xsl 30932 2004-07-29 17:35:38Z vgritsenko $
+ -->
+
+<xsl:stylesheet
+    version="1.0"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+>
+    <!-- by default copy everything -->
+    <xsl:template match="*">
+        <xsl:copy>
+            <xsl:copy-of select="@*"/>
+            <xsl:apply-templates/>
+        </xsl:copy>
+    </xsl:template>
+
+    <!-- let them know we were here -->
+    <xsl:template match="root">
+        <root test-transform="true">
+            <xsl:apply-templates/>
+        </root>
+    </xsl:template>
+</xsl:stylesheet>

Mime
View raw message