You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by gk...@apache.org on 2008/06/17 12:23:02 UTC

svn commit: r668604 - in /cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src: changes/ main/java/org/apache/cocoon/template/instruction/ main/resources/org/apache/cocoon/template/ test/java/org/apache/cocoon/template/jxtg/ test/resources/org/...

Author: gkossakowski
Date: Tue Jun 17 03:23:01 2008
New Revision: 668604

URL: http://svn.apache.org/viewvc?rev=668604&view=rev
Log:
COCOON-2211: Added support for jx:element - the instructions that allow dynamic element creation.COCOON-2211: Added support for jx:element
Thanks to Kamal Bhatt for providing a patch.

Added:
    cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/instruction/Element.java
    cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail1.xml
    cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail2.xml
    cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail3.xml
    cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail4.xml
    cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail5.xml
    cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-output.xml
    cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement.xml
Modified:
    cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/changes/changes.xml
    cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/resources/org/apache/cocoon/template/template-instructions.xml
    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/changes/changes.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/changes/changes.xml?rev=668604&r1=668603&r2=668604&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/changes/changes.xml (original)
+++ cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/changes/changes.xml Tue Jun 17 03:23:01 2008
@@ -24,9 +24,14 @@
     +-->
 <document>
   <body>
+    <release version="1.2.0" date="2008-??-??" description="unreleased">  
+      <action dev="gkossakowski" type="add" fixes-bug="COCOON-2211" due-to="Kamal Bhatt" due-to-email="bhatt@tt.com.au">
+        Added support for jx:element - the instructions that allow dynamic element creation.
+      </action>
+    </release>
     <release version="1.0.0-RC1" date="2007-??-??" description="unreleased">  
       
-    </release>    
+    </release>
     <release version="1.0.0-M3" date="2007-03-02" description="released">
       <action dev="vgritsenko" type="fix">
         Fix exception handling in script manager. Do not wrap processing exception into SAXException.

Added: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/instruction/Element.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/instruction/Element.java?rev=668604&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/instruction/Element.java (added)
+++ cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/instruction/Element.java Tue Jun 17 03:23:01 2008
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ */
+package org.apache.cocoon.template.instruction;
+
+import java.util.Stack;
+
+import org.apache.cocoon.el.objectmodel.ObjectModel;
+import org.apache.cocoon.el.parsing.Subst;
+import org.apache.cocoon.template.environment.ExecutionContext;
+import org.apache.cocoon.template.environment.ParsingContext;
+import org.apache.cocoon.template.script.Invoker;
+import org.apache.cocoon.template.script.event.Event;
+import org.apache.cocoon.template.script.event.StartElement;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.apache.cocoon.xml.util.NamespacesTable;
+import org.apache.commons.lang.StringUtils;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.AttributesImpl;
+
+public class Element extends Instruction {
+    private Subst name;
+    private Subst uri;
+    private Subst prefix;
+    
+    public static  final String XML_ELEM_NAME_BLANK = "parameter: \"name\" is required";
+    public static final String XML_ELEM_NAME_INVALID = "parameter: \"name\" is an invalid XML element name";
+    public static final String XML_PREFIX_NAME_INVALID = "parameter: \"prefix\" is an Invalid XML prefix";
+    public static final String XML_PREFIX_MISSING_NAMESPACE = "parameter: \"namespace\" must be specified if \"prefix\" is specified";
+
+    public Element(ParsingContext parsingContext, StartElement raw, Attributes attrs, Stack stack) throws SAXException {
+
+        super(raw);
+        this.name = getSubst("name", attrs, parsingContext, true);
+        this.uri = getSubst("uri", attrs, parsingContext, false);
+        this.prefix = getSubst("prefix", attrs, parsingContext, false); 
+    }
+
+    public Event execute(final XMLConsumer consumer, ObjectModel objectModel, ExecutionContext executionContext,
+            MacroContext macroContext, NamespacesTable namespaces, Event startEvent, Event endEvent)
+            throws SAXException {
+	final Attributes EMPTY_ATTRS = new AttributesImpl();
+	String nameStr = null;
+	String uriStr;
+	String prefixStr;
+	String qName;
+	
+        try {
+            nameStr = this.name.getStringValue(objectModel);
+            uriStr = (this.uri != null) ? this.uri.getStringValue(objectModel) : null;
+            prefixStr = (this.prefix != null) ? this.prefix.getStringValue(objectModel) : null;
+            
+            if (StringUtils.isBlank(nameStr))
+        	throw new SAXParseException(XML_ELEM_NAME_BLANK, getLocation());
+
+            if (!nameStr.matches("[A-Za-z][^\\s:]*"))
+        	throw new SAXParseException(XML_ELEM_NAME_INVALID, getLocation());  
+            
+            if (StringUtils.isNotBlank(prefixStr) && !prefixStr.matches("[A-Za-z][^\\s:]*"))
+        	throw new SAXParseException(XML_PREFIX_NAME_INVALID, getLocation());           
+            
+            if (StringUtils.isNotBlank(prefixStr) && StringUtils.isBlank(uriStr))
+        	throw new SAXParseException(XML_PREFIX_MISSING_NAMESPACE, getLocation());
+        	            
+            qName = (StringUtils.isNotBlank(prefixStr)) ? prefixStr + ":" + nameStr : nameStr;
+            
+            consumer.startElement(uriStr, nameStr, qName, EMPTY_ATTRS);
+            Invoker.execute(consumer, objectModel, executionContext, macroContext, namespaces, this.getNext(), this
+                            .getEndInstruction());            
+            consumer.endElement(uriStr, nameStr, qName);            
+        } catch (Exception e) {
+            throw new SAXParseException(e.getMessage(), getLocation(), e);
+        }
+        return getEndInstruction().getNext();
+    }
+    
+    private Subst getSubst(String attrName, Attributes attrs, ParsingContext parsingContext, boolean isRequired)
+    	    throws SAXParseException
+    {
+	Locator locator = getLocation();
+	String value = attrs.getValue(attrName);
+        if (isRequired && value == null) {           
+            throw new SAXParseException("parameter: \"" + attrName + "\" is required", locator, null);
+        }
+        else if (!isRequired && value == null) {
+            return(null);
+        }
+        
+        return parsingContext.getStringTemplateParser().compileExpr(value, "parameter: \"" + attrName + "\": ", locator);  	
+    }
+}

