You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/04/07 03:43:27 UTC

svn commit: r931402 [1/3] - in /myfaces/core/trunk/impl/src: main/java/org/apache/myfaces/config/ main/java/org/apache/myfaces/view/facelets/compiler/ main/resources/META-INF/ main/resources/org/apache/myfaces/resource/ test/java/org/apache/myfaces/vie...

Author: lu4242
Date: Wed Apr  7 01:43:27 2010
New Revision: 931402

URL: http://svn.apache.org/viewvc?rev=931402&view=rev
Log:
MYFACES-2329 Add Facelet taglib 2.0 schema (Thanks to Ingo Hofmann for provide this patch)

Added:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/ConfigFilesXmlValidationUtils.java
    myfaces/core/trunk/impl/src/main/resources/org/apache/myfaces/resource/XMLSchema.dtd
    myfaces/core/trunk/impl/src/main/resources/org/apache/myfaces/resource/datatypes.dtd
    myfaces/core/trunk/impl/src/main/resources/org/apache/myfaces/resource/javaee_5.xsd
    myfaces/core/trunk/impl/src/main/resources/org/apache/myfaces/resource/javaee_web_services_client_1_2.xsd
    myfaces/core/trunk/impl/src/main/resources/org/apache/myfaces/resource/xml.xsd
    myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/compiler/TagLibraryTestCase.java
    myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/compiler/testlib.taglib.xml
    myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/compiler/testlib_invalid.taglib.xml
    myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/compiler/testlib_old_invalid.taglib.xml
Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TagLibraryConfig.java
    myfaces/core/trunk/impl/src/main/resources/META-INF/faces-config20.vm
    myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletTestCase.java

Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/ConfigFilesXmlValidationUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/ConfigFilesXmlValidationUtils.java?rev=931402&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/ConfigFilesXmlValidationUtils.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/ConfigFilesXmlValidationUtils.java Wed Apr  7 01:43:27 2010
@@ -0,0 +1,507 @@
+/*
+ * 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;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.faces.context.ExternalContext;
+import javax.xml.XMLConstants;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+
+import org.apache.myfaces.shared_impl.util.ClassUtils;
+import org.w3c.dom.ls.LSInput;
+import org.w3c.dom.ls.LSResourceResolver;
+import org.xml.sax.Attributes;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class ConfigFilesXmlValidationUtils
+{
+    public final static LSResourceResolver JAVAEE_5_LS_RESOURCE_RESOLVER = new ValidatorLSResourceResolver();
+    public final static ErrorHandler VALIDATION_ERROR_HANDLER = new ValidationErrorHandler(); 
+
+    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_TAGLIB_SCHEMA_PATH = "org/apache/myfaces/resource/web-facelettaglibrary_2_0.xsd";
+
+    public static class LSInputImpl implements LSInput
+    {
+        private final String _publicId;
+        private final String _systemId;
+        private final String _baseURI;
+        private final InputStream _input;
+        
+        public LSInputImpl(String publicId,
+                String systemId, String baseURI, InputStream input)
+        {
+            super();
+            _publicId = publicId;
+            _systemId = systemId;
+            _baseURI = baseURI;
+            _input = input;
+        }
+
+        public String getBaseURI()
+        {
+            return _baseURI;
+        }
+
+        public InputStream getByteStream()
+        {
+            return _input;
+        }
+
+        public boolean getCertifiedText()
+        {
+            return false;
+        }
+
+        public Reader getCharacterStream()
+        {
+            return null;
+        }
+
+        public String getEncoding()
+        {
+            return null;
+        }
+
+        public String getPublicId()
+        {
+            return _publicId;
+        }
+
+        public String getStringData()
+        {
+            return null;
+        }
+
+        public String getSystemId()
+        {
+            return _systemId;
+        }
+
+        public void setBaseURI(String baseURI)
+        {
+        }
+
+        public void setByteStream(InputStream byteStream)
+        {
+        }
+
+        public void setCertifiedText(boolean certifiedText)
+        {
+        }
+
+        public void setCharacterStream(Reader characterStream)
+        {
+        }
+
+        public void setEncoding(String encoding)
+        {
+        }
+
+        public void setPublicId(String publicId)
+        {
+        }
+
+        public void setStringData(String stringData)
+        {
+        }
+
+        public void setSystemId(String systemId)
+        {
+        }
+    }
+    
+    public static class ValidatorLSResourceResolver implements LSResourceResolver
+    {
+
+        public LSInput resolveResource(String type, String namespaceURI,
+                String publicId, String systemId, String baseURI)
+        {
+            if ("http://www.w3.org/TR/REC-xml".equals(type) && "datatypes.dtd".equals(systemId))
+            {
+                return new LSInputImpl(publicId, systemId, baseURI, ClassUtils.getResourceAsStream("org/apache/myfaces/resource/datatypes.dtd"));
+            }
+            if ("-//W3C//DTD XMLSCHEMA 200102//EN".equals(publicId) && "XMLSchema.dtd".equals(systemId))
+            {
+                return new LSInputImpl(publicId, systemId, baseURI, ClassUtils.getResourceAsStream("org/apache/myfaces/resource/XMLSchema.dtd"));
+            }
+            if ("http://java.sun.com/xml/ns/javaee".equals(namespaceURI))
+            {
+                if ("javaee_5.xsd".equals(systemId))
+                {
+                    return new LSInputImpl(publicId, systemId, baseURI, ClassUtils.getResourceAsStream("org/apache/myfaces/resource/javaee_5.xsd"));
+                }
+                else if ("javaee_web_services_client_1_2.xsd".equals(systemId))
+                {
+                    return new LSInputImpl(publicId, systemId, baseURI, ClassUtils.getResourceAsStream("org/apache/myfaces/resource/javaee_web_services_client_1_2.xsd"));
+                }
+            }
+            if ("http://www.w3.org/XML/1998/namespace".equals(namespaceURI))
+            {
+                return new LSInputImpl(publicId, systemId, baseURI, ClassUtils.getResourceAsStream("org/apache/myfaces/resource/xml.xsd")); 
+            }
+            return null;
+        }
+        
+    } 
+    
+    public static class ValidationErrorHandler implements ErrorHandler
+    {
+        public void fatalError(SAXParseException exception) throws SAXException
+        {
+            throw exception;
+        }
+        
+        public void error(SAXParseException exception) throws SAXException
+        {
+            Logger log = Logger.getLogger(ConfigFilesXmlValidationUtils.class.getName());
+            log.log(Level.SEVERE, exception.getMessage(), exception);
+        }
+
+        public void warning(SAXParseException exception) throws SAXException
+        {
+            Logger log = Logger.getLogger(ConfigFilesXmlValidationUtils.class.getName());
+            log.log(Level.WARNING, exception.getMessage(), exception);
+        }
+    }
+    
+    public static void validateFacesConfigFile(URL xmlFile,
+            ExternalContext externalContext, String version) throws SAXException, IOException
+    {
+        SchemaFactory schemaFactory = SchemaFactory
+                .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+
+        Source schemaFile = getFacesConfigSchemaFileAsSource(externalContext, version);
+        if (schemaFile == null)
+        {
+            throw new IOException("Could not find schema file for validation.");
+        }
+        
+        schemaFactory.setResourceResolver(JAVAEE_5_LS_RESOURCE_RESOLVER);
+        Schema schema = schemaFactory.newSchema(schemaFile);
+
+        Validator validator = schema.newValidator();
+        URLConnection conn = xmlFile.openConnection();
+        conn.setUseCaches(false);
+        InputStream is = conn.getInputStream();
+        Source source = new StreamSource(is);
+        validator.setErrorHandler(VALIDATION_ERROR_HANDLER);
+        validator.validate(source);
+    }
+
+    private static Source getFacesConfigSchemaFileAsSource(ExternalContext externalContext, String version)
+    {
+        String xmlSchema = "1.2".equals(version) ? FACES_CONFIG_SCHEMA_PATH_12 : FACES_CONFIG_SCHEMA_PATH_20; 
+        
+        InputStream stream = ClassUtils.getResourceAsStream(xmlSchema);
+        
+        if (stream == null)
+        {
+           stream = externalContext.getResourceAsStream(xmlSchema);
+        }
+
+        if (stream == null) {
+            return null;
+        }
+        
+        return new StreamSource(stream);
+    }
+
+    public static final String getFacesConfigVersion(URL url)
+    {
+        URLConnection conn = null;
+        InputStream input = null;
+        String result = "2.0";
+
+        try
+        {
+            SAXParserFactory factory = SAXParserFactory.newInstance();
+            SAXParser parser;
+            FacesConfigVersionCheckHandler handler = new FacesConfigVersionCheckHandler();
+
+            // We need to create a non-validating, non-namespace aware parser used to simply check
+            // which version of the facelets taglib document we are dealing with.
+
+            factory.setNamespaceAware(false);
+            factory.setFeature("http://xml.org/sax/features/validation", false);
+            factory.setValidating(false);
+
+            parser = factory.newSAXParser();
+
+            conn = url.openConnection();
+            conn.setUseCaches(false);
+            input = conn.getInputStream();
+
+            try
+            {
+                parser.parse(input, handler);
+            }
+
+            catch (SAXException e)
+            {
+                // This is as a result of our aborted parse, so ignore.
+            }
+
+            result = handler.isVersion20OrLater() ? "2.0" : (handler
+                    .isVersion12() ? "1.2" : "1.1");
+        }
+
+        catch (Throwable e)
+        {
+            // Most likely a result of our aborted parse, so ignore.
+        }
+
+        finally
+        {
+            if (input != null)
+            {
+                try
+                {
+                    input.close();
+                }
+
+                catch (Throwable e)
+                {
+                }
+            }
+        }
+
+        return result;
+    }
+
+    private static class FacesConfigVersionCheckHandler extends DefaultHandler
+    {
+        private boolean version12;
+        private boolean version20OrLater;
+
+        public boolean isVersion12()
+        {
+            return this.version12;
+        }
+
+        public boolean isVersion20OrLater()
+        {
+            return this.version20OrLater;
+        }
+
+        @Override
+        public void startElement(String uri, String localName, String name,
+                Attributes attributes) throws SAXException
+        {
+            if (name.equals("faces-config"))
+            {
+                int length = attributes.getLength();
+
+                for (int i = 0; i < length; i++)
+                {
+                    String attrName = attributes.getLocalName(i);
+                    attrName = (attrName != null) ? ((attrName.length() > 0) ? attrName
+                            : attributes.getQName(i))
+                            : attributes.getQName(i);
+                    if (attrName.equals("version"))
+                    {
+                        if (attributes.getValue(i).equals("1.2"))
+                        {
+                            this.version12 = true;
+                            this.version20OrLater = false;
+                        }
+                        else
+                        {
+                            this.version20OrLater = true;
+                            this.version12 = false;
+                        }
+                    }
+                }
+            }
+        }
+    }
+    
+    public static void validateFaceletTagLibFile(URL xmlFile, ExternalContext externalContext, String version)
+        throws SAXException, IOException, ParserConfigurationException
+    {
+        SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+        
+        Source schemaFile = getFaceletSchemaFileAsSource(externalContext);
+        if (schemaFile == null)
+        {
+            throw new IOException("Could not find schema file for validation.");
+        }
+        schemaFactory.setResourceResolver(ConfigFilesXmlValidationUtils.JAVAEE_5_LS_RESOURCE_RESOLVER);
+        Schema schema = schemaFactory.newSchema(schemaFile);
+    
+        Validator validator = schema.newValidator();
+        URLConnection conn = xmlFile.openConnection();
+        conn.setUseCaches(false);
+        InputStream is = conn.getInputStream();
+        Source source = new StreamSource(is);
+        validator.setErrorHandler(VALIDATION_ERROR_HANDLER);
+        validator.validate(source);
+    }
+    
+    private static Source getFaceletSchemaFileAsSource(ExternalContext externalContext)
+    {
+        InputStream stream = ClassUtils.getResourceAsStream(FACES_TAGLIB_SCHEMA_PATH);
+        
+        if (stream == null)
+        {
+           stream = externalContext.getResourceAsStream(FACES_TAGLIB_SCHEMA_PATH);
+        }
+    
+        if (stream == null) {
+            return null;
+        }
+        
+        return new StreamSource(stream);
+    }
+    
+    public static final String getFaceletTagLibVersion(URL url)
+    {
+        if (isTaglibDocument20OrLater(url))
+        {
+            return "2.0";
+        }
+        else
+        {
+            return "1.0";
+        }
+    }
+
+    private static final boolean isTaglibDocument20OrLater (URL url)
+    {
+        URLConnection conn = null;
+        InputStream input = null;
+        boolean result = false;
+        
+        try
+        {
+            SAXParserFactory factory = SAXParserFactory.newInstance();
+            SAXParser parser;
+            VersionCheckHandler handler = new VersionCheckHandler();
+            
+            // We need to create a non-validating, non-namespace aware parser used to simply check
+            // which version of the facelets taglib document we are dealing with.
+
+            factory.setNamespaceAware(false);
+            factory.setFeature("http://xml.org/sax/features/validation", false);
+            factory.setValidating(false);
+            
+            parser = factory.newSAXParser();
+            
+            conn = url.openConnection();
+            conn.setUseCaches(false);
+            input = conn.getInputStream();
+            
+            try
+            {
+                parser.parse (input, handler);
+            }
+            
+            catch (SAXException e)
+            {
+                // This is as a result of our aborted parse, so ignore.
+            }
+            
+            result = handler.isVersion20OrLater();
+        }
+        
+        catch (Throwable e)
+        {
+            // Most likely a result of our aborted parse, so ignore.
+        }
+        
+        finally
+        {
+            if (input != null)
+            {
+                try
+                {
+                    input.close();
+                }
+                
+                catch (Throwable e)
+                {
+                }
+            }
+        }
+        
+        return result;
+    }
+
+    
+    /*
+     * We need this class to do a quick check on a facelets taglib document to see if it's
+     * a pre-2.0 document.  If it is, we really need to construct a DTD validating, non-namespace
+     * aware parser. Otherwise, we have to construct a schema validating, namespace-aware parser.
+     */
+    private static class VersionCheckHandler extends DefaultHandler
+    {
+        private boolean version20OrLater;
+        
+        public boolean isVersion20OrLater ()
+        {
+            return this.version20OrLater;
+        }
+        
+        @Override
+        public void startElement (String uri, String localName, String name, Attributes attributes) throws SAXException
+        {
+            if (name.equals ("facelet-taglib"))
+            {
+                int length = attributes.getLength();
+                
+                for (int i = 0; i < length; i++)
+                {
+                    String attrName = attributes.getLocalName(i);
+                    attrName = (attrName != null) ? ( (attrName.length() > 0) ? attrName : attributes.getQName(i)) : attributes.getQName(i);
+                    if (attrName.equals ("version"))
+                    {
+                        // This document has a "version" attribute in the <facelet-taglib> element, so
+                        // it must be a 2.0 or later document as this attribute was never required before.
+
+                        this.version20OrLater = true;
+                    }
+                }
+                
+                // Throw a dummy parsing exception to terminate parsing as there really isn't any need to go any
+                // further.
+                // -= Leonardo Uribe =- THIS IS NOT GOOD PRACTICE! It is better to let the checker continue that                
+                // throw an exception, and run this one only when project stage != production.
+                //throw new SAXException();
+            }
+        }
+    }
+}

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java?rev=931402&r1=931401&r2=931402&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java Wed Apr  7 01:43:27 2010
@@ -540,6 +540,18 @@ public class FacesConfigurator
 
     private void feedStandardConfig() throws IOException, SAXException
     {
+        if (MyfacesConfig.getCurrentInstance(_externalContext).isValidateXML())
+        {
+            URL url = ClassUtils.getContextClassLoader().getResource(STANDARD_FACES_CONFIG_RESOURCE);
+            if (url == null)
+            {
+                url = this.getClass().getResource(STANDARD_FACES_CONFIG_RESOURCE);
+            }
+            if (url != null)
+            {
+                validateFacesConfig(url);
+            }
+        }
         InputStream stream = ClassUtils.getResourceAsStream(STANDARD_FACES_CONFIG_RESOURCE);
         if (stream == null)
             throw new FacesException("Standard faces config " + STANDARD_FACES_CONFIG_RESOURCE + " not found");
@@ -757,6 +769,10 @@ public class FacesConfigurator
 
             for (Map.Entry<String, URL> entry : facesConfigs.entrySet())
             {
+                if (MyfacesConfig.getCurrentInstance(_externalContext).isValidateXML())
+                {
+                    validateFacesConfig(entry.getValue());
+                }
                 InputStream stream = null;
                 try
                 {
@@ -787,6 +803,14 @@ public class FacesConfigurator
     {
         for (String systemId : getConfigFilesList())
         {
+            if (MyfacesConfig.getCurrentInstance(_externalContext).isValidateXML())
+            {
+                URL url = _externalContext.getResource(systemId);
+                if (url != null)
+                {
+                    validateFacesConfig(url);
+                }
+            }            
             InputStream stream = _externalContext.getResourceAsStream(systemId);
             if (stream == null)
             {
@@ -837,6 +861,14 @@ public class FacesConfigurator
     {
         FacesConfig webAppConfig = null;
         // web application config
+        if (MyfacesConfig.getCurrentInstance(_externalContext).isValidateXML())
+        {
+            URL url = _externalContext.getResource(DEFAULT_FACES_CONFIG);
+            if (url != null)
+            {
+                validateFacesConfig(url);
+            }
+        }
         InputStream stream = _externalContext.getResourceAsStream(DEFAULT_FACES_CONFIG);
         if (stream != null)
         {
@@ -849,6 +881,15 @@ public class FacesConfigurator
         return webAppConfig;
     }
     
+    private void validateFacesConfig(URL url) throws IOException, SAXException
+    {
+        String version = ConfigFilesXmlValidationUtils.getFacesConfigVersion(url);
+        if ("1.2".equals(version) || "2.0".equals(version))
+        {
+            ConfigFilesXmlValidationUtils.validateFacesConfigFile(url, _externalContext, version);                
+        }
+    }
+    
     protected void orderAndFeedArtifacts(List<FacesConfig> appConfigResources, FacesConfig webAppConfig)
         throws FacesException
     {

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TagLibraryConfig.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TagLibraryConfig.java?rev=931402&r1=931401&r2=931402&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TagLibraryConfig.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TagLibraryConfig.java Wed Apr  7 01:43:27 2010
@@ -22,12 +22,14 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.Method;
 import java.net.URL;
+import java.net.URLConnection;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.faces.FacesException;
 import javax.faces.application.Resource;
 import javax.faces.application.ResourceHandler;
+import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 import javax.faces.view.facelets.ComponentConfig;
 import javax.faces.view.facelets.FaceletHandler;
@@ -38,6 +40,8 @@ import javax.xml.parsers.ParserConfigura
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
+import org.apache.myfaces.config.ConfigFilesXmlValidationUtils;
+import org.apache.myfaces.shared_impl.config.MyfacesConfig;
 import org.apache.myfaces.shared_impl.util.ClassUtils;
 import org.apache.myfaces.view.facelets.tag.AbstractTagLibrary;
 import org.apache.myfaces.view.facelets.tag.TagLibrary;
@@ -47,6 +51,7 @@ import org.apache.myfaces.view.facelets.
 import org.apache.myfaces.view.facelets.util.ParameterCheck;
 import org.apache.myfaces.view.facelets.util.ReflectionUtil;
 import org.xml.sax.Attributes;
+import org.xml.sax.ErrorHandler;
 import org.xml.sax.InputSource;
 import org.xml.sax.Locator;
 import org.xml.sax.SAXException;
@@ -250,47 +255,6 @@ public final class TagLibraryConfig
         }
     }    
     
-    /*
-     * We need this class to do a quick check on a facelets taglib document to see if it's
-     * a pre-2.0 document.  If it is, we really need to construct a DTD validating, non-namespace
-     * aware parser. Otherwise, we have to construct a schema validating, namespace-aware parser.
-     */
-    /*private static class VersionCheckHandler extends DefaultHandler
-    {
-        private boolean version20OrLater;
-        
-        public boolean isVersion20OrLater ()
-        {
-            return this.version20OrLater;
-        }
-        
-        @Override
-        public void startElement (String uri, String localName, String name, Attributes attributes) throws SAXException
-        {
-            if (name.equals ("facelet-taglib"))
-            {
-                int length = attributes.getLength();
-                
-                for (int i = 0; i < length; ++i)
-                {
-                    if (attributes.getLocalName (i).equals ("version"))
-                    {
-                        // This document has a "version" attribute in the <facelet-taglib> element, so
-                        // it must be a 2.0 or later document as this attribute was never required before.
-
-                        this.version20OrLater = true;
-                    }
-                }
-                
-                // Throw a dummy parsing exception to terminate parsing as there really isn't any need to go any
-                // further.
-                // -= Leonardo Uribe =- THIS IS NOT GOOD PRACTICE! It is better to let the checker continue that                
-                // throw an exception, and run this one only when project stage != production.
-                //throw new SAXException();
-            }
-        }
-    }*/
-    
     private static class LibraryHandler extends DefaultHandler
     {
         private final URL source;
@@ -642,11 +606,28 @@ public final class TagLibraryConfig
     {
         InputStream is = null;
         TagLibrary t = null;
+        URLConnection conn = null;
         try
         {
-            is = url.openStream();
+            ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
+            boolean schemaValidating = false;
+
+            // validate XML
+            if (MyfacesConfig.getCurrentInstance(externalContext).isValidateXML())
+            {
+                String version = ConfigFilesXmlValidationUtils.getFaceletTagLibVersion(url);
+                if (schemaValidating = "2.0".equals(version))
+                {
+                    ConfigFilesXmlValidationUtils.validateFaceletTagLibFile(url, externalContext, version);
+                }
+            }
+            
+            // parse file
             LibraryHandler handler = new LibraryHandler(url);
-            SAXParser parser = createSAXParser(handler, url);
+            SAXParser parser = createSAXParser(handler, externalContext, schemaValidating);
+            conn = url.openConnection();
+            conn.setUseCaches(false);
+            is = conn.getInputStream();
             parser.parse(is, handler);
             t = handler.getLibrary();
         }
@@ -695,46 +676,24 @@ public final class TagLibraryConfig
         }
     }
 
-    private static final SAXParser createSAXParser(LibraryHandler handler, URL url) throws SAXException,
+    private static final SAXParser createSAXParser(LibraryHandler handler, ExternalContext externalContext, boolean schemaValidating) throws SAXException,
             ParserConfigurationException
     {
         SAXParserFactory factory = SAXParserFactory.newInstance();
-       
-        // -= Leonardo Uribe =- this code is commented because it is not mandatory to
-        // validate facelets tag lib and this cause performance issues. Maybe we can 
-        // refactor this part an use SchemaFactory for validation instead the proposed here
-        // only on ProjectStage.Development time before parse it (on create(URL) method).
-        //if (FacesContext.getCurrentInstance().isProjectStage(ProjectStage.Development))
-        //{
-            // We have to make two different parsers depending on whether or not the facelets taglib
-            // document is version 2.0 or later.  If pre-version 2.0, then the parser must not be
-            // namespace-aware and must be DTD validating.  If verison 2.0 or later, the parser must be
-            // namespace-aware and must be schema validating.
-            //if (!isTaglibDocument20OrLater (url))
-            //{
-            //    factory.setNamespaceAware(false);
-            //    factory.setFeature("http://xml.org/sax/features/validation", true);
-            //    factory.setValidating(true);
-            //}
-            //else
-            //{
-                // TODO: CJH: the Facelets project does not make the 2.0 schema available via their
-                // CVS.  The schema is also not available at its URL.  For now, 2.0 documents will simply
-                // have no validation.  We must get a copy of their schema once they release it and set up
-                // the parser to use it.
-                
-                //factory.setNamespaceAware(true);
-                //factory.setFeature("http://xml.org/sax/features/validation", false);
-                //factory.setValidating(false);
-            //}
-        //}
-        //else
-        //{
+
+        if (MyfacesConfig.getCurrentInstance(externalContext).isValidateXML() && !schemaValidating)
+        {
+            // DTD validating
+            factory.setNamespaceAware(false);
+            factory.setFeature("http://xml.org/sax/features/validation", true);
+            factory.setValidating(true);
+        }
+        else {
             //Just parse it and do not validate, because it is not necessary.
             factory.setNamespaceAware(true);
             factory.setFeature("http://xml.org/sax/features/validation", false);
             factory.setValidating(false);
-        //}
+        }
 
         SAXParser parser = factory.newSAXParser();
         XMLReader reader = parser.getXMLReader();
@@ -743,62 +702,4 @@ public final class TagLibraryConfig
         return parser;
     }
 
-    /*
-    private static final boolean isTaglibDocument20OrLater (URL url)
-    {
-        InputStream input = null;
-        boolean result = false;
-        
-        try
-        {
-            SAXParserFactory factory = SAXParserFactory.newInstance();
-            SAXParser parser;
-            VersionCheckHandler handler = new VersionCheckHandler();
-            
-            // We need to create a non-validating, non-namespace aware parser used to simply check
-            // which version of the facelets taglib document we are dealing with.
-
-            factory.setNamespaceAware(false);
-            factory.setFeature("http://xml.org/sax/features/validation", false);
-            factory.setValidating(false);
-            
-            parser = factory.newSAXParser();
-            
-            input = url.openStream();
-            
-            try
-            {
-                parser.parse (input, handler);
-            }
-            
-            catch (SAXException e)
-            {
-                // This is as a result of our aborted parse, so ignore.
-            }
-            
-            result = handler.isVersion20OrLater();
-        }
-        
-        catch (Throwable e)
-        {
-            // Most likely a result of our aborted parse, so ignore.
-        }
-        
-        finally
-        {
-            if (input != null)
-            {
-                try
-                {
-                    input.close();
-                }
-                
-                catch (Throwable e)
-                {
-                }
-            }
-        }
-        
-        return result;
-    }*/
 }

Modified: myfaces/core/trunk/impl/src/main/resources/META-INF/faces-config20.vm
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/resources/META-INF/faces-config20.vm?rev=931402&r1=931401&r2=931402&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/resources/META-INF/faces-config20.vm (original)
+++ myfaces/core/trunk/impl/src/main/resources/META-INF/faces-config20.vm Wed Apr  7 01:43:27 2010
@@ -36,6 +36,15 @@ $baseContent
 #end    
     <component-type>$component.type</component-type>
     <component-class>$component.className</component-class>
+#set ($facetList = ${component.facetList})
+#foreach( $facet in $facetList )
+    <facet>
+#if ($facet.longDescription)
+        <description><![CDATA[$facet.longDescription]]></description>
+#end
+        <facet-name>$facet.name</facet-name>
+    </facet>
+#end
 #set ($propertyList = ${component.propertyList})
 #foreach( $property in $propertyList )
 ## Theorically, it should only add properties visible on tld or transient
@@ -59,15 +68,6 @@ $baseContent
     </property>
 #end
 #end
-#set ($facetList = ${component.facetList})
-#foreach( $facet in $facetList )
-    <facet>
-#if ($facet.longDescription)
-        <description><![CDATA[$facet.longDescription]]></description>
-#end
-        <facet-name>$facet.name</facet-name>
-    </facet>
-#end
     <component-extension>
       <component-family>$component.family</component-family>
 #if ($component.rendererType)
@@ -112,11 +112,6 @@ $baseContent
 #if ($renderKit.className)
     <render-kit-class>$renderKit.className</render-kit-class>
 #end
-## TODO: Create a myfaces builder annotation and add through this class
-    <client-behavior-renderer>
-        <client-behavior-renderer-type>javax.faces.behavior.Ajax</client-behavior-renderer-type>
-        <client-behavior-renderer-class>org.apache.myfaces.renderkit.html.HtmlAjaxBehaviorRenderer</client-behavior-renderer-class>
-    </client-behavior-renderer>
 #set ($rendererList = ${renderKit.getRenderers()})
 #foreach( $renderer in $rendererList )
       <renderer>
@@ -125,6 +120,11 @@ $baseContent
         <renderer-class>$renderer.className</renderer-class>
       </renderer>
 #end
+## TODO: Create a myfaces builder annotation and add through this class
+    <client-behavior-renderer>
+        <client-behavior-renderer-type>javax.faces.behavior.Ajax</client-behavior-renderer-type>
+        <client-behavior-renderer-class>org.apache.myfaces.renderkit.html.HtmlAjaxBehaviorRenderer</client-behavior-renderer-class>
+    </client-behavior-renderer>
   </render-kit>
 #end
 </faces-config>

Added: myfaces/core/trunk/impl/src/main/resources/org/apache/myfaces/resource/XMLSchema.dtd
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/resources/org/apache/myfaces/resource/XMLSchema.dtd?rev=931402&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/resources/org/apache/myfaces/resource/XMLSchema.dtd (added)
+++ myfaces/core/trunk/impl/src/main/resources/org/apache/myfaces/resource/XMLSchema.dtd Wed Apr  7 01:43:27 2010
@@ -0,0 +1,418 @@
+<!--
+ 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.
+-->
+<!-- DTD for XML Schemas: Part 1: Structures
+     Public Identifier: "-//W3C//DTD XMLSCHEMA 200102//EN"
+     Official Location: http://www.w3.org/2001/XMLSchema.dtd -->
+<!-- $Id$ -->
+<!-- Note this DTD is NOT normative, or even definitive. -->           <!--d-->
+<!-- prose copy in the structures REC is the definitive version -->    <!--d-->
+<!-- (which shouldn't differ from this one except for this -->         <!--d-->
+<!-- comment and entity expansions, but just in case) -->              <!--d-->
+<!-- With the exception of cases with multiple namespace
+     prefixes for the XML Schema namespace, any XML document which is
+     not valid per this DTD given redefinitions in its internal subset of the
+     'p' and 's' parameter entities below appropriate to its namespace
+     declaration of the XML Schema namespace is almost certainly not
+     a valid schema. -->
+
+<!-- The simpleType element and its constituent parts
+     are defined in XML Schema: Part 2: Datatypes -->
+<!ENTITY % xs-datatypes PUBLIC 'datatypes' 'datatypes.dtd' >
+
+<!ENTITY % p 'xs:'> <!-- can be overriden in the internal subset of a
+                         schema document to establish a different
+                         namespace prefix -->
+<!ENTITY % s ':xs'> <!-- if %p is defined (e.g. as foo:) then you must
+                         also define %s as the suffix for the appropriate
+                         namespace declaration (e.g. :foo) -->
+<!ENTITY % nds 'xmlns%s;'>
+
+<!-- Define all the element names, with optional prefix -->
+<!ENTITY % schema "%p;schema">
+<!ENTITY % complexType "%p;complexType">
+<!ENTITY % complexContent "%p;complexContent">
+<!ENTITY % simpleContent "%p;simpleContent">
+<!ENTITY % extension "%p;extension">
+<!ENTITY % element "%p;element">
+<!ENTITY % unique "%p;unique">
+<!ENTITY % key "%p;key">
+<!ENTITY % keyref "%p;keyref">
+<!ENTITY % selector "%p;selector">
+<!ENTITY % field "%p;field">
+<!ENTITY % group "%p;group">
+<!ENTITY % all "%p;all">
+<!ENTITY % choice "%p;choice">
+<!ENTITY % sequence "%p;sequence">
+<!ENTITY % any "%p;any">
+<!ENTITY % anyAttribute "%p;anyAttribute">
+<!ENTITY % attribute "%p;attribute">
+<!ENTITY % attributeGroup "%p;attributeGroup">
+<!ENTITY % include "%p;include">
+<!ENTITY % import "%p;import">
+<!ENTITY % redefine "%p;redefine">
+<!ENTITY % notation "%p;notation">
+
+<!-- annotation elements -->
+<!ENTITY % annotation "%p;annotation">
+<!ENTITY % appinfo "%p;appinfo">
+<!ENTITY % documentation "%p;documentation">
+
+<!-- Customisation entities for the ATTLIST of each element type.
+     Define one of these if your schema takes advantage of the
+     anyAttribute='##other' in the schema for schemas -->
+
+<!ENTITY % schemaAttrs ''>
+<!ENTITY % complexTypeAttrs ''>
+<!ENTITY % complexContentAttrs ''>
+<!ENTITY % simpleContentAttrs ''>
+<!ENTITY % extensionAttrs ''>
+<!ENTITY % elementAttrs ''>
+<!ENTITY % groupAttrs ''>
+<!ENTITY % allAttrs ''>
+<!ENTITY % choiceAttrs ''>
+<!ENTITY % sequenceAttrs ''>
+<!ENTITY % anyAttrs ''>
+<!ENTITY % anyAttributeAttrs ''>
+<!ENTITY % attributeAttrs ''>
+<!ENTITY % attributeGroupAttrs ''>
+<!ENTITY % uniqueAttrs ''>
+<!ENTITY % keyAttrs ''>
+<!ENTITY % keyrefAttrs ''>
+<!ENTITY % selectorAttrs ''>
+<!ENTITY % fieldAttrs ''>
+<!ENTITY % includeAttrs ''>
+<!ENTITY % importAttrs ''>
+<!ENTITY % redefineAttrs ''>
+<!ENTITY % notationAttrs ''>
+<!ENTITY % annotationAttrs ''>
+<!ENTITY % appinfoAttrs ''>
+<!ENTITY % documentationAttrs ''>
+
+<!ENTITY % complexDerivationSet "CDATA">
+      <!-- #all or space-separated list drawn from derivationChoice -->
+<!ENTITY % blockSet "CDATA">
+      <!-- #all or space-separated list drawn from
+                      derivationChoice + 'substitution' -->
+
+<!ENTITY % mgs '%all; | %choice; | %sequence;'>
+<!ENTITY % cs '%choice; | %sequence;'>
+<!ENTITY % formValues '(qualified|unqualified)'>
+
+
+<!ENTITY % attrDecls    '((%attribute;| %attributeGroup;)*,(%anyAttribute;)?)'>
+
+<!ENTITY % particleAndAttrs '((%mgs; | %group;)?, %attrDecls;)'>
+
+<!-- This is used in part2 -->
+<!ENTITY % restriction1 '((%mgs; | %group;)?)'>
+
+%xs-datatypes;
+
+<!-- the duplication below is to produce an unambiguous content model
+     which allows annotation everywhere -->
+<!ELEMENT %schema; ((%include; | %import; | %redefine; | %annotation;)*,
+                    ((%simpleType; | %complexType;
+                      | %element; | %attribute;
+                      | %attributeGroup; | %group;
+                      | %notation; ),
+                     (%annotation;)*)* )>
+<!ATTLIST %schema;
+   targetNamespace      %URIref;               #IMPLIED
+   version              CDATA                  #IMPLIED
+   %nds;                %URIref;               #FIXED 'http://www.w3.org/2001/XMLSchema'
+   xmlns                CDATA                  #IMPLIED
+   finalDefault         %complexDerivationSet; ''
+   blockDefault         %blockSet;             ''
+   id                   ID                     #IMPLIED
+   elementFormDefault   %formValues;           'unqualified'
+   attributeFormDefault %formValues;           'unqualified'
+   xml:lang             CDATA                  #IMPLIED
+   %schemaAttrs;>
+<!-- Note the xmlns declaration is NOT in the Schema for Schemas,
+     because at the Infoset level where schemas operate,
+     xmlns(:prefix) is NOT an attribute! -->
+<!-- The declaration of xmlns is a convenience for schema authors -->
+ 
+<!-- The id attribute here and below is for use in external references
+     from non-schemas using simple fragment identifiers.
+     It is NOT used for schema-to-schema reference, internal or
+     external. -->
+
+<!-- a type is a named content type specification which allows attribute
+     declarations-->
+<!-- -->
+
+<!ELEMENT %complexType; ((%annotation;)?,
+                         (%simpleContent;|%complexContent;|
+                          %particleAndAttrs;))>
+
+<!ATTLIST %complexType;
+          name      %NCName;                        #IMPLIED
+          id        ID                              #IMPLIED
+          abstract  %boolean;                       #IMPLIED
+          final     %complexDerivationSet;          #IMPLIED
+          block     %complexDerivationSet;          #IMPLIED
+          mixed (true|false) 'false'
+          %complexTypeAttrs;>
+
+<!-- particleAndAttrs is shorthand for a root type -->
+<!-- mixed is disallowed if simpleContent, overriden if complexContent
+     has one too. -->
+
+<!-- If anyAttribute appears in one or more referenced attributeGroups
+     and/or explicitly, the intersection of the permissions is used -->
+
+<!ELEMENT %complexContent; ((%annotation;)?, (%restriction;|%extension;))>
+<!ATTLIST %complexContent;
+          mixed (true|false) #IMPLIED
+          id    ID           #IMPLIED
+          %complexContentAttrs;>
+
+<!-- restriction should use the branch defined above, not the simple
+     one from part2; extension should use the full model  -->
+
+<!ELEMENT %simpleContent; ((%annotation;)?, (%restriction;|%extension;))>
+<!ATTLIST %simpleContent;
+          id    ID           #IMPLIED
+          %simpleContentAttrs;>
+
+<!-- restriction should use the simple branch from part2, not the 
+     one defined above; extension should have no particle  -->
+
+<!ELEMENT %extension; ((%annotation;)?, (%particleAndAttrs;))>
+<!ATTLIST %extension;
+          base  %QName;      #REQUIRED
+          id    ID           #IMPLIED
+          %extensionAttrs;>
+
+<!-- an element is declared by either:
+ a name and a type (either nested or referenced via the type attribute)
+ or a ref to an existing element declaration -->
+
+<!ELEMENT %element; ((%annotation;)?, (%complexType;| %simpleType;)?,
+                     (%unique; | %key; | %keyref;)*)>
+<!-- simpleType or complexType only if no type|ref attribute -->
+<!-- ref not allowed at top level -->
+<!ATTLIST %element;
+            name               %NCName;               #IMPLIED
+            id                 ID                     #IMPLIED
+            ref                %QName;                #IMPLIED
+            type               %QName;                #IMPLIED
+            minOccurs          %nonNegativeInteger;   #IMPLIED
+            maxOccurs          CDATA                  #IMPLIED
+            nillable           %boolean;              #IMPLIED
+            substitutionGroup  %QName;                #IMPLIED
+            abstract           %boolean;              #IMPLIED
+            final              %complexDerivationSet; #IMPLIED
+            block              %blockSet;             #IMPLIED
+            default            CDATA                  #IMPLIED
+            fixed              CDATA                  #IMPLIED
+            form               %formValues;           #IMPLIED
+            %elementAttrs;>
+<!-- type and ref are mutually exclusive.
+     name and ref are mutually exclusive, one is required -->
+<!-- In the absence of type AND ref, type defaults to type of
+     substitutionGroup, if any, else the ur-type, i.e. unconstrained -->
+<!-- default and fixed are mutually exclusive -->
+
+<!ELEMENT %group; ((%annotation;)?,(%mgs;)?)>
+<!ATTLIST %group; 
+          name        %NCName;               #IMPLIED
+          ref         %QName;                #IMPLIED
+          minOccurs   %nonNegativeInteger;   #IMPLIED
+          maxOccurs   CDATA                  #IMPLIED
+          id          ID                     #IMPLIED
+          %groupAttrs;>
+
+<!ELEMENT %all; ((%annotation;)?, (%element;)*)>
+<!ATTLIST %all;
+          minOccurs   (1)                    #IMPLIED
+          maxOccurs   (1)                    #IMPLIED
+          id          ID                     #IMPLIED
+          %allAttrs;>
+
+<!ELEMENT %choice; ((%annotation;)?, (%element;| %group;| %cs; | %any;)*)>
+<!ATTLIST %choice;
+          minOccurs   %nonNegativeInteger;   #IMPLIED
+          maxOccurs   CDATA                  #IMPLIED
+          id          ID                     #IMPLIED
+          %choiceAttrs;>
+
+<!ELEMENT %sequence; ((%annotation;)?, (%element;| %group;| %cs; | %any;)*)>
+<!ATTLIST %sequence;
+          minOccurs   %nonNegativeInteger;   #IMPLIED
+          maxOccurs   CDATA                  #IMPLIED
+          id          ID                     #IMPLIED
+          %sequenceAttrs;>
+
+<!-- an anonymous grouping in a model, or
+     a top-level named group definition, or a reference to same -->
+
+<!-- Note that if order is 'all', group is not allowed inside.
+     If order is 'all' THIS group must be alone (or referenced alone) at
+     the top level of a content model -->
+<!-- If order is 'all', minOccurs==maxOccurs==1 on element/any inside -->
+<!-- Should allow minOccurs=0 inside order='all' . . . -->
+
+<!ELEMENT %any; (%annotation;)?>
+<!ATTLIST %any;
+            namespace       CDATA                  '##any'
+            processContents (skip|lax|strict)      'strict'
+            minOccurs       %nonNegativeInteger;   '1'
+            maxOccurs       CDATA                  '1'
+            id              ID                     #IMPLIED
+            %anyAttrs;>
+
+<!-- namespace is interpreted as follows:
+                  ##any      - - any non-conflicting WFXML at all
+
+                  ##other    - - any non-conflicting WFXML from namespace other
+                                  than targetNamespace
+
+                  ##local    - - any unqualified non-conflicting WFXML/attribute
+                  one or     - - any non-conflicting WFXML from
+                  more URI        the listed namespaces
+                  references
+
+                  ##targetNamespace ##local may appear in the above list,
+                    with the obvious meaning -->
+
+<!ELEMENT %anyAttribute; (%annotation;)?>
+<!ATTLIST %anyAttribute;
+            namespace       CDATA              '##any'
+            processContents (skip|lax|strict)  'strict'
+            id              ID                 #IMPLIED
+            %anyAttributeAttrs;>
+<!-- namespace is interpreted as for 'any' above -->
+
+<!-- simpleType only if no type|ref attribute -->
+<!-- ref not allowed at top level, name iff at top level -->
+<!ELEMENT %attribute; ((%annotation;)?, (%simpleType;)?)>
+<!ATTLIST %attribute;
+          name      %NCName;      #IMPLIED
+          id        ID            #IMPLIED
+          ref       %QName;       #IMPLIED
+          type      %QName;       #IMPLIED
+          use       (prohibited|optional|required) #IMPLIED
+          default   CDATA         #IMPLIED
+          fixed     CDATA         #IMPLIED
+          form      %formValues;  #IMPLIED
+          %attributeAttrs;>
+<!-- type and ref are mutually exclusive.
+     name and ref are mutually exclusive, one is required -->
+<!-- default for use is optional when nested, none otherwise -->
+<!-- default and fixed are mutually exclusive -->
+<!-- type attr and simpleType content are mutually exclusive -->
+
+<!-- an attributeGroup is a named collection of attribute decls, or a
+     reference thereto -->
+<!ELEMENT %attributeGroup; ((%annotation;)?,
+                       (%attribute; | %attributeGroup;)*,
+                       (%anyAttribute;)?) >
+<!ATTLIST %attributeGroup;
+                 name       %NCName;       #IMPLIED
+                 id         ID             #IMPLIED
+                 ref        %QName;        #IMPLIED
+                 %attributeGroupAttrs;>
+
+<!-- ref iff no content, no name.  ref iff not top level -->
+
+<!-- better reference mechanisms -->
+<!ELEMENT %unique; ((%annotation;)?, %selector;, (%field;)+)>
+<!ATTLIST %unique;
+          name     %NCName;       #REQUIRED
+	  id       ID             #IMPLIED
+	  %uniqueAttrs;>
+
+<!ELEMENT %key;    ((%annotation;)?, %selector;, (%field;)+)>
+<!ATTLIST %key;
+          name     %NCName;       #REQUIRED
+	  id       ID             #IMPLIED
+	  %keyAttrs;>
+
+<!ELEMENT %keyref; ((%annotation;)?, %selector;, (%field;)+)>
+<!ATTLIST %keyref;
+          name     %NCName;       #REQUIRED
+	  refer    %QName;        #REQUIRED
+	  id       ID             #IMPLIED
+	  %keyrefAttrs;>
+
+<!ELEMENT %selector; ((%annotation;)?)>
+<!ATTLIST %selector;
+          xpath %XPathExpr; #REQUIRED
+          id    ID          #IMPLIED
+          %selectorAttrs;>
+<!ELEMENT %field; ((%annotation;)?)>
+<!ATTLIST %field;
+          xpath %XPathExpr; #REQUIRED
+          id    ID          #IMPLIED
+          %fieldAttrs;>
+
+<!-- Schema combination mechanisms -->
+<!ELEMENT %include; (%annotation;)?>
+<!ATTLIST %include;
+          schemaLocation %URIref; #REQUIRED
+          id             ID       #IMPLIED
+          %includeAttrs;>
+
+<!ELEMENT %import; (%annotation;)?>
+<!ATTLIST %import;
+          namespace      %URIref; #IMPLIED
+          schemaLocation %URIref; #IMPLIED
+          id             ID       #IMPLIED
+          %importAttrs;>
+
+<!ELEMENT %redefine; (%annotation; | %simpleType; | %complexType; |
+                      %attributeGroup; | %group;)*>
+<!ATTLIST %redefine;
+          schemaLocation %URIref; #REQUIRED
+          id             ID       #IMPLIED
+          %redefineAttrs;>
+
+<!ELEMENT %notation; (%annotation;)?>
+<!ATTLIST %notation;
+	  name        %NCName;    #REQUIRED
+	  id          ID          #IMPLIED
+	  public      CDATA       #REQUIRED
+	  system      %URIref;    #IMPLIED
+	  %notationAttrs;>
+
+<!-- Annotation is either application information or documentation -->
+<!-- By having these here they are available for datatypes as well
+     as all the structures elements -->
+
+<!ELEMENT %annotation; (%appinfo; | %documentation;)*>
+<!ATTLIST %annotation; %annotationAttrs;>
+
+<!-- User must define annotation elements in internal subset for this
+     to work -->
+<!ELEMENT %appinfo; ANY>   <!-- too restrictive -->
+<!ATTLIST %appinfo;
+          source     %URIref;      #IMPLIED
+          id         ID         #IMPLIED
+          %appinfoAttrs;>
+<!ELEMENT %documentation; ANY>   <!-- too restrictive -->
+<!ATTLIST %documentation;
+          source     %URIref;   #IMPLIED
+          id         ID         #IMPLIED
+          xml:lang   CDATA      #IMPLIED
+          %documentationAttrs;>
+
+<!NOTATION XMLSchemaStructures PUBLIC
+           'structures' 'http://www.w3.org/2001/XMLSchema.xsd' >
+<!NOTATION XML PUBLIC
+           'REC-xml-1998-0210' 'http://www.w3.org/TR/1998/REC-xml-19980210' >

Added: myfaces/core/trunk/impl/src/main/resources/org/apache/myfaces/resource/datatypes.dtd
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/resources/org/apache/myfaces/resource/datatypes.dtd?rev=931402&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/resources/org/apache/myfaces/resource/datatypes.dtd (added)
+++ myfaces/core/trunk/impl/src/main/resources/org/apache/myfaces/resource/datatypes.dtd Wed Apr  7 01:43:27 2010
@@ -0,0 +1,219 @@
+<!--
+ 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.
+-->
+<!--
+        DTD for XML Schemas: Part 2: Datatypes
+        $Id$
+        Note this DTD is NOT normative, or even definitive. - - the
+        prose copy in the datatypes REC is the definitive version
+        (which shouldn't differ from this one except for this comment
+        and entity expansions, but just in case)
+  -->
+
+<!--
+        This DTD cannot be used on its own, it is intended
+        only for incorporation in XMLSchema.dtd, q.v.
+  -->
+
+<!-- Define all the element names, with optional prefix -->
+<!ENTITY % simpleType "%p;simpleType">
+<!ENTITY % restriction "%p;restriction">
+<!ENTITY % list "%p;list">
+<!ENTITY % union "%p;union">
+<!ENTITY % maxExclusive "%p;maxExclusive">
+<!ENTITY % minExclusive "%p;minExclusive">
+<!ENTITY % maxInclusive "%p;maxInclusive">
+<!ENTITY % minInclusive "%p;minInclusive">
+<!ENTITY % totalDigits "%p;totalDigits">
+<!ENTITY % fractionDigits "%p;fractionDigits">
+<!ENTITY % length "%p;length">
+<!ENTITY % minLength "%p;minLength">
+<!ENTITY % maxLength "%p;maxLength">
+<!ENTITY % enumeration "%p;enumeration">
+<!ENTITY % whiteSpace "%p;whiteSpace">
+<!ENTITY % pattern "%p;pattern">
+
+<!--
+        Customisation entities for the ATTLIST of each element
+        type. Define one of these if your schema takes advantage
+        of the anyAttribute='##other' in the schema for schemas
+  -->
+
+<!ENTITY % simpleTypeAttrs "">
+<!ENTITY % restrictionAttrs "">
+<!ENTITY % listAttrs "">
+<!ENTITY % unionAttrs "">
+<!ENTITY % maxExclusiveAttrs "">
+<!ENTITY % minExclusiveAttrs "">
+<!ENTITY % maxInclusiveAttrs "">
+<!ENTITY % minInclusiveAttrs "">
+<!ENTITY % totalDigitsAttrs "">
+<!ENTITY % fractionDigitsAttrs "">
+<!ENTITY % lengthAttrs "">
+<!ENTITY % minLengthAttrs "">
+<!ENTITY % maxLengthAttrs "">
+<!ENTITY % enumerationAttrs "">
+<!ENTITY % whiteSpaceAttrs "">
+<!ENTITY % patternAttrs "">
+
+<!-- Define some entities for informative use as attribute
+        types -->
+<!ENTITY % URIref "CDATA">
+<!ENTITY % XPathExpr "CDATA">
+<!ENTITY % QName "NMTOKEN">
+<!ENTITY % QNames "NMTOKENS">
+<!ENTITY % NCName "NMTOKEN">
+<!ENTITY % nonNegativeInteger "NMTOKEN">
+<!ENTITY % boolean "(true|false)">
+<!ENTITY % simpleDerivationSet "CDATA">
+<!--
+        #all or space-separated list drawn from derivationChoice
+  -->
+
+<!--
+        Note that the use of 'facet' below is less restrictive
+        than is really intended:  There should in fact be no
+        more than one of each of minInclusive, minExclusive,
+        maxInclusive, maxExclusive, totalDigits, fractionDigits,
+        length, maxLength, minLength within datatype,
+        and the min- and max- variants of Inclusive and Exclusive
+        are mutually exclusive. On the other hand,  pattern and
+        enumeration may repeat.
+  -->
+<!ENTITY % minBound "(%minInclusive; | %minExclusive;)">
+<!ENTITY % maxBound "(%maxInclusive; | %maxExclusive;)">
+<!ENTITY % bounds "%minBound; | %maxBound;">
+<!ENTITY % numeric "%totalDigits; | %fractionDigits;">
+<!ENTITY % ordered "%bounds; | %numeric;">
+<!ENTITY % unordered
+   "%pattern; | %enumeration; | %whiteSpace; | %length; |
+   %maxLength; | %minLength;">
+<!ENTITY % facet "%ordered; | %unordered;">
+<!ENTITY % facetAttr 
+        "value CDATA #REQUIRED
+        id ID #IMPLIED">
+<!ENTITY % fixedAttr "fixed %boolean; #IMPLIED">
+<!ENTITY % facetModel "(%annotation;)?">
+<!ELEMENT %simpleType;
+        ((%annotation;)?, (%restriction; | %list; | %union;))>
+<!ATTLIST %simpleType;
+    name      %NCName; #IMPLIED
+    final     %simpleDerivationSet; #IMPLIED
+    id        ID       #IMPLIED
+    %simpleTypeAttrs;>
+<!-- name is required at top level -->
+<!ELEMENT %restriction; ((%annotation;)?,
+                         (%restriction1; |
+                          ((%simpleType;)?,(%facet;)*)),
+                         (%attrDecls;))>
+<!ATTLIST %restriction;
+    base      %QName;                  #IMPLIED
+    id        ID       #IMPLIED
+    %restrictionAttrs;>
+<!--
+        base and simpleType child are mutually exclusive,
+        one is required.
+
+        restriction is shared between simpleType and
+        simpleContent and complexContent (in XMLSchema.xsd).
+        restriction1 is for the latter cases, when this
+        is restricting a complex type, as is attrDecls.
+  -->
+<!ELEMENT %list; ((%annotation;)?,(%simpleType;)?)>
+<!ATTLIST %list;
+    itemType      %QName;             #IMPLIED
+    id        ID       #IMPLIED
+    %listAttrs;>
+<!--
+        itemType and simpleType child are mutually exclusive,
+        one is required
+  -->
+<!ELEMENT %union; ((%annotation;)?,(%simpleType;)*)>
+<!ATTLIST %union;
+    id            ID       #IMPLIED
+    memberTypes   %QNames;            #IMPLIED
+    %unionAttrs;>
+<!--
+        At least one item in memberTypes or one simpleType
+        child is required
+  -->
+
+<!ELEMENT %maxExclusive; %facetModel;>
+<!ATTLIST %maxExclusive;
+        %facetAttr;
+        %fixedAttr;
+        %maxExclusiveAttrs;>
+<!ELEMENT %minExclusive; %facetModel;>
+<!ATTLIST %minExclusive;
+        %facetAttr;
+        %fixedAttr;
+        %minExclusiveAttrs;>
+
+<!ELEMENT %maxInclusive; %facetModel;>
+<!ATTLIST %maxInclusive;
+        %facetAttr;
+        %fixedAttr;
+        %maxInclusiveAttrs;>
+<!ELEMENT %minInclusive; %facetModel;>
+<!ATTLIST %minInclusive;
+        %facetAttr;
+        %fixedAttr;
+        %minInclusiveAttrs;>
+
+<!ELEMENT %totalDigits; %facetModel;>
+<!ATTLIST %totalDigits;
+        %facetAttr;
+        %fixedAttr;
+        %totalDigitsAttrs;>
+<!ELEMENT %fractionDigits; %facetModel;>
+<!ATTLIST %fractionDigits;
+        %facetAttr;
+        %fixedAttr;
+        %fractionDigitsAttrs;>
+
+<!ELEMENT %length; %facetModel;>
+<!ATTLIST %length;
+        %facetAttr;
+        %fixedAttr;
+        %lengthAttrs;>
+<!ELEMENT %minLength; %facetModel;>
+<!ATTLIST %minLength;
+        %facetAttr;
+        %fixedAttr;
+        %minLengthAttrs;>
+<!ELEMENT %maxLength; %facetModel;>
+<!ATTLIST %maxLength;
+        %facetAttr;
+        %fixedAttr;
+        %maxLengthAttrs;>
+
+<!-- This one can be repeated -->
+<!ELEMENT %enumeration; %facetModel;>
+<!ATTLIST %enumeration;
+        %facetAttr;
+        %enumerationAttrs;>
+
+<!ELEMENT %whiteSpace; %facetModel;>
+<!ATTLIST %whiteSpace;
+        %facetAttr;
+        %fixedAttr;
+        %whiteSpaceAttrs;>
+
+<!-- This one can be repeated -->
+<!ELEMENT %pattern; %facetModel;>
+<!ATTLIST %pattern;
+        %facetAttr;
+        %patternAttrs;>