You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sc...@apache.org on 2006/06/12 19:20:37 UTC

svn commit: r413711 - in /myfaces/tomahawk/trunk: examples/simple/src/main/webapp/ sandbox/core/src/main/java/org/apache/myfaces/custom/template/ sandbox/core/src/main/resources-facesconfig/META-INF/ sandbox/core/src/main/tld/ sandbox/core/src/main/tld...

Author: schof
Date: Mon Jun 12 10:20:35 2006
New Revision: 413711

URL: http://svn.apache.org/viewvc?rev=413711&view=rev
Log:
Experimental XmlTemplate component.  Converts xml using xsl stylesheet.

Added:
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/template/
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/template/XmlTemplate.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/template/XmlTemplateTag.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/xml_template_attributes.xml
    myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/
    myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/
    myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/
    myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/
    myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/template/
    myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/template/ManagedFoo.java
    myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/template/XmlTemplateTest.java
    myfaces/tomahawk/trunk/sandbox/core/src/test/resources/
    myfaces/tomahawk/trunk/sandbox/core/src/test/resources/pets.xml
    myfaces/tomahawk/trunk/sandbox/core/src/test/resources/pets.xsl
    myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/template/
    myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/template/TemplateBacker.java
    myfaces/tomahawk/trunk/sandbox/examples/src/main/resources/org/apache/myfaces/examples/template/
    myfaces/tomahawk/trunk/sandbox/examples/src/main/resources/org/apache/myfaces/examples/template/foo.xml
    myfaces/tomahawk/trunk/sandbox/examples/src/main/resources/org/apache/myfaces/examples/template/foo.xsl
    myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/template/
    myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/template/index.jsp
Modified:
    myfaces/tomahawk/trunk/examples/simple/src/main/webapp/calendar.jsp
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml
    myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
    myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/examples-config.xml
    myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp

Modified: myfaces/tomahawk/trunk/examples/simple/src/main/webapp/calendar.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/examples/simple/src/main/webapp/calendar.jsp?rev=413711&r1=413710&r2=413711&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/examples/simple/src/main/webapp/calendar.jsp (original)
+++ myfaces/tomahawk/trunk/examples/simple/src/main/webapp/calendar.jsp Mon Jun 12 10:20:35 2006
@@ -57,7 +57,8 @@
                 currentDayCellClass="currentDayCell" value="#{calendarBean.secondDate}" renderAsPopup="true"
                 popupTodayString="#{example_messages['popup_today_string']}"
                 popupDateFormat="MM/dd/yyyy" popupWeekString="#{example_messages['popup_week_string']}"