Modified: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/resources/org/apache/cocoon/template/template-instructions.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/resources/org/apache/cocoon/template/template-instructions.xml?rev=668604&r1=668603&r2=668604&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/resources/org/apache/cocoon/template/template-instructions.xml (original)
+++ cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/resources/org/apache/cocoon/template/template-instructions.xml Tue Jun 17 03:23:01 2008
@@ -24,6 +24,7 @@
         <instruction name="when" class="org.apache.cocoon.template.instruction.When"/>
         <instruction name="otherwise" class="org.apache.cocoon.template.instruction.Otherwise"/>
         <instruction name="out" class="org.apache.cocoon.template.instruction.Out"/>
+        <instruction name="element" class="org.apache.cocoon.template.instruction.Element"/>        
         <instruction name="import" class="org.apache.cocoon.template.instruction.Import"/>
         <instruction name="set" class="org.apache.cocoon.template.instruction.Set"/>
         <instruction name="macro" class="org.apache.cocoon.template.instruction.Define"/>

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=668604&r1=668603&r2=668604&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 Tue Jun 17 03:23:01 2008
@@ -27,6 +27,8 @@
 import org.apache.cocoon.el.objectmodel.ObjectModel;
 import org.xml.sax.SAXParseException;
 
+import org.apache.cocoon.template.instruction.Element;
+
 /**
  * @version SVN $Id$
  */
@@ -266,4 +268,93 @@
         assertEqual(load(outputURI), generate(JX, inputURI, EMPTY_PARAMS));
         getNewObjectModel().cleanupLocalContext();
     }
