myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1087575 [1/2] - in /myfaces/core/branches/2.1.x/impl/src: main/java/org/apache/myfaces/config/ main/java/org/apache/myfaces/config/element/ main/java/org/apache/myfaces/config/impl/digester/ main/java/org/apache/myfaces/config/impl/digeste...
Date Fri, 01 Apr 2011 03:59:35 GMT
Author: lu4242
Date: Fri Apr  1 03:59:34 2011
New Revision: 1087575

URL: http://svn.apache.org/viewvc?rev=1087575&view=rev
Log:
MYFACES-3098 Add support for view.xml handling and facelets-processing element

Added:
    myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/element/FaceletsProcessing.java
    myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/element/FacesConfigExtension.java
    myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FaceletsProcessing.java
    myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfigExtension.java
    myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/FaceletsProcessingInstructions.java
    myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/LiteralNonExcapedTextInstruction.java
    myfaces/core/branches/2.1.x/impl/src/main/resources/org/apache/myfaces/resource/web-facesconfig_2_1.xsd
    myfaces/core/branches/2.1.x/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/JSPXFaceletsProcessingTestCase.java
    myfaces/core/branches/2.1.x/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/XHTMLFaceletsProcessingTestCase.java
    myfaces/core/branches/2.1.x/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/XMLFaceletsProcessingTestCase.java
    myfaces/core/branches/2.1.x/impl/src/test/resources/org/apache/myfaces/view/facelets/compiler/testJSPXProcessing1.jspx
    myfaces/core/branches/2.1.x/impl/src/test/resources/org/apache/myfaces/view/facelets/compiler/testXHTMLProcessing1.xhtml
    myfaces/core/branches/2.1.x/impl/src/test/resources/org/apache/myfaces/view/facelets/compiler/testXMLProcessing1.view.xml
Modified:
    myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/ConfigFilesXmlValidationUtils.java
    myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java
    myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
    myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java
    myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/element/FacesConfig.java
    myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/element/FacesConfigData.java
    myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java
    myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java
    myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfig.java
    myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
    myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CompilationManager.java
    myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/Compiler.java
    myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/SAXCompiler.java
    myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TextUnit.java
    myfaces/core/branches/2.1.x/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletTestCase.java

Modified: myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/ConfigFilesXmlValidationUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/ConfigFilesXmlValidationUtils.java?rev=1087575&r1=1087574&r2=1087575&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/ConfigFilesXmlValidationUtils.java (original)
+++ myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/ConfigFilesXmlValidationUtils.java Fri Apr  1 03:59:34 2011
@@ -53,6 +53,7 @@ public class ConfigFilesXmlValidationUti
 
     private final static String FACES_CONFIG_SCHEMA_PATH_12 = "org/apache/myfaces/resource/web-facesconfig_1_2.xsd";
     private final static String FACES_CONFIG_SCHEMA_PATH_20 = "org/apache/myfaces/resource/web-facesconfig_2_0.xsd";
+    private final static String FACES_CONFIG_SCHEMA_PATH_21 = "org/apache/myfaces/resource/web-facesconfig_2_0.xsd";
     private final static String FACES_TAGLIB_SCHEMA_PATH = "org/apache/myfaces/resource/web-facelettaglibrary_2_0.xsd";
 
     public static class LSInputImpl implements LSInput
@@ -225,7 +226,7 @@ public class ConfigFilesXmlValidationUti
 
     private static Source getFacesConfigSchemaFileAsSource(ExternalContext externalContext, String version)
     {
-        String xmlSchema = "1.2".equals(version) ? FACES_CONFIG_SCHEMA_PATH_12 : FACES_CONFIG_SCHEMA_PATH_20; 
+        String xmlSchema = "1.2".equals(version) ? FACES_CONFIG_SCHEMA_PATH_12 : ("2.0".equals(version) ? FACES_CONFIG_SCHEMA_PATH_20 : FACES_CONFIG_SCHEMA_PATH_21) ; 
         
         InputStream stream = ClassUtils.getResourceAsStream(xmlSchema);
         
@@ -276,8 +277,8 @@ public class ConfigFilesXmlValidationUti
                 // This is as a result of our aborted parse, so ignore.
             }
 
-            result = handler.isVersion20OrLater() ? "2.0" : (handler
-                    .isVersion12() ? "1.2" : "1.1");
+            result = handler.isVersion21OrLater() ? "2.1" : (handler.isVersion20() ? "2.0" : (handler
+                    .isVersion12() ? "1.2" : "1.1"));
         }
 
         catch (Throwable e)
@@ -306,16 +307,22 @@ public class ConfigFilesXmlValidationUti
     private static class FacesConfigVersionCheckHandler extends DefaultHandler
     {
         private boolean version12;
-        private boolean version20OrLater;
+        private boolean version20;
+        private boolean version21OrLater;
 
         public boolean isVersion12()
         {
             return this.version12;
         }
 
-        public boolean isVersion20OrLater()
+        public boolean isVersion20()
         {
-            return this.version20OrLater;
+            return this.version20 || this.version21OrLater;
+        }
+        
+        public boolean isVersion21OrLater()
+        {
+            return version21OrLater;
         }
 
         @Override
@@ -337,11 +344,19 @@ public class ConfigFilesXmlValidationUti
                         if (attributes.getValue(i).equals("1.2"))
                         {
                             this.version12 = true;
-                            this.version20OrLater = false;
+                            this.version20 = false;
+                            this.version21OrLater = false;
+                        }
+                        else if (attributes.getValue(i).equals("2.0"))
+                        {
+                            this.version21OrLater = false;
+                            this.version20 = true;
+                            this.version12 = false;
                         }
                         else
                         {
-                            this.version20OrLater = true;
+                            this.version21OrLater = true;
+                            this.version20 = false;
                             this.version12 = false;
                         }
                     }