-                helpText="MM/DD/YYYY"/>
+                helpText="MM/DD/YYYY"
+                forceId="true"/>
 
             <t:inputCalendar id="thirdOne" monthYearRowClass="yearMonthHeader" weekRowClass="weekHeader" popupButtonStyleClass="standard_bold"
                 currentDayCellClass="currentDayCell" value="#{calendarBean.secondDate}" renderAsPopup="true"

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/template/XmlTemplate.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/template/XmlTemplate.java?rev=413711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/template/XmlTemplate.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/template/XmlTemplate.java Mon Jun 12 10:20:35 2006
@@ -0,0 +1,253 @@
+/*
+ * Copyright 2006 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.
+ */
+package org.apache.myfaces.custom.template;
+
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.*;
+import java.net.URL;
+
+/**
+ * Used to transform XML (from either a String or URL) using either XSLT or
+ * Velocity.
+ *
+ * @author Sean Schofield
+ */
+public class XmlTemplate extends UIComponentBase
+{
+    public static final String COMPONENT_TYPE = "org.apache.myfaces.tomahawk.XmlTemplate";
+    public static final String COMPONENT_FAMILY = "org.apache.myfaces.tomahawk.Template";
+
+    private String content;
+    private String contentLocation;
+    private Object contentStream;
+    private String stylesheet;
+    private String stylesheetLocation;
+    private Object styleStream;
+
+    // see superclass for documentation
+    public String getFamily()
+    {
+        return COMPONENT_FAMILY;
+    }
+
+    public void encodeBegin(FacesContext context)
+            throws IOException
+    {
+        InputStream xmlStream = (InputStream)getContentStream();
+        String xml = getContent();
+        String xmlLocation = getContentLocation();
+
+        InputStream xslStream = (InputStream)getStyleStream();
+        String xsl = getStylesheet();
+        String xslLocation = getStylesheetLocation();
+
+        if (context == null) throw new NullPointerException("context");
+        if (!isRendered()) return;
+
+        if (getContent() == null && getContentLocation() == null && getContentStream() == null)
+            throw new NullPointerException("content/contentLocation/contentStream cannot all be null");
+
+        //TODO - handle all cases
+        if (xmlLocation != null)
+        {
+            ClassLoader loader = Thread.currentThread().getContextClassLoader();
+            if (loader == null)
+            {
+                loader = XmlTemplate.class.getClassLoader();
+            }
+
+            URL url = loader.getResource(xmlLocation);
+            xmlStream = new FileInputStream(new File(url.getFile()));
+        }
+
+        if (xslLocation != null)
+        {
+            ClassLoader loader = Thread.currentThread().getContextClassLoader();
+            if (loader == null)
+            {
+                loader = XmlTemplate.class.getClassLoader();
+            }
+
+            URL url = loader.getResource(xslLocation);
+            xslStream = new FileInputStream(new File(url.getFile()));
+        }
+
+        if (xml != null)
+        {
+            xmlStream = new ByteArrayInputStream(xml.getBytes());
+        }
+
+        if (xsl != null)
+        {
+            xslStream = new ByteArrayInputStream(xsl.getBytes());
+        }
+
+        if (xmlStream != null && xslStream != null)
+        {
+            transformContent(xmlStream, xslStream);
+        }
+    }
+
+    /**
+     * Transforms an XML string using the stylesheet string provided.
+     *
+     * @param content The XML to transform
+     * @param stylesheet The stylesheet to use in the transformation
+     * @throws IOException
+     */
+    private void transformContent(InputStream content, InputStream stylesheet)
+        throws IOException
+    {
+        try
+        {
+            TransformerFactory tFactory = TransformerFactory.newInstance();
+            Transformer transformer = tFactory.newTransformer(new StreamSource(stylesheet));
+
+            Writer responseWriter = FacesContext.getCurrentInstance().getResponseWriter();
+            transformer.transform(new StreamSource(content), new StreamResult(responseWriter));
+        }
+        catch (TransformerException te)
+        {
+            throw new IOException("Error while transforming XML: " + te.getMessage());
+        }
+    }
+
+    // component does not need to manage its own children (its not allowed to have any)
+    public void encodeChildren(FacesContext context)
+            throws IOException
+    {}
+
+    // nothing special to do here
+    public void encodeEnd(FacesContext context)
+            throws IOException
+    {}
+
+    //  see superclass for documentation
+    public Object saveState(FacesContext context)
+    {
+        Object values[] = new Object[5];
+
+        values[0] = super.saveState(context);
+        values[1] = content;
+        values[2] = contentLocation;
+        values[3] = stylesheet;
+        values[4] = stylesheetLocation;
+
+        /**
+         * NOTE: If setContentStream is called directly (instead of through value binding) it will
+         * not be saved in the state since it does not make sense to serialize a stream.
+         */
+
+        return values;
+    }
+
+    // see superclass for documentation
+    public void restoreState(FacesContext context, Object state)
+    {
+        Object values[] = (Object[]) state;
+        super.restoreState(context, values[0]);
+
+        content = (String)values[1];
+        contentLocation = (String)values[2];
+        stylesheet = (String)values[3];
+        stylesheetLocation = (String)values[4];
+    }
+
+    public void setContent(String content)
+    {
+        this.content = content;
+    }
+
+    public String getContent()
+    {
+        if (content != null) return content;
+
+        ValueBinding vb = getValueBinding("content");
+        return (vb != null) ? (String)vb.getValue(getFacesContext()) : null;
+    }
+
+    public void setContentLocation(String contentLocation)
+    {
+        this.contentLocation = contentLocation;
+    }
+
+    public String getContentLocation()
+    {
+        if (contentLocation != null) return contentLocation;
+
+        ValueBinding vb = getValueBinding("contentLocation");
+        return (vb != null) ? (String)vb.getValue(getFacesContext()) : null;
+    }
+
+    public void setStylesheet(String stylesheet)
+    {
+        this.stylesheet = stylesheet;
+    }
+
+    public String getStylesheet()
+    {
+        if (stylesheet != null) return stylesheet;
+
+        ValueBinding vb = getValueBinding("stylesheet");
+        return (vb != null) ? (String)vb.getValue(getFacesContext()) : null;
+    }
+
+    public void setContentStream(Object contentStream)
+    {
+        this.contentStream = contentStream;
+    }
+
+    public Object getContentStream()
+    {
+        if (contentStream != null) return contentStream;
+
+        ValueBinding vb = getValueBinding("contentStream");
+        return (vb != null) ? vb.getValue(getFacesContext()) : null;
+    }
+
+    public void setStylesheetLocation(String stylesheetLocation)
+    {
+        this.stylesheetLocation = stylesheetLocation;
+    }
+
+    public String getStylesheetLocation()
+    {
+        if (stylesheetLocation != null) return stylesheetLocation;
+
+        ValueBinding vb = getValueBinding("stylesheetLocation");
+        return (vb != null) ? (String)vb.getValue(getFacesContext()) : null;
+    }
+
+    public void setStyleStream(Object styleStream)
+    {
+        this.styleStream = styleStream;
+    }
+
+    public Object getStyleStream()
+    {
+        if (styleStream != null) return styleStream;
+
+        ValueBinding vb = getValueBinding("styleStream");
+        return (vb != null) ? vb.getValue(getFacesContext()) : null;
+    }
+}

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/template/XmlTemplateTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/template/XmlTemplateTag.java?rev=413711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/template/XmlTemplateTag.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/template/XmlTemplateTag.java Mon Jun 12 10:20:35 2006
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2006 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.
+ */
+package org.apache.myfaces.custom.template;
+
+import javax.faces.component.UIComponent;
+import javax.faces.webapp.UIComponentTag;
+import javax.faces.el.ValueBinding;
+
+/**
+ * JspTag for XmlTemplate Component
+ * @author Sean Schofield
+ */
+public class XmlTemplateTag extends UIComponentTag
+{
+    private String content;
+    private String contentLocation;
+    private String contentStream;
+    private String stylesheet;
+    private String stylesheetLocation;
+    private String styleStream;
+
+    public String getComponentType()
+    {
+        return XmlTemplate.COMPONENT_TYPE;
+    }
+
+    public String getRendererType()
+    {
+        /**
+         * There is no renderer for this component.  Component just transforms XML and writes directly to the
+         * response stream.
+         */
+        return null;
+    }
+
+    public void setContent(String content)
+    {
+        this.content = content;
+    }
+
+    public void setContentLocation(String contentLocation)
+    {
+        this.contentLocation = contentLocation;
+    }
+
+    public void setContentStream(String contentStream)
+    {
+        this.contentStream = contentStream;
+    }
+
+    public void setStylesheet(String stylesheet)
+    {
+        this.stylesheet = stylesheet;
+    }
+
+    public void setStylesheetLocation(String stylesheetLocation)
+    {
+        this.stylesheetLocation = stylesheetLocation;
+    }
+
+    public void setStyleStream(String styleStream)
+    {
+        this.styleStream = styleStream;
+    }
+
+    protected void setProperties(UIComponent component)
+    {
+        super.setProperties(component);
+
+        XmlTemplate template = (XmlTemplate)component;
+
+        if (content != null && isValueReference(content))
+        {
+            ValueBinding vb = getFacesContext().getApplication().createValueBinding(content);
+            component.setValueBinding("content", vb);
+        }
+        else
+        {
+            template.setContent(content);
+        }
+
+        if (contentLocation != null && isValueReference(contentLocation))
+        {
+            ValueBinding vb = getFacesContext().getApplication().createValueBinding(contentLocation);
+            component.setValueBinding("contentLocation", vb);
+        }
+        else
+        {
+            template.setContentLocation(contentLocation);
+        }
+
+        if (contentStream != null && isValueReference(contentStream))
+        {
+            ValueBinding vb = getFacesContext().getApplication().createValueBinding(contentStream);
+            component.setValueBinding("contentStream", vb);
+        }
+
+        if (stylesheet != null && isValueReference(stylesheet))
+        {
+            ValueBinding vb = getFacesContext().getApplication().createValueBinding(stylesheet);
+            component.setValueBinding("stylesheet", vb);
+        }
+        else
+        {
+            template.setStylesheet(stylesheet);
+        }
+
+        if (stylesheetLocation != null && isValueReference(stylesheetLocation))
+        {
+            ValueBinding vb = getFacesContext().getApplication().createValueBinding(stylesheetLocation);
+            component.setValueBinding("stylesheetLocation", vb);
+        }
+        else
+        {
+            template.setStylesheetLocation(stylesheetLocation);
+        }
+
+        if (styleStream != null && isValueReference(styleStream))
+        {
+            ValueBinding vb = getFacesContext().getApplication().createValueBinding(styleStream);
+            component.setValueBinding("styleStream", vb);
+        }
+    }
+}

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml?rev=413711&r1=413710&r2=413711&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml Mon Jun 12 10:20:35 2006
@@ -30,15 +30,10 @@
   </component>
 
   <component>
