cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lgaw...@apache.org
Subject svn commit: r570034 - in /cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src: main/java/org/apache/cocoon/template/ main/java/org/apache/cocoon/template/instruction/ main/java/org/apache/cocoon/template/script/event/ test/java/org/apache/coco...
Date Mon, 27 Aug 2007 08:29:27 GMT
Author: lgawron
Date: Mon Aug 27 01:29:26 2007
New Revision: 570034

URL: http://svn.apache.org/viewvc?rev=570034&view=rev
Log:
removed new local context creation for jx:import (without context="${bean}" attribute)
removed new local context creation for StartPrefixMapping, NamespacesTable is enough to keep
declared namespaces in order.
added some test cases for scope testing

Added:
    cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxPrefixMapping-2.xml
  (with props)
    cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxPrefixMapping-3-output.xml
  (with props)
    cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxPrefixMapping-3.xml
  (with props)
Modified:
    cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/JXTemplateGenerator.java
    cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/instruction/Import.java
    cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/script/event/EndPrefixMapping.java
    cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/script/event/StartPrefixMapping.java
    cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/java/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.java

Modified: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/JXTemplateGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/JXTemplateGenerator.java?rev=570034&r1=570033&r2=570034&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/JXTemplateGenerator.java
(original)
+++ cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/JXTemplateGenerator.java
Mon Aug 27 01:29:26 2007
@@ -145,10 +145,10 @@
         newObjectModel.markLocalContext();
 
         newObjectModel.putAt(ObjectModel.PARAMETERS_PATH, new ParametersMap(parameters));
-
+        newObjectModel.put(ObjectModel.NAMESPACE, namespaces);
         XMLConsumer consumer = new AttributeAwareXMLConsumerImpl(new RedundantNamespacesFilter(this.xmlConsumer));
-        //not sure why this is needed
         newObjectModel.putAt("cocoon/consumer", consumer);
+        
         Invoker.execute(consumer, this.newObjectModel, new ExecutionContext(this.definitions,
this.scriptManager,
                 this.manager), null, namespaces, startEvent, null);
 

Modified: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/instruction/Import.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/instruction/Import.java?rev=570034&r1=570033&r2=570034&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/instruction/Import.java
(original)
+++ cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/instruction/Import.java
Mon Aug 27 01:29:26 2007
@@ -47,8 +47,7 @@
     private final AttributeEvent uri;
     private final Subst select;
 
-    public Import(ParsingContext parsingContext, StartElement raw, Attributes attrs, Stack
stack)
-        throws SAXException {
+    public Import(ParsingContext parsingContext, StartElement raw, Attributes attrs, Stack
stack) throws SAXException {
 
         super(raw);
 
@@ -69,7 +68,8 @@
             // as the context object in the imported template
             String context = attrs.getValue("context");
             if (context != null) {
-                select = parsingContext.getStringTemplateParser().compileExpr(context, "import:
\"context\": ", locator);
+                select = parsingContext.getStringTemplateParser()
+                        .compileExpr(context, "import: \"context\": ", locator);
             }
         } else {
             throw new SAXParseException("import: \"uri\" is required", locator, null);
@@ -78,10 +78,9 @@
         this.select = select;
     }
 
-    public Event execute(final XMLConsumer consumer,
-                         ObjectModel objectModel, ExecutionContext executionContext,
-                         MacroContext macroContext, NamespacesTable namespaces, Event startEvent,
Event endEvent) 
-        throws SAXException {
+    public Event execute(final XMLConsumer consumer, ObjectModel objectModel, ExecutionContext
executionContext,
+            MacroContext macroContext, NamespacesTable namespaces, Event startEvent, Event
endEvent)
+            throws SAXException {
         String uri;
         AttributeEvent e = this.uri;
         if (e instanceof CopyAttribute) {
@@ -111,8 +110,9 @@
         } catch (ProcessingException exc) {
             throw new SAXParseException(exc.getMessage(), getLocation(), exc);
         }
-        objectModel.markLocalContext();
+
         if (this.select != null) {
+            objectModel.markLocalContext();
             try {
                 Object obj = this.select.getValue(objectModel);
                 objectModel.put(ObjectModel.CONTEXTBEAN, obj);
@@ -120,21 +120,20 @@
             } catch (Exception exc) {
                 throw new SAXParseException(exc.getMessage(), getLocation(), exc);
             } catch (Error err) {
-                throw new SAXParseException(err.getMessage(), getLocation(),
-                                            new ErrorHolder(err));
+                throw new SAXParseException(err.getMessage(), getLocation(), new ErrorHolder(err));
             }
         }
         try {
-            Invoker.execute(consumer, objectModel, executionContext,
-                            macroContext, namespaces, doc.getNext(), doc.getEndDocument());
+            Invoker.execute(consumer, objectModel, executionContext, macroContext, namespaces,
doc.getNext(), doc
+                    .getEndDocument());
         } catch (Exception exc) {
-            throw new SAXParseException(
-                                        "Exception occurred in imported template " + uri
-                                        + ": " + exc.getMessage(), getLocation(), exc);
-        }
-        
-        objectModel.cleanupLocalContext();
-        
+            throw new SAXParseException("Exception occurred in imported template " + uri
+ ": " + exc.getMessage(),
+                    getLocation(), exc);
+        }
+
+        if (this.select != null)
+            objectModel.cleanupLocalContext();
+
         return getEndInstruction().getNext();
     }
 }