Modified: myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java?rev=1087575&r1=1087574&r2=1087575&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java (original)
+++ myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java Fri Apr  1 03:59:34 2011
@@ -392,7 +392,7 @@ public class DefaultFacesConfigurationPr
     private void validateFacesConfig(ExternalContext ectx, URL url) throws IOException, SAXException
     {
         String version = ConfigFilesXmlValidationUtils.getFacesConfigVersion(url);
-        if ("1.2".equals(version) || "2.0".equals(version))
+        if ("1.2".equals(version) || "2.0".equals(version) || "2.1".equals(version))
         {
             ConfigFilesXmlValidationUtils.validateFacesConfigFile(url, ectx, version);
         }

Modified: myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java?rev=1087575&r1=1087574&r2=1087575&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java (original)
+++ myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java Fri Apr  1 03:59:34 2011
@@ -26,6 +26,7 @@ import org.apache.myfaces.config.annotat
 import org.apache.myfaces.config.annotation.LifecycleProviderFactory;
 import org.apache.myfaces.config.element.Behavior;
 import org.apache.myfaces.config.element.ClientBehaviorRenderer;
+import org.apache.myfaces.config.element.FaceletsProcessing;
 import org.apache.myfaces.config.element.FacesConfig;
 import org.apache.myfaces.config.element.FacesConfigData;
 import org.apache.myfaces.config.element.ManagedBean;
@@ -899,6 +900,11 @@ public class FacesConfigurator
                 log.log(Level.SEVERE, "Named event could not be initialized, reason:",e);
             }
         }
+        
+        for (FaceletsProcessing faceletsProcessing : dispenser.getFaceletsProcessing())
+        {
+            runtimeConfig.addFaceletProcessingConfiguration(faceletsProcessing.getFileExtension(), faceletsProcessing);
+        }
     }
 
     private void removePurgedBeansFromSessionAndApplication(RuntimeConfig runtimeConfig)

Modified: myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java?rev=1087575&r1=1087574&r2=1087575&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java (original)
+++ myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/RuntimeConfig.java Fri Apr  1 03:59:34 2011
@@ -34,6 +34,7 @@ import javax.faces.context.ExternalConte
 import javax.faces.el.PropertyResolver;
 import javax.faces.el.VariableResolver;
 
+import org.apache.myfaces.config.element.FaceletsProcessing;
 import org.apache.myfaces.config.element.ManagedBean;
 import org.apache.myfaces.config.element.NavigationRule;
 import org.apache.myfaces.config.element.ResourceBundle;
@@ -78,6 +79,9 @@ public class RuntimeConfig
         new ConcurrentHashMap<String, org.apache.myfaces.config.element.Converter>();
     
     private NamedEventManager _namedEventManager;
+    
+    private final Map<String, FaceletsProcessing> _faceletsProcessingByFileExtension =
+        new HashMap<String, FaceletsProcessing>();
 
     public static RuntimeConfig getCurrentInstance(ExternalContext externalContext)
     {
@@ -326,4 +330,23 @@ public class RuntimeConfig
     {
         this._namedEventManager = namedEventManager;
     }
+    
+    public void addFaceletProcessingConfiguration(String fileExtension, FaceletsProcessing configuration)
+    {
+        checkNull(fileExtension, "fileExtension");
+        checkEmpty(fileExtension, "fileExtension");
+        checkNull(configuration, "configuration");
+
+        this._faceletsProcessingByFileExtension.put(fileExtension, configuration);
+    }
+    
+    public FaceletsProcessing getFaceletProcessingConfiguration(String fileExtensions)
+    {
+        return _faceletsProcessingByFileExtension.get(fileExtensions);
+    }
+    
+    public Collection<FaceletsProcessing> getFaceletProcessingConfigurations()
+    {
+        return _faceletsProcessingByFileExtension.values();
+    }
 }

Added: myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/element/FaceletsProcessing.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/element/FaceletsProcessing.java?rev=1087575&view=auto
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/element/FaceletsProcessing.java (added)
+++ myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/element/FaceletsProcessing.java Fri Apr  1 03:59:34 2011
@@ -0,0 +1,37 @@
+/*
+ * 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.myfaces.config.element;
+
+import java.io.Serializable;
+
+/**
+ * 
+ * @author Leonardo Uribe
+ * @since 2.1.0
+ */
+public abstract class FaceletsProcessing implements Serializable
+{
+    public static final String PROCESS_AS_XHTML = "xhtml";
+    public static final String PROCESS_AS_XML = "xml";
+    public static final String PROCESS_AS_JSPX = "jspx";
+    
+    public abstract String getFileExtension();
+    
+    public abstract String getProcessAs();
+}