-    <component-type>org.apache.myfaces.TableSuggestAjax</component-type>
-    <component-class>org.apache.myfaces.custom.suggestajax.tablesuggestajax.TableSuggestAjax</component-class>
+    <component-type>org.apache.myfaces.AjaxChildComboBox</component-type>
+    <component-class>org.apache.myfaces.custom.ajaxchildcombobox.AjaxChildComboBox</component-class>
   </component>
 
-  <component>
-    <component-type>org.apache.myfaces.AjaxChildComboBox</component-type>
-    <component-class>org.apache.myfaces.custom.ajaxchildcombobox.AjaxChildComboBox</component-class>
-  </component>
-
   <component>
 	<component-type>org.apache.myfaces.HtmlOutputTextFor</component-type>
 	<component-class>org.apache.myfaces.custom.suggestajax.tablesuggestajax.HtmlOutputText</component-class>
@@ -119,23 +114,23 @@
 	<component-class>org.apache.myfaces.custom.scope.UIScope</component-class>
   </component>
 
-  <component>
-	<component-type>org.apache.myfaces.StartConversation</component-type>
-	<component-class>org.apache.myfaces.custom.conversation.UIStartConversation</component-class>
-  </component>
-  <component>
-	<component-type>org.apache.myfaces.EndConversation</component-type>
-	<component-class>org.apache.myfaces.custom.conversation.UIEndConversation</component-class>
-  </component>
-  <component>
-	<component-type>org.apache.myfaces.SeparateConversationContext</component-type>
-	<component-class>org.apache.myfaces.custom.conversation.UISeparateConversationContext</component-class>
-  </component>
-  <component>
-	<component-type>org.apache.myfaces.Conversation</component-type>
-	<component-class>org.apache.myfaces.custom.conversation.UIConversation</component-class>
-  </component>
-  
+  <component>
+	<component-type>org.apache.myfaces.StartConversation</component-type>
+	<component-class>org.apache.myfaces.custom.conversation.UIStartConversation</component-class>
+  </component>
+  <component>
+	<component-type>org.apache.myfaces.EndConversation</component-type>
+	<component-class>org.apache.myfaces.custom.conversation.UIEndConversation</component-class>
+  </component>
+  <component>
+	<component-type>org.apache.myfaces.SeparateConversationContext</component-type>
+	<component-class>org.apache.myfaces.custom.conversation.UISeparateConversationContext</component-class>
+  </component>
+  <component>
+	<component-type>org.apache.myfaces.Conversation</component-type>
+	<component-class>org.apache.myfaces.custom.conversation.UIConversation</component-class>
+  </component>
+  
   <component>
 	<component-type>org.apache.myfaces.HtmlSelectManyPicklist</component-type>
 	<component-class>org.apache.myfaces.custom.picklist.HtmlSelectManyPicklist</component-class>
@@ -176,9 +171,11 @@
     <component-class>org.apache.myfaces.custom.timednotifier.TimedNotifier</component-class>
  </component>
 