+
+    public void testPrefixMappingFailDueToNoNameSpecified() throws Exception {
+        String inputURI = docBase + "jxElement-fail1.xml";
+        getNewObjectModel().markLocalContext();
+        boolean error = false;
+        
+        try {
+            generate(JX, inputURI, EMPTY_PARAMS);
+        } catch (SAXParseException e) {               
+              error = true;
+        }
+        assertTrue("should throw sax exception due to no name", error);
+        getNewObjectModel().cleanupLocalContext();
+    }
+    
+    public void testPrefixMappingFailDueToInvalidNameSpecified() throws Exception {
+	String inputURI = docBase + "jxElement-fail2.xml";
+        getNewObjectModel().markLocalContext();
+        boolean error = false;
+        
+        try {
+            generate(JX, inputURI, EMPTY_PARAMS);
+        } catch (SAXParseException e) {
+            if (e.getMessage().equals(Element.XML_ELEM_NAME_INVALID))
+        	error = true;        
+        }
+        assertTrue("should throw sax exception due to invalid element name", error);      
+        getNewObjectModel().cleanupLocalContext();
+    }
+    
+    public void testPrefixMappingFailDueToMissingNamespaceSpecifedPrefix() throws Exception {
+	String inputURI = docBase + "jxElement-fail3.xml";
+        getNewObjectModel().markLocalContext();
+        boolean error = false;
+        
+        try {
+            generate(JX, inputURI, EMPTY_PARAMS);
+        } catch (SAXParseException e) {
+            if (e.getMessage().equals(Element.XML_PREFIX_MISSING_NAMESPACE))
+        	error = true;        
+        }
+        assertTrue("should throw sax exception due missing namespace", error);      
+        getNewObjectModel().cleanupLocalContext();
+    }    
+    
+    public void testPrefixMappingFailDueToEmptyName() throws Exception {
+	String inputURI = docBase + "jxElement-fail4.xml";
+        getNewObjectModel().markLocalContext();
+        boolean error = false;
+        
+        try {
+            generate(JX, inputURI, EMPTY_PARAMS);
+        } catch (SAXParseException e) {
+            if (e.getMessage().equals(Element.XML_ELEM_NAME_BLANK))
+        	error = true;        
+        }
+        assertTrue("should throw sax exception due empty name", error);      
+        getNewObjectModel().cleanupLocalContext();
+    }      
+    
+    public void testPrefixMappingFailDueToInvalidPrefix() throws Exception {
+	String inputURI = docBase + "jxElement-fail4.xml";
+        getNewObjectModel().markLocalContext();
+        boolean error = false;
+        
+        try {
+            generate(JX, inputURI, EMPTY_PARAMS);
+        } catch (SAXParseException e) {
+            if (e.getMessage().equals(Element.XML_ELEM_NAME_BLANK))
+        	error = true;        
+        }
+        assertTrue("should throw sax exception due empty name", error);      
+        getNewObjectModel().cleanupLocalContext();
+    }     
+    
+    public void testElementSuccess() throws Exception {
+        String inputURI =  docBase + "jxElement.xml";
+        
+        String outputURI = docBase + "jxElement-output.xml";
+
+        getNewObjectModel().markLocalContext();
+        Calendar cal = new GregorianCalendar(1979, 0, 1, 10, 21, 33);
+        getFlowContext().put("date", cal.getTime());
+        addFlowContextToObjectModel(getNewObjectModel());
+
+        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/jxElement-fail1.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail1.xml?rev=668604&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail1.xml (added)
+++ cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail1.xml Tue Jun 17 03:23:01 2008
@@ -0,0 +1,20 @@
+<?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">
+	<jx:element/>
+</root>

Added: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail2.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail2.xml?rev=668604&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail2.xml (added)
+++ cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail2.xml Tue Jun 17 03:23:01 2008
@@ -0,0 +1,21 @@
+<?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">
+	<jx:set var="elem" value="Invalid Element"/>
+	<jx:element name="${elem}"></jx:element>	 	    
+</root>

Added: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail3.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail3.xml?rev=668604&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail3.xml (added)
+++ cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail3.xml Tue Jun 17 03:23:01 2008
@@ -0,0 +1,21 @@
+<?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">
+	<jx:set var="elem" value="Test"/>
+	<jx:element name="${elem}" prefix="abc123"></jx:element>	 	    
+</root>

Added: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail4.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail4.xml?rev=668604&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail4.xml (added)
+++ cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail4.xml Tue Jun 17 03:23:01 2008
@@ -0,0 +1,21 @@
+<?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">
+	<jx:set var="elem" value=""/>
+	<jx:element name="${elem}"></jx:element>	 	    
+</root>

Added: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail5.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail5.xml?rev=668604&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail5.xml (added)
+++ cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-fail5.xml Tue Jun 17 03:23:01 2008
@@ -0,0 +1,21 @@
+<?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">
+	<jx:set var="elem" value="Test"/>
+	<jx:element name="${elem}" prefix="abc123:" namespace="http://www.test.com/test"></jx:element>	 	    
+</root>

Added: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-output.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-output.xml?rev=668604&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-output.xml (added)
+++ cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-output.xml Tue Jun 17 03:23:01 2008
@@ -0,0 +1,35 @@
+<?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">
+	<Empty/>
+	<ElementWithValue>value</ElementWithValue>
+	<OneFixedValueChildNode><ChildNode>Test</ChildNode></OneFixedValueChildNode>	
+	<WithChildGeneratedNode><ChildNode>dd</ChildNode></WithChildGeneratedNode>	
+	<DynamicElement>01 styczeń 1979</DynamicElement>	
+	<WithAttribute attribute="attr"/>
+	<AttributeAndChildNode attribute="attr"><ChildNode>A</ChildNode></AttributeAndChildNode>
+	<MixedContent attribute="attr">A<B/></MixedContent>
+	<MixedContent2 attribute="attr">A<B/></MixedContent2>		
+	<EmptyElementWithNamespace xmlns="http://cocoon.apache.org/kamal"/>
+	<EmptyElementWithGeneratedNamespace xmlns="http://cocoon.apache.org/kamalbhatt"/>	
+	<GeneratedElementWithGeneratedChild xmlns="http://cocoon.apache.org/kamalbhatt">
+	  <GeneratedChild xmlns="http://cocoon.apache.org/kamal">Test</GeneratedChild>
+	</GeneratedElementWithGeneratedChild>	
+	<prefix:ElementWithNamespaceAndHardCodedPrefix xmlns:prefix="http://cocoon.apache.org/kamalbhatt"/>
+	<kb:ElementWithNamespaceAndGeneratedPrefix xmlns:kb="http://cocoon.apache.org/kamalbhatt"/> 
+</root>

Added: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement.xml?rev=668604&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement.xml (added)
+++ cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement.xml Tue Jun 17 03:23:01 2008
@@ -0,0 +1,42 @@
+<?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">
+	<jx:set var="a" value="dd"/>
+	<jx:set var="elem" value="DynamicElement"/>
+	<jx:set var="namespace" value="http://cocoon.apache.org/kamalbhatt"/>
+	<jx:set var="prefix" value="kb"/>
+    <jx:element name="Empty"/>
+    <jx:element name="ElementWithValue">value</jx:element>
+	<jx:element name="OneFixedValueChildNode"><ChildNode>Test</ChildNode></jx:element>
+	<jx:element name="WithChildGeneratedNode"><ChildNode><jx:out value="${a}"/></ChildNode></jx:element>
+	<jx:element name="${elem}"><jx:formatDate value="${date}" pattern="dd MMMM yyyy" locale="pl_PL"/></jx:element>
+    <jx:element name="WithAttribute"><jx:attribute name="attribute" value="attr"/></jx:element>	
+	<jx:element name="AttributeAndChildNode">
+	  <jx:attribute name="attribute" value="attr"/>
+	  <ChildNode>A</ChildNode>
+	</jx:element>
+	<jx:element name="MixedContent"><jx:attribute name="attribute" value="attr"/>A<B/></jx:element>
+	<jx:element name="MixedContent2">A<jx:attribute name="attribute" value="attr"/><B/></jx:element>
+	<jx:element name="EmptyElementWithNamespace" uri="http://cocoon.apache.org/kamal"></jx:element>
+	<jx:element name="EmptyElementWithGeneratedNamespace" uri="${namespace}"></jx:element>
+	<jx:element name="GeneratedElementWithGeneratedChild" uri="${namespace}">
+	  <jx:element name="GeneratedChild" uri="http://cocoon.apache.org/kamal">Test</jx:element>
+	</jx:element>
+	<jx:element name="ElementWithNamespaceAndHardCodedPrefix" uri="${namespace}" prefix="prefix"/>
+	<jx:element name="ElementWithNamespaceAndGeneratedPrefix" uri="${namespace}" prefix="${prefix}"/> 
+</root>