Modified: myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/element/FacesConfig.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/element/FacesConfig.java?rev=1087575&r1=1087574&r2=1087575&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/element/FacesConfig.java (original)
+++ myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/element/FacesConfig.java Fri Apr  1 03:59:34 2011
@@ -19,6 +19,7 @@
 package org.apache.myfaces.config.element;
 
 import java.io.Serializable;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
@@ -60,4 +61,13 @@ public abstract class FacesConfig implem
     public abstract String getMetadataComplete();
 
     public abstract String getVersion ();
+    
+    /**
+     * 
+     * @since 2.1.0
+     */
+    public List<FacesConfigExtension> getFacesConfigExtensions()
+    {
+        return Collections.emptyList();
+    }
 }

Modified: myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/element/FacesConfigData.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/element/FacesConfigData.java?rev=1087575&r1=1087574&r2=1087575&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/element/FacesConfigData.java (original)
+++ myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/element/FacesConfigData.java Fri Apr  1 03:59:34 2011
@@ -20,6 +20,7 @@ package org.apache.myfaces.config.elemen
 
 import java.io.Serializable;
 import java.util.Collection;
+import java.util.Collections;
 
 import javax.el.ELResolver;
 
@@ -209,4 +210,13 @@ public abstract class FacesConfigData im
      */
     public abstract Collection<NamedEvent> getNamedEvents();
 
+    /**
+     * 
+     * @since 2.1.0
+     */
+    public Collection<FaceletsProcessing> getFaceletsProcessing()
+    {
+        return Collections.emptyList();
+    }
+
 }

Added: myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/element/FacesConfigExtension.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/element/FacesConfigExtension.java?rev=1087575&view=auto
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/element/FacesConfigExtension.java (added)
+++ myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/element/FacesConfigExtension.java Fri Apr  1 03:59:34 2011
@@ -0,0 +1,32 @@
+/*
+ * 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.myfaces.config.element;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 
+ * @author Leonardo Uribe
+ * @since 2.1.0
+ */
+public abstract class FacesConfigExtension implements Serializable
+{
+    public abstract List<FaceletsProcessing> getFaceletsProcessingList();
+}

Modified: myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java?rev=1087575&r1=1087574&r2=1087575&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java (original)
+++ myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java Fri Apr  1 03:59:34 2011
@@ -31,6 +31,8 @@ import javax.faces.render.RenderKitFacto
 import org.apache.myfaces.config.FacesConfigDispenser;
 import org.apache.myfaces.config.element.Behavior;
 import org.apache.myfaces.config.element.ClientBehaviorRenderer;
+import org.apache.myfaces.config.element.FaceletsProcessing;
+import org.apache.myfaces.config.element.FacesConfigExtension;
 import org.apache.myfaces.config.element.ManagedBean;
 import org.apache.myfaces.config.element.NavigationRule;
 import org.apache.myfaces.config.element.Renderer;
@@ -102,6 +104,8 @@ public class DigesterFacesConfigDispense
     
     private List<NamedEvent> namedEvents = new ArrayList<NamedEvent>();
     
+    private Map<String, FaceletsProcessing> faceletsProcessingByFileExtension = new HashMap<String, FaceletsProcessing>();
+    
     /**
      * Add another unmarshalled faces config object.
      * 
@@ -220,6 +224,17 @@ public class DigesterFacesConfigDispense
             }
         }
 
+        for (FacesConfigExtension extension : config.getFacesConfigExtensions())
+        {
+            for (FaceletsProcessing faceletsProcessing : extension.getFaceletsProcessingList())
+            {
+                if (faceletsProcessing.getFileExtension() != null && faceletsProcessing.getFileExtension().length() > 0)
+                {
+                    faceletsProcessingByFileExtension.put(faceletsProcessing.getFileExtension(), faceletsProcessing);
+                }
+            }
+        }
+
         lifecyclePhaseListeners.addAll(config.getLifecyclePhaseListener());
         managedBeans.addAll(config.getManagedBeans());
         navigationRules.addAll(config.getNavigationRules());
@@ -641,4 +656,14 @@ public class DigesterFacesConfigDispense
     {
         return namedEvents;
     }
+    
+    public Collection<FaceletsProcessing> getFaceletsProcessing()
+    {
+        return faceletsProcessingByFileExtension.values();
+    }
+
+    public FaceletsProcessing getFaceletsProcessingConfiguration(String fileExtension)
+    {
+        return faceletsProcessingByFileExtension.get(fileExtension);
+    }
 }

Modified: myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java?rev=1087575&r1=1087574&r2=1087575&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java (original)
+++ myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java Fri Apr  1 03:59:34 2011
@@ -278,6 +278,16 @@ public class DigesterFacesConfigUnmarsha
         digester.addCallMethod("faces-config/validator", "addValidator", 2);
         digester.addCallParam("faces-config/validator/validator-id", 0);
         digester.addCallParam("faces-config/validator/validator-class", 1);
+        
+        // 2.1 facelets-processing start
+        digester.addObjectCreate("faces-config/faces-config-extension", FacesConfigExtension.class);
+        digester.addSetNext("faces-config/faces-config-extension", "addFacesConfigExtension");
+        digester.addObjectCreate("faces-config/faces-config-extension/facelets-processing", FaceletsProcessing.class);
+        digester.addSetNext("faces-config/faces-config-extension/facelets-processing", "addFaceletsProcessing");
+        digester.addCallMethod("faces-config/faces-config-extension/facelets-processing/file-extension", "setFileExtension", 0);
+        digester.addCallMethod("faces-config/faces-config-extension/facelets-processing/process-as", "setProcessAs", 0);
+
+        // 2.1 facelets-processing end
     }
 
     public FacesConfig getFacesConfig(InputStream in, String systemId) throws IOException, SAXException

Added: myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FaceletsProcessing.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FaceletsProcessing.java?rev=1087575&view=auto
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FaceletsProcessing.java (added)
+++ myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FaceletsProcessing.java Fri Apr  1 03:59:34 2011
@@ -0,0 +1,56 @@
+/*
+ * 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.myfaces.config.impl.digester.elements;
+
+/**
+ * 
+ * @author Leonardo Uribe
+ * @since 2.1.0
+ */
+public class FaceletsProcessing extends org.apache.myfaces.config.element.FaceletsProcessing 
+{
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 7692451499973040255L;
+
+    private String fileExtension;
+    
+    private String processAs;
+
+    public String getFileExtension()
+    {
+        return fileExtension;
+    }
+
+    public String getProcessAs()
+    {
+        return processAs;
+    }
+
+    public void setFileExtension(String fileExtension)
+    {
+        this.fileExtension = fileExtension;
+    }
+
+    public void setProcessAs(String processAs)
+    {
+        this.processAs = processAs;
+    }
+}