-	
+  <component>
+    <component-type>org.apache.myfaces.tomahawk.XmlTemplate</component-type>
+    <component-class>org.apache.myfaces.custom.template.XmlTemplate</component-class>
+  </component>
 
-  
   <!-- sandbox converters -->
 
   <converter>
@@ -235,12 +232,12 @@
       <renderer-class>org.apache.myfaces.custom.suggestajax.tablesuggestajax.TableSuggestAjaxRenderer</renderer-class>
     </renderer>
 
-    <renderer>
-      <component-family>javax.faces.SelectOne</component-family>
-      <renderer-type>org.apache.myfaces.AjaxChildComboBox</renderer-type>
-      <renderer-class>org.apache.myfaces.custom.ajaxchildcombobox.HtmlAjaxChildComboBoxRenderer</renderer-class>
-    </renderer>
-
+    <renderer>
+      <component-family>javax.faces.SelectOne</component-family>
+      <renderer-type>org.apache.myfaces.AjaxChildComboBox</renderer-type>
+      <renderer-class>org.apache.myfaces.custom.ajaxchildcombobox.HtmlAjaxChildComboBoxRenderer</renderer-class>
+    </renderer>
+
     <renderer>
       <component-family>javax.faces.Command</component-family>
       <renderer-type>org.apache.myfaces.CommandButtonAjax</renderer-type>

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/xml_template_attributes.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/xml_template_attributes.xml?rev=413711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/xml_template_attributes.xml (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/xml_template_attributes.xml Mon Jun 12 10:20:35 2006
@@ -0,0 +1,53 @@
+<attribute>
+    <name>content</name>
+    <required>false</required>
+    <rtexprvalue>false</rtexprvalue>
+    <type>java.lang.String</type>
+    <description>String containing the XML content to be transformed.</description>
+</attribute>
+
+<attribute>
+    <name>contentLocation</name>
+    <required>false</required>
+    <rtexprvalue>false</rtexprvalue>
+    <type>java.lang.String</type>
+    <description>String containing the location of the XML content to be transformed.</description>
+</attribute>
+
+<attribute>
+    <name>contentStream</name>
+    <required>false</required>
+    <rtexprvalue>false</rtexprvalue>
+    <type>java.lang.String</type>
+    <description>
+        Value binding expression referencing an InputStream from which the XML content
+        is to be read.
+    </description>
+</attribute>
+
+<attribute>
+    <name>stylesheet</name>
+    <required>false</required>
+    <rtexprvalue>false</rtexprvalue>
+    <type>java.lang.String</type>
+    <description>String containing the XSL information to use in the transformation.</description>
+</attribute>
+
+<attribute>
+    <name>stylesheetLocation</name>
+    <required>false</required>
+    <rtexprvalue>false</rtexprvalue>
+    <type>java.lang.String</type>
+    <description>String containing the location of the XSL stylesheet to use in the transformation.</description>
+</attribute>
+
+<attribute>
+    <name>styleStream</name>
+    <required>false</required>
+    <rtexprvalue>false</rtexprvalue>
+    <type>java.lang.String</type>
+    <description>
+        Value binding expression referencing an InputStream from which the XSL stylesheet
+        is to be read.
+    </description>
+</attribute>

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld?rev=413711&r1=413710&r2=413711&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld Mon Jun 12 10:20:35 2006
@@ -132,6 +132,7 @@
 <!ENTITY ext_escape_attribute	SYSTEM "entities-share/ext_escape_attribute.xml">
 <!ENTITY convertNumber_attributes SYSTEM "entities/standard_convertNumber_attributes.xml">
 <!ENTITY ui_convertNumber_attributes SYSTEM "entities/ui_convertNumber_attributes.xml">
+<!ENTITY xml_template_attributes SYSTEM "entities/xml_template_attributes.xml">
 ]>
 
 <taglib>
@@ -144,7 +145,17 @@
         Enhanced standard JSP actions and custom MyFaces actions.
     </description>
 
-	<!-- inputSuggest -->
+    <!-- xmlTemplate -->
+	<tag>
+		<name>xmlTemplate</name>
+		<tag-class>org.apache.myfaces.custom.template.XmlTemplateTag</tag-class>
+		<body-content>JSP</body-content>
+		<description>Transforms XML using and XSL stylesheet.</description>
+		&xml_template_attributes;
+        &faces_rendered_attribute;
+    </tag>
+
+    <!-- inputSuggest -->
 	<tag>
 		<name>inputSuggest</name>
 		<tag-class>org.apache.myfaces.custom.suggest.InputSuggestTag</tag-class>

Added: myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/template/ManagedFoo.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/template/ManagedFoo.java?rev=413711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/template/ManagedFoo.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/template/ManagedFoo.java Mon Jun 12 10:20:35 2006
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2006 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.
+ */
+package org.apache.myfaces.custom.template;
+
+import java.io.InputStream;
+
+/**
+ * Simple class to be used as a ManagedBean in testing.
+ *
+ * @author Sean Schofield
+ */
+public class ManagedFoo
+{
+    private String content;
+    private String stylesheet;
+    private String contentLocation;
+    private String stylesheetLocation;
+    private InputStream contentStream;
+    private InputStream styleStream;
+
+    public String getContent()
+    {
+        return content;
+    }
+
+    public void setContent(String content)
+    {
+        this.content = content;
+    }
+
+    public String getStylesheet()
+    {
+        return stylesheet;
+    }
+
+    public void setStylesheet(String stylesheet)
+    {
+        this.stylesheet = stylesheet;
+    }
+
+    public String getContentLocation()
+    {
+        return contentLocation;
+    }
+
+    public void setContentLocation(String contentLocation)
+    {
+        this.contentLocation = contentLocation;
+    }
+
+    public String getStylesheetLocation()
+    {
+        return stylesheetLocation;
+    }
+
+    public void setStylesheetLocation(String stylesheetLocation)
+    {
+        this.stylesheetLocation = stylesheetLocation;
+    }
+
+    public InputStream getContentStream()
+    {
+        return contentStream;
+    }
+
+    public void setContentStream(InputStream contentStream)
+    {
+        this.contentStream = contentStream;
+    }
+
+    public InputStream getStyleStream()
+    {
+        return styleStream;
+    }
+
+    public void setStyleStream(InputStream styleStream)
+    {
+        this.styleStream = styleStream;
+    }
+}