Modified: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/script/event/EndPrefixMapping.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/script/event/EndPrefixMapping.java?rev=570034&r1=570033&r2=570034&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/script/event/EndPrefixMapping.java
(original)
+++ cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/script/event/EndPrefixMapping.java
Mon Aug 27 01:29:26 2007
@@ -45,9 +45,6 @@
             NamespacesTable namespaces, Event startEvent, Event endEvent) throws SAXException
{
         
         // (endPrefixMapping is sent in EndElement)
-        
-        objectModel.cleanupLocalContext();
-        
         return getNext();
     }
 }

Modified: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/script/event/StartPrefixMapping.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/script/event/StartPrefixMapping.java?rev=570034&r1=570033&r2=570034&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/script/event/StartPrefixMapping.java
(original)
+++ cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/script/event/StartPrefixMapping.java
Mon Aug 27 01:29:26 2007
@@ -51,8 +51,6 @@
             NamespacesTable namespaces, Event startEvent, Event endEvent) throws SAXException
{
         // the startPrefixMapping event will be sent in StartElement
         namespaces.addDeclaration(getPrefix(), getUri());
-        objectModel.markLocalContext();
-        objectModel.put(ObjectModel.NAMESPACE, namespaces);
         return getNext();
     }
 }

Modified: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/java/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/java/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.java?rev=570034&r1=570033&r2=570034&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/java/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.java
(original)
+++ cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/java/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.java
Mon Aug 27 01:29:26 2007
@@ -25,6 +25,7 @@
 import org.apache.cocoon.SitemapComponentTestCase;
 import org.apache.cocoon.components.flow.FlowHelper;
 import org.apache.cocoon.el.objectmodel.ObjectModel;
+import org.xml.sax.SAXParseException;
 
 /**
  * @version SVN $Id$
@@ -69,7 +70,7 @@
         return this.newObjectModel;
     }
 
-    public void testGenerate() throws Exception {
+     public void testGenerate() throws Exception {
         String inputURI = docBase + "generate.xml";
 
         assertEqual(load(inputURI), generate(JX, inputURI, EMPTY_PARAMS));
@@ -240,6 +241,27 @@
     public void testPrefixMapping() throws Exception {
         String inputURI = docBase + "jxPrefixMapping.xml";
         String outputURI = docBase + "jxPrefixMapping-output.xml";
+        getNewObjectModel().markLocalContext();
+        assertEqual(load(outputURI), generate(JX, inputURI, EMPTY_PARAMS));
+        getNewObjectModel().cleanupLocalContext();
+    }
+
+    public void testPrefixMapping2() throws Exception {
+        String inputURI = docBase + "jxPrefixMapping-2.xml";
+        getNewObjectModel().markLocalContext();
+        boolean error = false;
+        try {
+            generate(JX, inputURI, EMPTY_PARAMS);
+        } catch (SAXParseException e) {
+            error = true;
+        }
+        assertTrue("should throw on unbound prefix", error);
+        getNewObjectModel().cleanupLocalContext();
+    }
+
+    public void testPrefixMapping3() throws Exception {
+        String inputURI = docBase + "jxPrefixMapping-3.xml";
+        String outputURI = docBase + "jxPrefixMapping-3-output.xml";
         getNewObjectModel().markLocalContext();
         assertEqual(load(outputURI), generate(JX, inputURI, EMPTY_PARAMS));
         getNewObjectModel().cleanupLocalContext();

Added: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxPrefixMapping-2.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxPrefixMapping-2.xml?rev=570034&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxPrefixMapping-2.xml
(added)
+++ cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxPrefixMapping-2.xml
Mon Aug 27 01:29:26 2007
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+<root xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+	<foo:foo xmlns:foo="http://foor.org/bar/1.0">
+		<something/>
+	</foo:foo>
+	<foo:foo>
+		<something/>
+	</foo:foo>
+</root>

Propchange: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxPrefixMapping-2.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxPrefixMapping-2.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxPrefixMapping-3-output.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxPrefixMapping-3-output.xml?rev=570034&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxPrefixMapping-3-output.xml
(added)
+++ cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxPrefixMapping-3-output.xml
Mon Aug 27 01:29:26 2007
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+<root xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+	<foo:foo xmlns:foo="http://foo.org/bar/1.0">
+		<something/>
+	</foo:foo>
+	<foo:foo xmlns:foo="http://muu.org/foo/2.0">
+		<something/>
+	</foo:foo>
+</root>

Propchange: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxPrefixMapping-3-output.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxPrefixMapping-3-output.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxPrefixMapping-3.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxPrefixMapping-3.xml?rev=570034&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxPrefixMapping-3.xml
(added)
+++ cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxPrefixMapping-3.xml
Mon Aug 27 01:29:26 2007
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+<root xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+	<foo:foo xmlns:foo="http://foo.org/bar/1.0">
+		<something/>
+	</foo:foo>
+	<foo:foo xmlns:foo="http://muu.org/foo/2.0">
+		<something/>
+	</foo:foo>
+</root>

Propchange: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxPrefixMapping-3.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxPrefixMapping-3.xml
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message