Modified: myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfig.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfig.java?rev=1087575&r1=1087574&r2=1087575&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfig.java (original)
+++ myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfig.java Fri Apr  1 03:59:34 2011
@@ -41,6 +41,7 @@ public class FacesConfig extends org.apa
     private Map<String, String> validators = new HashMap<String, String>();
     private List<org.apache.myfaces.config.element.Behavior> behaviors = new ArrayList<org.apache.myfaces.config.element.Behavior>();
     private List<org.apache.myfaces.config.element.NamedEvent> namedEvents = new ArrayList<org.apache.myfaces.config.element.NamedEvent>();
+    private List<org.apache.myfaces.config.element.FacesConfigExtension> facesConfigExtensions = new ArrayList<org.apache.myfaces.config.element.FacesConfigExtension>();
     
     private String metadataComplete;
     private String version;
@@ -226,4 +227,16 @@ public class FacesConfig extends org.apa
     {
         this.version = version;
     }
+
+    @Override
+    public List<org.apache.myfaces.config.element.FacesConfigExtension> getFacesConfigExtensions()
+    {
+        return facesConfigExtensions;
+    }
+    
+    public void addFacesConfigExtension(org.apache.myfaces.config.element.FacesConfigExtension elem)
+    {
+        facesConfigExtensions.add(elem);
+    }
+    
 }

Added: myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfigExtension.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfigExtension.java?rev=1087575&view=auto
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfigExtension.java (added)
+++ myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfigExtension.java Fri Apr  1 03:59:34 2011
@@ -0,0 +1,49 @@
+/*
+ * 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.myfaces.config.impl.digester.elements;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 
+ * @author Leonardo Uribe
+ * @since 2.1.0
+ */
+public class FacesConfigExtension extends org.apache.myfaces.config.element.FacesConfigExtension
+{
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 7624583794474223864L;
+    
+    private List<org.apache.myfaces.config.element.FaceletsProcessing> _faceletsProcessingList = 
+        new ArrayList<org.apache.myfaces.config.element.FaceletsProcessing>();
+
+    @Override
+    public List<org.apache.myfaces.config.element.FaceletsProcessing> getFaceletsProcessingList()
+    {
+        return _faceletsProcessingList;
+    }
+    
+    public void addFaceletsProcessing(org.apache.myfaces.config.element.FaceletsProcessing elem)
+    {
+        _faceletsProcessingList.add(elem);
+    }
+}

Modified: myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java?rev=1087575&r1=1087574&r2=1087575&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java (original)
+++ myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java Fri Apr  1 03:59:34 2011
@@ -1636,6 +1636,10 @@ public class FaceletViewDeclarationLangu
         loadLibraries(context, compiler);
         loadDecorators(context, compiler);
         loadOptions(context, compiler);
+        
+        compiler.setFaceletsProcessingConfigurations(
+                RuntimeConfig.getCurrentInstance(
+                        context.getExternalContext()).getFaceletProcessingConfigurations()); 
 
         return compiler;
     }
@@ -1767,6 +1771,9 @@ public class FaceletViewDeclarationLangu
     @Deprecated
     protected String getRenderedViewId(FacesContext context, String actionId)
     {
+        // The previous code comes from Facelets 1.1.x but now it becomes invalid. In JSF 2.1, it is possible
+        // to have multiple file extensions, and to make work correctly viewExists(), it is necessary to return
+        // the viewId without changes
         return actionId;
     }
 

Modified: myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CompilationManager.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CompilationManager.java?rev=1087575&r1=1087574&r2=1087575&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CompilationManager.java (original)
+++ myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CompilationManager.java Fri Apr  1 03:59:34 2011
@@ -71,8 +71,10 @@ final class CompilationManager
     private final String alias;
     
     private CompilationUnit interfaceCompilationUnit;
+    
+    private final FaceletsProcessingInstructions faceletsProcessingInstructions;
 