Added: myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/template/XmlTemplateTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/template/XmlTemplateTest.java?rev=413711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/template/XmlTemplateTest.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/template/XmlTemplateTest.java Mon Jun 12 10:20:35 2006
@@ -0,0 +1,394 @@
+/*
+ * Copyright 2006 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.
+ */
+
+package org.apache.myfaces.custom.template;
+
+import org.apache.shale.test.base.AbstractJsfTestCase;
+import org.apache.shale.test.mock.MockResponseWriter;
+import org.apache.shale.test.mock.MockRenderKitFactory;
+import org.apache.shale.test.mock.MockHttpServletRequest;
+import org.apache.shale.test.mock.MockValueBinding;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import java.io.*;
+import java.net.URL;
+
+/**
+ * Test case for XmlTemplate
+ *
+ * @author Sean Schofield
+ */
+public class XmlTemplateTest extends AbstractJsfTestCase
+{
+    private static final String PETS_STYLESHEET = "pets.xsl";
+    private static final String PETS_CONTENT = "pets.xml";
+    private static final String EXPECTED_TEXT = "Iguana";
+
+    private XmlTemplate xmlTemplate;
+    private ManagedFoo fooBean;
+    private String stylesheet;
+    private String stylesheetLocation = PETS_STYLESHEET;
+    private InputStream styleStream;
+    private String content;
+    private String contentLocation = PETS_CONTENT;
+    private InputStream contentStream;
+
+    private StringWriter mockWriter = new StringWriter();
+
+    /**
+     * Constructor
+     * @param name String
+     */
+    public XmlTemplateTest(String name)
+    {
+        super(name);
+    }
+
+    /**
+     * See abstract class
+     */
+    public void setUp()
+    {
+        super.setUp();
+
+        xmlTemplate = new XmlTemplate();
+
+        // additional setup not provided automatically by the shale mock stuff
+        facesContext.setResponseWriter(new MockResponseWriter(mockWriter, null, null));
+
+        // TODO remove these two lines once shale-test goes alpha, see MYFACES-1155
+        facesContext.getViewRoot().setRenderKitId(MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
+
+        fooBean = new ManagedFoo();
+        fooBean.setContentLocation(PETS_CONTENT);
+        fooBean.setStylesheetLocation(PETS_STYLESHEET);
+
+        // put the foo bean in the request scope
+        MockHttpServletRequest request = (MockHttpServletRequest)facesContext.getExternalContext().getRequest();
+        request.setAttribute("foo", fooBean);
+
+        // setup input stream to be used in some of the test cases
+        ClassLoader loader = Thread.currentThread().getContextClassLoader();
+        if (loader == null)
+        {
+            loader = XmlTemplate.class.getClassLoader();
+        }
+
+        URL url = loader.getResource(PETS_CONTENT);
+        try
+        {
+            contentStream = new FileInputStream(new File(url.getFile()));
+
+            // now also populate the String variable for certain test cases
+            FileInputStream cs = new FileInputStream(new File(url.getFile()));
+            int x= cs.available();
+            byte b[]= new byte[x];
+            //noinspection ResultOfMethodCallIgnored
+            cs.read(b);
+            content = new String(b);
+        }
+        catch (IOException io)
+        {}  // do nothing - test will fail eventually
+
+        // setup stylesheet text to be used in some of the test cases
+        url = loader.getResource(PETS_STYLESHEET);
+        try
+        {
+            styleStream = new FileInputStream(new File(url.getFile()));
+
+            // now also populate the String variable for certain test cases
+            FileInputStream ss = new FileInputStream(new File(url.getFile()));
+            int x= ss.available();
+            byte b[]= new byte[x];
+            //noinspection ResultOfMethodCallIgnored
+            ss.read(b);
+            stylesheet = new String(b);
+        }
+        catch (IOException io)
+        {}  // do nothing - test will fail eventually
+
+        fooBean.setContent(content);
+        fooBean.setStylesheet(stylesheet);
+        fooBean.setContentStream(contentStream);
+        fooBean.setStyleStream(styleStream);
+    }
+
+    /**
+     * Test the save and restore state methods.
+     */
+    public void testSaveAndRestoreState()
+    {
+        /**
+         * NOTE: Normally you would not set all of these properties together in the component, but for the
+         * purposes of testing, we want to make sure all fields are saved and restored properly.
+         */
+        xmlTemplate.setContent(content);
+        xmlTemplate.setContentLocation(contentLocation);
+        xmlTemplate.setStylesheet(stylesheet);
+        xmlTemplate.setStylesheetLocation(stylesheetLocation);
+        xmlTemplate.setContentStream(contentStream);
+        xmlTemplate.setStyleStream(styleStream);
+
+        Object state = xmlTemplate.saveState(facesContext);
+        xmlTemplate = new XmlTemplate();
+        xmlTemplate.restoreState(facesContext, state);
+
+        assertEquals(content, xmlTemplate.getContent());
+        assertEquals(contentLocation, xmlTemplate.getContentLocation());
+        assertEquals(stylesheet, xmlTemplate.getStylesheet());
+        assertEquals(stylesheetLocation, xmlTemplate.getStylesheetLocation());
+        assertNull("contentStream should be null since it cannot be serialized", xmlTemplate.getContentStream());
+        assertNull("styleStream should be null since it cannot be serialized", xmlTemplate.getStyleStream());
+    }
+
+    /**
+     * Test the save and restore state methods with all values as value binding expressions.  This also tests
+     * the value bindings themselves to make sure they are working.
+     */
+    public void testSaveAndRestoreStateValueBinding()
+    {
+        /**
+         * NOTE: Normally you would not set all of these properties together in the component, but for the
+         * purposes of testing, we want to make sure all fields are saved and restored properly.
+         */
+        xmlTemplate.setValueBinding("content", new MockValueBinding(application, "#{foo.content}"));
+        xmlTemplate.setValueBinding("contentLocation", new MockValueBinding(application, "#{foo.contentLocation}"));
+        xmlTemplate.setValueBinding("stylesheet", new MockValueBinding(application, "#{foo.stylesheet}"));
+        xmlTemplate.setValueBinding("stylesheetLocation", new MockValueBinding(application, "#{foo.stylesheetLocation}"));
+        xmlTemplate.setValueBinding("contentStream", new MockValueBinding(application, "#{foo.contentStream}"));
+        xmlTemplate.setValueBinding("styleStream", new MockValueBinding(application, "#{foo.styleStream}"));
+
+        Object state = xmlTemplate.saveState(facesContext);
+        xmlTemplate = new XmlTemplate();
+        xmlTemplate.restoreState(facesContext, state);
+
+        assertEquals(content, xmlTemplate.getContent());
+        assertEquals(contentLocation, xmlTemplate.getContentLocation());
+        assertEquals(stylesheet, xmlTemplate.getStylesheet());
+        assertEquals(stylesheetLocation, xmlTemplate.getStylesheetLocation());
+        assertEquals(contentStream, xmlTemplate.getContentStream());
+    }
+
+    public void testSetContent()
+    {
+        xmlTemplate.setContent("foo");
+        assertEquals("foo", xmlTemplate.getContent());
+
+        // reset property so we can test value binding
+        xmlTemplate.setContent(null);
+        xmlTemplate.setValueBinding("content", new MockValueBinding(application, "#{foo.content}"));
+        assertEquals(fooBean.getContent(), xmlTemplate.getContent());
+    }
+
+    public void testSetContentStream()
+    {
+        xmlTemplate.setContentStream(fooBean.getContentStream());
+        assertEquals(fooBean.getContentStream(), xmlTemplate.getContentStream());
+    }
+
+    public void testSetContentStreamValueBinding()
+    {
+        xmlTemplate.setValueBinding("contentStream", new MockValueBinding(application, "#{foo.contentStream}"));
+        assertEquals(fooBean.getContentStream(), xmlTemplate.getContentStream());
+    }
+
+    public void testSetStylesheet()
+    {
+        xmlTemplate.setStylesheet("foo");
+        assertEquals("foo", xmlTemplate.getStylesheet());
+
+        // reset property so we can test value binding
+        xmlTemplate.setStylesheet(null);
+        xmlTemplate.setValueBinding("stylesheet", new MockValueBinding(application, "#{foo.stylesheet}"));
+        assertEquals(fooBean.getStylesheet(), xmlTemplate.getStylesheet());
+    }
+
+    /**
+     * Component should throw NPE if no stylesheet or template is provided
+     */
+    public void testNoTransformInfo() throws IOException
+    {
+        try
+        {
+            xmlTemplate.encodeBegin(facesContext);
+        }
+        catch (NullPointerException e)
+        {
+            return;
+        }
+
+        fail("Expected exception when no template or stylesheet provided");
+    }
+
+    /**
+     * Component should throw NPE if no content is provided
+     */
+    public void testStylesheetNoContent() throws IOException
+    {
+        // stylesheet is not sufficient, content must be provided
+        xmlTemplate.setStylesheet("blah");
+
+        try
+        {
+            xmlTemplate.encodeBegin(facesContext);
+        }
+        catch (NullPointerException e)
+        {
+            return;
+        }
+
+        fail("Expected exception when stylesheet but no content provided");
+    }
+
+    public void testStyleSheet() throws IOException
+    {
+        xmlTemplate.setContentLocation(contentLocation);
+        xmlTemplate.setStylesheet(stylesheet);
+        xmlTemplate.encodeBegin(facesContext);
+
+        String responseText = mockWriter.toString();
+        assertEquals("Unexpected response text from content transformation", EXPECTED_TEXT, responseText);
+    }
+
+    public void testStyleSheetValueBinding() throws IOException
+    {
+        xmlTemplate.setContent(content);
+        xmlTemplate.setValueBinding("stylesheet", new MockValueBinding(application, "#{foo.stylesheet}"));
+        xmlTemplate.encodeBegin(facesContext);
+
+        String responseText = mockWriter.toString();
+        assertEquals("Unexpected response text from content transformation", EXPECTED_TEXT, responseText);
+    }
+
+    public void testStylesheetLocation() throws IOException
+    {
+        xmlTemplate.setContent(content);
+        xmlTemplate.setStylesheetLocation(stylesheetLocation);
+        xmlTemplate.encodeBegin(facesContext);
+
+        String responseText = mockWriter.toString();
+        assertEquals("Unexpected response text from content transformation", EXPECTED_TEXT, responseText);
+    }
+
+    public void testStylesheetLocationValueBinding() throws IOException
+    {
+        xmlTemplate.setContent(content);
+        xmlTemplate.setValueBinding("stylesheetLocation", new MockValueBinding(application, "#{foo.stylesheetLocation}"));
+        xmlTemplate.encodeBegin(facesContext);
+
+        String responseText = mockWriter.toString();
+        assertEquals("Unexpected response text from content transformation", EXPECTED_TEXT, responseText);
+    }
+
+    public void testStylesheetStream() throws IOException
+    {
+        xmlTemplate.setStyleStream(styleStream);
+        xmlTemplate.setContent(content);
+        xmlTemplate.encodeBegin(facesContext);
+
+        String responseText = mockWriter.toString();
+        assertEquals("Unexpected response text from content transformation", EXPECTED_TEXT, responseText);
+    }
+
+    public void testStylesheetStreamValueBinding() throws IOException
+    {
+        xmlTemplate.setValueBinding("styleStream", new MockValueBinding(application, "#{foo.styleStream}"));
+        xmlTemplate.setContent(content);
+        xmlTemplate.encodeBegin(facesContext);
+
+        String responseText = mockWriter.toString();
+        assertEquals("Unexpected response text from content transformation", EXPECTED_TEXT, responseText);
+    }
+
+    public void testContent() throws IOException
+    {
+        xmlTemplate.setContent(content);
+        xmlTemplate.setStylesheet(stylesheet);
+        xmlTemplate.encodeBegin(facesContext);
+
+        String responseText = mockWriter.toString();
+        assertEquals("Unexpected response text from content transformation", EXPECTED_TEXT, responseText);
+    }
+
+    public void testContentValueBinding() throws IOException
+    {
+        xmlTemplate.setValueBinding("content", new MockValueBinding(application, "#{foo.content}"));
+        xmlTemplate.setStylesheet(stylesheet);
+        xmlTemplate.encodeBegin(facesContext);
+
+        String responseText = mockWriter.toString();
+        assertEquals("Unexpected response text from content transformation", EXPECTED_TEXT, responseText);
+    }
+
+    public void testContentLocation() throws IOException
+    {
+        xmlTemplate.setContentLocation(contentLocation);
+        xmlTemplate.setStylesheet(stylesheet);
+        xmlTemplate.encodeBegin(facesContext);
+
+        String responseText = mockWriter.toString();
+        assertEquals("Unexpected response text from content transformation", EXPECTED_TEXT, responseText);
+    }
+
+    public void testContentLocationValueBinding() throws IOException
+    {
+        xmlTemplate.setValueBinding("contentLocation", new MockValueBinding(application, "#{foo.contentLocation}"));
+        xmlTemplate.setStylesheet(stylesheet);
+        xmlTemplate.encodeBegin(facesContext);
+
+        String responseText = mockWriter.toString();
+        assertEquals("Unexpected response text from content transformation", EXPECTED_TEXT, responseText);
+    }
+
+    /**
+     * Tests the actual transformation process using an InputStream as the source for content.
+     * @throws IOException
+     */
+    public void testContentStream() throws IOException
+    {
+        xmlTemplate.setContentStream(contentStream);
+        xmlTemplate.setStylesheet(stylesheet);
+        xmlTemplate.encodeBegin(facesContext);
+
+        String responseText = mockWriter.toString();
+        assertEquals("Unexpected response text from content transformation", EXPECTED_TEXT, responseText);
+    }
+
+    /**
+     * Tests the actual transformation process using an InputStream as the source for content.  This test
+     * sets the property to a value binding (as you would through use of XmlTemplateTag) instead of setting
+     * the value of the contentStream on the component directly.
+     *
+     * @throws IOException
+     */
+    public void testContentStreamValueBinding() throws IOException
+    {
+        xmlTemplate.setValueBinding("contentStream", new MockValueBinding(application, "#{foo.contentStream}"));
+        xmlTemplate.setStylesheetLocation(stylesheetLocation);
+        xmlTemplate.encodeBegin(facesContext);
+
+        String responseText = mockWriter.toString();
+        assertEquals("Unexpected response text from content transformation", EXPECTED_TEXT, responseText);
+    }
+
+    public static Test suite()
+    {
+        return new TestSuite(XmlTemplateTest.class);
+    }
+
+}

Added: myfaces/tomahawk/trunk/sandbox/core/src/test/resources/pets.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/test/resources/pets.xml?rev=413711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/test/resources/pets.xml (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/test/resources/pets.xml Mon Jun 12 10:20:35 2006
@@ -0,0 +1,5 @@
+<item>
+	<number>1000203</number>
+	<name>Iguana</name>
+	<price>$100.20</price>
+</item>
\ No newline at end of file

Added: myfaces/tomahawk/trunk/sandbox/core/src/test/resources/pets.xsl
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/test/resources/pets.xsl?rev=413711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/test/resources/pets.xsl (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/test/resources/pets.xsl Mon Jun 12 10:20:35 2006
@@ -0,0 +1,15 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+     version="1.0">
+
+	<xsl:output method="text" omit-xml-declaration="yes"/> 
+	<xsl:strip-space elements="*"/>
+
+   <xsl:template match="item">
+     <xsl:apply-templates select="name"/>
+   </xsl:template>
+
+   <xsl:template match="name">
+     <xsl:value-of select="text()"/>
+   </xsl:template>
+
+ </xsl:stylesheet>
\ No newline at end of file

Added: myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/template/TemplateBacker.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/template/TemplateBacker.java?rev=413711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/template/TemplateBacker.java (added)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/template/TemplateBacker.java Mon Jun 12 10:20:35 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 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.
+ */
+
+package org.apache.myfaces.examples.template;
+
+import java.net.URL;
+import java.io.File;
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+/**
+ * Backing bean for template examples.  Used to demonstrate how you can provide both the
+ * content and the stylesheet using value bindings.
+ *
+ * @author Sean Schofield
+ */
+public class TemplateBacker
+{
+    private ClassLoader loader = Thread.currentThread().getContextClassLoader();
+
+    public TemplateBacker()
+    {
+        if (loader == null)
+        {
+            loader = TemplateBacker.class.getClassLoader();
+        }
+    }
+
+    public InputStream getContentStream() throws IOException
+    {
+        URL url = loader.getResource("org/apache/myfaces/examples/template/foo.xml");
+        return new FileInputStream(new File(url.getFile()));
+    }
+
+    public InputStream getStyleStream() throws IOException
+    {
+        URL url = loader.getResource("org/apache/myfaces/examples/template/foo.xsl");
+        return new FileInputStream(new File(url.getFile()));
+    }
+}

Added: myfaces/tomahawk/trunk/sandbox/examples/src/main/resources/org/apache/myfaces/examples/template/foo.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/resources/org/apache/myfaces/examples/template/foo.xml?rev=413711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/resources/org/apache/myfaces/examples/template/foo.xml (added)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/resources/org/apache/myfaces/examples/template/foo.xml Mon Jun 12 10:20:35 2006
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+
+<!--
+/*
+ * Copyright 2006 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.
+ */
+//-->
+
+<doc>Hello</doc>
\ No newline at end of file

Added: myfaces/tomahawk/trunk/sandbox/examples/src/main/resources/org/apache/myfaces/examples/template/foo.xsl
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/resources/org/apache/myfaces/examples/template/foo.xsl?rev=413711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/resources/org/apache/myfaces/examples/template/foo.xsl (added)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/resources/org/apache/myfaces/examples/template/foo.xsl Mon Jun 12 10:20:35 2006
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+
+<!--
+/*
+ * Copyright 2006 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.
+ */
+//-->
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+  <xsl:template match="doc">
+    <out><xsl:value-of select="."/></out>
+  </xsl:template>
+</xsl:stylesheet>

Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/examples-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/examples-config.xml?rev=413711&r1=413710&r2=413711&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/examples-config.xml (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/examples-config.xml Mon Jun 12 10:20:35 2006
@@ -439,7 +439,14 @@
     	<managed-bean-class>org.apache.myfaces.examples.NumberHolder</managed-bean-class>
     	<managed-bean-scope>request</managed-bean-scope>
     </managed-bean>
-    
+
+    <!-- XMLTemplate -->
+    <managed-bean>
+    	<managed-bean-name>templateBacker</managed-bean-name>
+    	<managed-bean-class>org.apache.myfaces.examples.template.TemplateBacker</managed-bean-class>
+    	<managed-bean-scope>request</managed-bean-scope>
+    </managed-bean>
+
     <!-- navigation rules -->
     <navigation-rule>
 		<navigation-case>

Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp?rev=413711&r1=413710&r2=413711&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp Mon Jun 12 10:20:35 2006
@@ -10,7 +10,6 @@
     <f:view>
 
         <f:loadBundle basename="org.apache.myfaces.examples.resource.build" var="buildInfo"/>
-
     <h:form>
 
         <h:panelGrid>
@@ -101,7 +100,12 @@
             <h:panelGrid style="padding-left:25px">
            		<h:outputLink value="conversation/index.jsf" ><f:verbatim>Conversation Tag examples</f:verbatim></h:outputLink>
             </h:panelGrid>
-            
+
+            <h:outputText value="XML Template"/>
+            <h:panelGrid style="padding-left:25px">
+           		<h:outputLink value="template/index.jsf" ><f:verbatim>XML Template examples</f:verbatim></h:outputLink>
+            </h:panelGrid>
+
         </h:panelGrid>
     </h:form>
     </f:view>

Added: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/template/index.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/template/index.jsp?rev=413711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/template/index.jsp (added)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/template/index.jsp Mon Jun 12 10:20:35 2006
@@ -0,0 +1,49 @@
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://myfaces.apache.org/sandbox" prefix="s"%>
+
+<!--
+/*
+ * Copyright 2006 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.
+ */
+//-->
+
+<html>
+
+	<%@include file="../inc/head.inc" %>
+
+	<body>
+        <f:view>
+            <h:outputText value="Example 1: Source and Style Using Location"/>
+            <br/>
+            <s:xmlTemplate   rendered="true"
+                            contentLocation="org/apache/myfaces/examples/template/foo.xml"
+                            stylesheetLocation="org/apache/myfaces/examples/template/foo.xsl"/>
+
+            <br/><br/>
+
+            <h:outputText value="Example 2: Source and Style Using Streams and Value Binding"/>
+            <br/>
+            <s:xmlTemplate   rendered="true"
+                             contentStream="#{templateBacker.contentStream}"
+                             styleStream="#{templateBacker.styleStream}"/>
+
+           <h:messages/>
+		</f:view>
+	</body>
+
+	<%@include file="../inc/page_footer.jsp" %>
+
+</html>
\ No newline at end of file