-    public CompilationManager(String alias, Compiler compiler)
+    public CompilationManager(String alias, Compiler compiler, FaceletsProcessingInstructions instructions)
     {
 
         // this is our alias
@@ -97,6 +99,7 @@ final class CompilationManager
         this.units.push(new CompilationUnit());
         
         this.interfaceCompilationUnit = null; 
+        this.faceletsProcessingInstructions = instructions;
     }
 
     public void writeInstruction(String value)
@@ -119,7 +122,7 @@ final class CompilationManager
         }
         else
         {
-            unit = new TextUnit(this.alias, this.nextTagId());
+            unit = new TextUnit(this.alias, this.nextTagId(), faceletsProcessingInstructions.isEscapeInlineText());
             this.startUnit(unit);
         }
         unit.writeInstruction(value);
@@ -146,7 +149,7 @@ final class CompilationManager
         }
         else
         {
-            unit = new TextUnit(this.alias, this.nextTagId());
+            unit = new TextUnit(this.alias, this.nextTagId(), faceletsProcessingInstructions.isEscapeInlineText());
             this.startUnit(unit);
         }
         unit.write(value);
@@ -175,7 +178,7 @@ final class CompilationManager
         }
         else
         {
-            unit = new TextUnit(this.alias, this.nextTagId());
+            unit = new TextUnit(this.alias, this.nextTagId(), faceletsProcessingInstructions.isEscapeInlineText());
             this.startUnit(unit);
         }
 
@@ -285,7 +288,7 @@ final class CompilationManager
             }
             else
             {
-                unit = new TextUnit(this.alias, this.nextTagId());
+                unit = new TextUnit(this.alias, this.nextTagId(), faceletsProcessingInstructions.isEscapeInlineText());
                 this.startUnit(unit);
             }
             unit.startTag(t);
@@ -522,4 +525,14 @@ final class CompilationManager
                            new TagAttributesImpl(attr));
         }
     }
+
+    /**
+     * 
+     * @since 2.1.0
+     * @return
+     */
+    public FaceletsProcessingInstructions getFaceletsProcessingInstructions()
+    {
+        return faceletsProcessingInstructions;
+    }
 }

Modified: myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/Compiler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/Compiler.java?rev=1087575&r1=1087574&r2=1087575&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/Compiler.java (original)
+++ myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/Compiler.java Fri Apr  1 03:59:34 2011
@@ -21,6 +21,7 @@ package org.apache.myfaces.view.facelets
 import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -35,6 +36,7 @@ import javax.faces.view.facelets.Facelet
 import javax.faces.view.facelets.FaceletHandler;
 import javax.faces.view.facelets.TagDecorator;
 
+import org.apache.myfaces.config.element.FaceletsProcessing;
 import org.apache.myfaces.view.facelets.tag.CompositeTagDecorator;
 import org.apache.myfaces.view.facelets.tag.CompositeTagLibrary;
 import org.apache.myfaces.view.facelets.tag.TagLibrary;
@@ -73,6 +75,8 @@ public abstract class Compiler
     private final Map<String, String> features = new HashMap<String, String>();
 
     private boolean initialized = false;
+    
+    private Collection<FaceletsProcessing> faceletsProcessingConfigurations;
 
     /**
      * 
@@ -259,4 +263,25 @@ public abstract class Compiler
     {
         this.validating = validating;
     }
+
+    /**
+     * 
+     * @since 2.1.0
+     * @return
+     */
+    public Collection<FaceletsProcessing> getFaceletsProcessingConfigurations()
+    {
+        return faceletsProcessingConfigurations;
+    }
+
+    /**
+     * 
+     * @since 2.1.0
+     * @return
+     */
+    public void setFaceletsProcessingConfigurations(
+            Collection<FaceletsProcessing> faceletsProcessingConfigurations)
+    {
+        this.faceletsProcessingConfigurations = faceletsProcessingConfigurations;
+    }
 }

Added: myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/FaceletsProcessingInstructions.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/FaceletsProcessingInstructions.java?rev=1087575&view=auto
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/FaceletsProcessingInstructions.java (added)
+++ myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/FaceletsProcessingInstructions.java Fri Apr  1 03:59:34 2011
@@ -0,0 +1,127 @@
+/*
+ * 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.myfaces.view.facelets.compiler;
+
+/**
+ * 
+ * @author Leonardo Uribe
+ * @since 2.1.0
+ */
+public final class FaceletsProcessingInstructions
+{
+    public static final String PROCESS_AS_JSPX = "jspx";
+    public static final String PROCESS_AS_XHTML = "xhtml";
+    public static final String PROCESS_AS_XML = "xml";
+    
+    private static final FaceletsProcessingInstructions processAsXHTML= 
+        new FaceletsProcessingInstructions(
+                false, false, false, false, true, false);
+
+    private static final FaceletsProcessingInstructions processAsXML= 
+        new FaceletsProcessingInstructions(
+                true, true, true, true, true, true);
+
+    private static final FaceletsProcessingInstructions processAsJSPX= 
+        new FaceletsProcessingInstructions(
+                true, true, true, true, false, true);
+
+    private final boolean consumeXmlDocType;
+    
+    private final boolean consumeXmlDeclaration;
+    
+    private final boolean consumeProcessingInstructions;
+    
+    private final boolean consumeCDataSections;
+    
+    private final boolean escapeInlineText;
+    
+    private final boolean consumeXMLComments;
+    
+    public final static FaceletsProcessingInstructions getProcessingInstructions(String processAs)
+    {
+        if (processAs == null)
+        {
+            return processAsXHTML;
+        }
+        else if (PROCESS_AS_XHTML.equals(processAs))
+        {
+            return processAsXHTML;
+        }
+        else if (PROCESS_AS_XML.equals(processAs))
+        {
+            return processAsXML;
+        }
+        else if (PROCESS_AS_JSPX.equals(processAs))
+        {
+            return processAsJSPX;
+        }
+        else
+        {
+            return processAsXHTML;
+        }
+    }
+    
+    public FaceletsProcessingInstructions(
+            boolean consumeXmlDocType,
+            boolean consumeXmlDeclaration,
+            boolean consumeProcessingInstructions,
+            boolean consumeCDataSections, 
+            boolean escapeInlineText,
+            boolean consumeXMLComments)
+    {
+        super();
+        this.consumeXmlDocType = consumeXmlDocType;
+        this.consumeXmlDeclaration = consumeXmlDeclaration;
+        this.consumeProcessingInstructions = consumeProcessingInstructions;
+        this.consumeCDataSections = consumeCDataSections;
+        this.escapeInlineText = escapeInlineText;
+        this.consumeXMLComments = consumeXMLComments;
+    }
+
+    public boolean isConsumeXmlDocType()
+    {
+        return consumeXmlDocType;
+    }
+
+    public boolean isConsumeXmlDeclaration()
+    {
+        return consumeXmlDeclaration;
+    }
+
+    public boolean isConsumeProcessingInstructions()
+    {
+        return consumeProcessingInstructions;
+    }
+
+    public boolean isConsumeCDataSections()
+    {
+        return consumeCDataSections;
+    }
+
+    public boolean isEscapeInlineText()
+    {
+        return escapeInlineText;
+    }
+
+    public boolean isConsumeXMLComments()
+    {
+        return consumeXMLComments;
+    }
+
+}

Added: myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/LiteralNonExcapedTextInstruction.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/LiteralNonExcapedTextInstruction.java?rev=1087575&view=auto
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/LiteralNonExcapedTextInstruction.java (added)
+++ myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/LiteralNonExcapedTextInstruction.java Fri Apr  1 03:59:34 2011
@@ -0,0 +1,55 @@
+/*
+ * 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.myfaces.view.facelets.compiler;
+
+import java.io.IOException;
+
+import javax.el.ELContext;
+import javax.el.ExpressionFactory;
+import javax.faces.context.FacesContext;
+
+/**
+ * 
+ * @author Leonardo Uribe
+ * @since 2.1.0
+ */
+final class LiteralNonExcapedTextInstruction implements Instruction
+{
+    private final String text;
+
+    public LiteralNonExcapedTextInstruction(String text)
+    {
+        this.text = text;
+    }
+
+    public void write(FacesContext context) throws IOException
+    {
+        context.getResponseWriter().write(this.text);
+    }
+
+    public Instruction apply(ExpressionFactory factory, ELContext ctx)
+    {
+        return this;
+    }
+
+    public boolean isLiteral()
+    {
+        return true;
+    }
+}

Modified: myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/SAXCompiler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/SAXCompiler.java?rev=1087575&r1=1087574&r2=1087575&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/SAXCompiler.java (original)
+++ myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/SAXCompiler.java Fri Apr  1 03:59:34 2011
@@ -22,11 +22,13 @@ import java.io.BufferedInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import javax.el.ELException;
 import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
 import javax.faces.view.Location;
 import javax.faces.view.facelets.FaceletException;
 import javax.faces.view.facelets.FaceletHandler;
@@ -37,6 +39,8 @@ import javax.xml.parsers.ParserConfigura
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
+import org.apache.myfaces.config.RuntimeConfig;
+import org.apache.myfaces.config.element.FaceletsProcessing;
 import org.apache.myfaces.shared_impl.util.ClassUtils;
 import org.apache.myfaces.view.facelets.tag.TagAttributeImpl;
 import org.apache.myfaces.view.facelets.tag.TagAttributesImpl;
@@ -77,6 +81,8 @@ public final class SAXCompiler extends C
         private Locator locator;
 
         private final CompilationManager unit;
+        
+        private boolean consumingCDATA = false;
 
         public CompilationHandler(CompilationManager unit, String alias)
         {
@@ -86,7 +92,7 @@ public final class SAXCompiler extends C
 
         public void characters(char[] ch, int start, int length) throws SAXException
         {
-            if (this.inDocument)
+            if (this.inDocument && !consumingCDATA)
             {
                 this.unit.writeText(new String(ch, start, length));
             }
@@ -94,7 +100,7 @@ public final class SAXCompiler extends C
 
         public void comment(char[] ch, int start, int length) throws SAXException
         {
-            if (this.inDocument)
+            if (this.inDocument && !unit.getFaceletsProcessingInstructions().isConsumeXMLComments())
             {
                 this.unit.writeComment(new String(ch, start, length));
             }
@@ -121,7 +127,14 @@ public final class SAXCompiler extends C
         {
             if (this.inDocument)
             {
-                this.unit.writeInstruction("]]>");
+                if (!this.unit.getFaceletsProcessingInstructions().isConsumeCDataSections())
+                {
+                    this.unit.writeInstruction("]]>");
+                }
+                else
+                {
+                    this.consumingCDATA = false;
+                }
             }
         }
 
@@ -189,7 +202,14 @@ public final class SAXCompiler extends C
         {
             if (this.inDocument)
             {
-                this.unit.writeInstruction("<![CDATA[");
+                if (!this.unit.getFaceletsProcessingInstructions().isConsumeCDataSections())
+                {
+                    this.unit.writeInstruction("<![CDATA[");
+                }
+                else
+                {
+                    this.consumingCDATA = true;
+                }
             }
         }
 
@@ -200,7 +220,7 @@ public final class SAXCompiler extends C
 
         public void startDTD(String name, String publicId, String systemId) throws SAXException
         {
-            if (this.inDocument)
+            if (this.inDocument && !unit.getFaceletsProcessingInstructions().isConsumeXmlDocType())
             {
                 StringBuffer sb = new StringBuffer(64);
                 sb.append("<!DOCTYPE ").append(name);
@@ -238,7 +258,7 @@ public final class SAXCompiler extends C
 
         public void processingInstruction(String target, String data) throws SAXException
         {
-            if (this.inDocument)
+            if (this.inDocument && !this.unit.getFaceletsProcessingInstructions().isConsumeProcessingInstructions())
             {
                 StringBuffer sb = new StringBuffer(64);
                 sb.append("<?").append(target).append(' ').append(data).append("?>\n");
@@ -264,6 +284,8 @@ public final class SAXCompiler extends C
         private final CompilationManager unit;
         
         private boolean inMetadata = false;
+        
+        private boolean consumingCDATA = false;
 
         public ViewMetadataHandler(CompilationManager unit, String alias)
         {
@@ -273,7 +295,7 @@ public final class SAXCompiler extends C
 
         public void characters(char[] ch, int start, int length) throws SAXException
         {
-            if (this.inDocument && inMetadata)
+            if (this.inDocument && inMetadata && !consumingCDATA)
             {
                 this.unit.writeText(new String(ch, start, length));
             }
@@ -281,7 +303,7 @@ public final class SAXCompiler extends C
 
         public void comment(char[] ch, int start, int length) throws SAXException
         {
-            if (this.inDocument && inMetadata)
+            if (this.inDocument && inMetadata && !unit.getFaceletsProcessingInstructions().isConsumeXMLComments())
             {
                 this.unit.writeComment(new String(ch, start, length));
             }
@@ -308,7 +330,14 @@ public final class SAXCompiler extends C
         {
             if (this.inDocument && inMetadata)
             {
-                this.unit.writeInstruction("]]>");
+                if (!this.unit.getFaceletsProcessingInstructions().isConsumeCDataSections())
+                {
+                    this.unit.writeInstruction("]]>");
+                }
+                else
+                {
+                    this.consumingCDATA = false;
+                }
             }
         }
 
@@ -383,7 +412,14 @@ public final class SAXCompiler extends C
         {
             if (this.inDocument && inMetadata)
             {
-                this.unit.writeInstruction("<![CDATA[");
+                if (!this.unit.getFaceletsProcessingInstructions().isConsumeCDataSections())
+                {
+                    this.unit.writeInstruction("<![CDATA[");
+                }
+                else
+                {
+                    this.consumingCDATA = true;
+                }
             }
         }
 
@@ -421,7 +457,7 @@ public final class SAXCompiler extends C
 
         public void processingInstruction(String target, String data) throws SAXException
         {
-            if (this.inDocument && inMetadata)
+            if (this.inDocument && inMetadata && !this.unit.getFaceletsProcessingInstructions().isConsumeProcessingInstructions())
             {
                 StringBuffer sb = new StringBuffer(64);
                 sb.append("<?").append(target).append(' ').append(data).append("?>\n");
@@ -453,6 +489,8 @@ public final class SAXCompiler extends C
         
         private boolean inCompositeImplementation = false;
 
+        private boolean consumingCDATA = false;
+
         public CompositeComponentMetadataHandler(CompilationManager unit, String alias)
         {
             this.unit = unit;
@@ -461,7 +499,7 @@ public final class SAXCompiler extends C
 
         public void characters(char[] ch, int start, int length) throws SAXException
         {
-            if (this.inDocument && inCompositeInterface)
+            if (this.inDocument && inCompositeInterface && !consumingCDATA)
             {
                 this.unit.writeText(new String(ch, start, length));
             }
@@ -469,7 +507,7 @@ public final class SAXCompiler extends C
 
         public void comment(char[] ch, int start, int length) throws SAXException
         {
-            if (this.inDocument && inCompositeInterface)
+            if (this.inDocument && inCompositeInterface && !unit.getFaceletsProcessingInstructions().isConsumeXMLComments())
             {
                 this.unit.writeComment(new String(ch, start, length));
             }
@@ -496,7 +534,14 @@ public final class SAXCompiler extends C
         {
             if (this.inDocument && inCompositeInterface)
             {
-                this.unit.writeInstruction("]]>");
+                if (!this.unit.getFaceletsProcessingInstructions().isConsumeCDataSections())
+                {
+                    this.unit.writeInstruction("]]>");
+                }
+                else
+                {
+                    this.consumingCDATA = false;
+                }
             }
         }
 
@@ -589,7 +634,14 @@ public final class SAXCompiler extends C
         {
             if (this.inDocument && inCompositeInterface)
             {
-                this.unit.writeInstruction("<![CDATA[");
+                if (!this.unit.getFaceletsProcessingInstructions().isConsumeCDataSections())
+                {
+                    this.unit.writeInstruction("<![CDATA[");
+                }
+                else
+                {
+                    this.consumingCDATA = true;
+                }
             }
         }
 
@@ -645,7 +697,7 @@ public final class SAXCompiler extends C
 
         public void processingInstruction(String target, String data) throws SAXException
         {
-            if (this.inDocument && inCompositeInterface)
+            if (this.inDocument && inCompositeInterface && !this.unit.getFaceletsProcessingInstructions().isConsumeProcessingInstructions())
             {
                 StringBuffer sb = new StringBuffer(64);
                 sb.append("<?").append(target).append(' ').append(data).append("?>\n");
@@ -668,7 +720,7 @@ public final class SAXCompiler extends C
         try
         {
             is = new BufferedInputStream(src.openStream(), 1024);
-            mngr = new CompilationManager(alias, this);
+            mngr = new CompilationManager(alias, this, getFaceletsProcessingInstructions(src, alias));
             encoding = writeXmlDecl(is, mngr);
             CompilationHandler handler = new CompilationHandler(mngr, alias);
             SAXParser parser = this.createSAXParser(handler);
@@ -705,7 +757,7 @@ public final class SAXCompiler extends C
         try
         {
             is = new BufferedInputStream(src.openStream(), 1024);
-            mngr = new CompilationManager(alias, this);
+            mngr = new CompilationManager(alias, this, getFaceletsProcessingInstructions(src, alias));
             encoding = getXmlDecl(is, mngr);
             ViewMetadataHandler handler = new ViewMetadataHandler(mngr, alias);
             SAXParser parser = this.createSAXParser(handler);
@@ -742,7 +794,7 @@ public final class SAXCompiler extends C
         try
         {
             is = new BufferedInputStream(src.openStream(), 1024);
-            mngr = new CompilationManager(alias, this);
+            mngr = new CompilationManager(alias, this, getFaceletsProcessingInstructions(src, alias));
             encoding = getXmlDecl(is, mngr);
             CompositeComponentMetadataHandler handler = new CompositeComponentMetadataHandler(mngr, alias);
             SAXParser parser = this.createSAXParser(handler);
@@ -765,6 +817,20 @@ public final class SAXCompiler extends C
         }
         return new EncodingHandler(mngr.createFaceletHandler(), encoding);
     }
+    
+    protected FaceletsProcessingInstructions getFaceletsProcessingInstructions(URL src, String alias)
+    {
+        String processAs = null;
+        for (FaceletsProcessing entry : getFaceletsProcessingConfigurations())
+        {
+            if (src.getPath().endsWith(entry.getFileExtension()))
+            {
+                processAs = entry.getProcessAs();
+                break;
+            }
+        }
+        return FaceletsProcessingInstructions.getProcessingInstructions(processAs);
+    }
 
     protected static final String writeXmlDecl(InputStream is, CompilationManager mngr) throws IOException
     {
@@ -779,7 +845,10 @@ public final class SAXCompiler extends C
                 Matcher m = XmlDeclaration.matcher(r);
                 if (m.find())
                 {
-                    mngr.writeInstruction(m.group(0) + "\n");
+                    if (!mngr.getFaceletsProcessingInstructions().isConsumeXmlDeclaration())
+                    {
+                        mngr.writeInstruction(m.group(0) + "\n");
+                    }
                     if (m.group(3) != null)
                     {
                         encoding = m.group(3);

Modified: myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TextUnit.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TextUnit.java?rev=1087575&r1=1087574&r2=1087575&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TextUnit.java (original)
+++ myfaces/core/branches/2.1.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TextUnit.java Fri Apr  1 03:59:34 2011
@@ -56,8 +56,15 @@ final class TextUnit extends Compilation
 
     private final String id;
 
+    private final boolean escapeInlineText;
+
     public TextUnit(String alias, String id)
     {
+        this(alias,id,true);
+    }
+    
+    public TextUnit(String alias, String id, boolean escapeInlineText)
+    {
         this.alias = alias;
         this.id = id;
         this.buffer = new StringBuffer();
@@ -66,6 +73,7 @@ final class TextUnit extends Compilation
         this.tags = new Stack<Tag>();
         this.children = new ArrayList<Object>();
         this.startTagOpen = false;
+        this.escapeInlineText = escapeInlineText;
     }
 
     public FaceletHandler createFaceletHandler()
@@ -121,7 +129,14 @@ final class TextUnit extends Compilation
                 {
                     if (txt.isLiteral())
                     {
-                        this.instructionBuffer.add(new LiteralTextInstruction(txt.toString()));
+                        if (escapeInlineText)
+                        {
+                            this.instructionBuffer.add(new LiteralTextInstruction(txt.toString()));
+                        }
+                        else
+                        {
+                            this.instructionBuffer.add(new LiteralNonExcapedTextInstruction(txt.toString()));
+                        }
                     }
                     else
                     {



Mime
View raw message