8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
authorjoehw
Fri, 29 Aug 2014 11:49:38 -0700
changeset 26257 4ec17c54acb3
parent 26077 ee87d00c5e2c
child 26258 f402435374ad
child 26516 8e6a45c22cea
8037819: Xerces Update: jaxp/validation/XMLSchemaFactory Reviewed-by: lancea
jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/Constants.java
jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/ValidatedInfo.java
jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties
jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/validation/ConfigurableValidationState.java
jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java
jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchema.java
jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java
jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java
jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/StandardParserConfiguration.java
jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/Constants.java	Mon Aug 18 10:08:34 2014 +0100
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/Constants.java	Fri Aug 29 11:49:38 2014 -0700
@@ -1,13 +1,10 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
- */
-
-/*
- * Copyright 2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * 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
  *
@@ -41,6 +38,9 @@
     public static final String NS_XMLSCHEMA = "http://www.w3.org/2001/XMLSchema".intern();
     public static final String NS_DTD = "http://www.w3.org/TR/REC-xml".intern();
 
+    // Schema Versions:
+    public static final String W3C_XML_SCHEMA10_NS_URI = "http://www.w3.org/XML/XMLSchema/v1.0".intern();
+
     // Schema features
     public static final String SUN_SCHEMA_FEATURE_PREFIX = "http://java.sun.com/xml/schema/features/";
     public static final String SUN_REPORT_IGNORED_ELEMENT_CONTENT_WHITESPACE = "report-ignored-element-content-whitespace";
@@ -487,6 +487,40 @@
     /** XInclude fixup language feature ("xinclude/fixup-language"). */
     public static final String XINCLUDE_FIXUP_LANGUAGE_FEATURE = "xinclude/fixup-language";
 
+     /**
+     * Feature to ignore xsi:type attributes on elements during validation,
+     * until a global element declaration is found. ("validation/schema/ignore-xsi-type-until-elemdecl")
+     * If this feature is on when validating a document, then beginning at the validation root
+     * element, xsi:type attributes are ignored until a global element declaration is
+     * found for an element.  Once a global element declaration has been found, xsi:type
+     * attributes will start being processed for the sub-tree beginning at the element for
+     * which the declaration was found.
+     *
+     * Suppose an element A has two element children, B and C.
+     *
+     * If a global element declaration is found for A, xsi:type attributes on A, B and C,
+     * and all of B and C's descendents, will be processed.
+     *
+     * If no global element declaration is found for A or B, but one is found for C,
+     * then xsi:type attributes will be ignored on A and B (and any descendents of B,
+     * until a global element declaration is found), but xsi:type attributes will be
+     * processed for C and all of C's descendents.
+     *
+     * Once xsi:type attributes stop being ignored for a subtree, they do not start
+     * being ignored again, even if more elements are encountered for which no global
+     * element declaration can be found.
+     */
+    public static final String IGNORE_XSI_TYPE_FEATURE = "validation/schema/ignore-xsi-type-until-elemdecl";
+
+    /** Perform checking of ID/IDREFs ("validation/id-idref-checking") */
+    public static final String ID_IDREF_CHECKING_FEATURE = "validation/id-idref-checking";
+
+    /** Feature to ignore errors caused by identity constraints ("validation/identity-constraint-checking") */
+    public static final String IDC_CHECKING_FEATURE = "validation/identity-constraint-checking";
+
+    /** Feature to ignore errors caused by unparsed entities ("validation/unparsed-entity-checking") */
+    public static final String UNPARSED_ENTITY_CHECKING_FEATURE = "validation/unparsed-entity-checking";
+
     /**
      * Internal feature. When set to true the schema validator will only use
      * schema components from the grammar pool provided.
@@ -598,6 +632,8 @@
     /** Validation manager property ("internal/validation-manager"). */
     public static final String VALIDATION_MANAGER_PROPERTY = "internal/validation-manager";
 
+    /** Schema type of the root element in a document ("validation/schema/root-type-definition"). */
+    public static final String ROOT_TYPE_DEFINITION_PROPERTY = "validation/schema/root-type-definition";
 
     /** XPointer Schema property ("xpointer-schema"). */
     public static final String XPOINTER_SCHEMA_PROPERTY = "xpointer-schema";
@@ -739,6 +775,10 @@
         XINCLUDE_FEATURE,
         XINCLUDE_FIXUP_BASE_URIS_FEATURE,
         XINCLUDE_FIXUP_LANGUAGE_FEATURE,
+        IGNORE_XSI_TYPE_FEATURE,
+        ID_IDREF_CHECKING_FEATURE,
+        IDC_CHECKING_FEATURE,
+        UNPARSED_ENTITY_CHECKING_FEATURE,
         NAMESPACE_GROWTH_FEATURE,
         TOLERATE_DUPLICATES_FEATURE,
     };
@@ -762,6 +802,7 @@
             VALIDATION_MANAGER_PROPERTY,
             BUFFER_SIZE_PROPERTY,
             SECURITY_MANAGER_PROPERTY,
+            ROOT_TYPE_DEFINITION_PROPERTY,
             LOCALE_PROPERTY,
             SCHEMA_DV_FACTORY_PROPERTY,
     };
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/ValidatedInfo.java	Mon Aug 18 10:08:34 2014 +0100
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/ValidatedInfo.java	Fri Aug 29 11:49:38 2014 -0700
@@ -1,13 +1,10 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * Copyright 2001, 2002,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * 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
  *
@@ -21,6 +18,7 @@
 package com.sun.org.apache.xerces.internal.impl.dv;
 
 import com.sun.org.apache.xerces.internal.xs.ShortList;
+import com.sun.org.apache.xerces.internal.xs.XSConstants;
 
 /**
  * Class to get the information back after content is validated. This info
@@ -95,4 +93,60 @@
         else
             return actualValue.toString();
     }
+
+    /**
+     * Returns true if the two ValidatedInfo objects can be compared in the same
+     * value space.
+     */
+    public static boolean isComparable(ValidatedInfo info1, ValidatedInfo info2) {
+        final short primitiveType1 = convertToPrimitiveKind(info1.actualValueType);
+        final short primitiveType2 = convertToPrimitiveKind(info2.actualValueType);
+        if (primitiveType1 != primitiveType2) {
+            return (primitiveType1 == XSConstants.ANYSIMPLETYPE_DT && primitiveType2 == XSConstants.STRING_DT ||
+                    primitiveType1 == XSConstants.STRING_DT && primitiveType2 == XSConstants.ANYSIMPLETYPE_DT);
+        }
+        else if (primitiveType1 == XSConstants.LIST_DT || primitiveType1 == XSConstants.LISTOFUNION_DT) {
+            final ShortList typeList1 = info1.itemValueTypes;
+            final ShortList typeList2 = info2.itemValueTypes;
+            final int typeList1Length = typeList1 != null ? typeList1.getLength() : 0;
+            final int typeList2Length = typeList2 != null ? typeList2.getLength() : 0;
+            if (typeList1Length != typeList2Length) {
+                return false;
+            }
+            for (int i = 0; i < typeList1Length; ++i) {
+                final short primitiveItem1 = convertToPrimitiveKind(typeList1.item(i));
+                final short primitiveItem2 = convertToPrimitiveKind(typeList2.item(i));
+                if (primitiveItem1 != primitiveItem2) {
+                    if (primitiveItem1 == XSConstants.ANYSIMPLETYPE_DT && primitiveItem2 == XSConstants.STRING_DT ||
+                        primitiveItem1 == XSConstants.STRING_DT && primitiveItem2 == XSConstants.ANYSIMPLETYPE_DT) {
+                        continue;
+                    }
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Returns the primitive type of the given type.
+     * @param valueType A value type as defined in XSConstants.
+     * @return The primitive type from which valueType was derived.
+     */
+    private static short convertToPrimitiveKind(short valueType) {
+        /** Primitive datatypes. */
+        if (valueType <= XSConstants.NOTATION_DT) {
+            return valueType;
+        }
+        /** Types derived from string. */
+        if (valueType <= XSConstants.ENTITY_DT) {
+            return XSConstants.STRING_DT;
+        }
+        /** Types derived from decimal. */
+        if (valueType <= XSConstants.POSITIVEINTEGER_DT) {
+            return XSConstants.DECIMAL_DT;
+        }
+        /** Other types. */
+        return valueType;
+    }
 }
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties	Mon Aug 18 10:08:34 2014 +0100
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties	Fri Aug 29 11:49:38 2014 -0700
@@ -14,20 +14,18 @@
 
 # Identity constraints
 
-        AbsentKeyValue = Identity Constraint error (cvc-identity-constraint.4.2.1):  element \"{0}\" has a key with no value.
+        AbsentKeyValue = cvc-identity-constraint.4.2.1.a: Element \"{0}\" has no value for the key \"{1}\".
         DuplicateField = Duplicate match in scope for field \"{0}\".
-        DuplicateKey = Duplicate key value [{0}] declared for identity constraint of element \"{1}\".
-        DuplicateUnique = Duplicate unique value [{0}] declared for identity constraint of element \"{1}\".
-        FieldMultipleMatch = Identity constraint error:  field \"{0}\" matches more than one value within the scope of its selector; fields must match unique values.
+        DuplicateKey = cvc-identity-constraint.4.2.2: Duplicate key value [{0}] declared for identity constraint \"{2}\" of element \"{1}\".
+        DuplicateUnique = cvc-identity-constraint.4.1: Duplicate unique value [{0}] declared for identity constraint \"{2}\" of element \"{1}\".
+        FieldMultipleMatch = cvc-identity-constraint.3: Field \"{0}\" of identity constraint \"{1}\" matches more than one value within the scope of its selector; fields must match unique values.
         FixedDiffersFromActual = The content of this element is not equivalent to the value of the \"fixed\" attribute in the element's declaration in the schema.
-        KeyMatchesNillable = Identity Constraint error (cvc-identity-constraint.4.2.3):  element \"{0}\" has a key which matches an element which has nillable set to true.
-        KeyNotEnoughValues = Not enough values specified for <key name=\"{1}\"> identity constraint specified for element \"{0}\".
-        KeyNotFound = Key ''{0}'' with value ''{1}'' not found for identity constraint of element ''{2}''.
-        KeyRefNotEnoughValues = Not enough values specified for <keyref name=\"{1}\"> identity constraint specified for element \"{0}\".
+        KeyMatchesNillable = cvc-identity-constraint.4.2.3: Element \"{0}\" has the key \"{1}\" which matches an element which has nillable set to true.
+        KeyNotEnoughValues = cvc-identity-constraint.4.2.1.b: Not enough values specified for <key name=\"{1}\"> identity constraint specified for element \"{0}\".
+        KeyNotFound = cvc-identity-constraint.4.3: Key ''{0}'' with value ''{1}'' not found for identity constraint of element ''{2}''.
         KeyRefOutOfScope = Identity Constraint error:  identity constraint \"{0}\" has a keyref which refers to a key or unique that is out of scope.
         KeyRefReferNotFound = Key reference declaration \"{0}\" refers to unknown key with name \"{1}\".
-        UniqueNotEnoughValues = Not enough values specified for <unique> identity constraint specified for element \"{0}\".
-        UnknownField = Internal identity constraint error; unknown field \"{0}\".
+        UnknownField = Internal identity constraint error; unknown field \"{0}\" for identity constraint \"{2}\" specified for element \"{1}\".
 
 # Ideally, we should only use the following error keys, not the ones under
 # "Identity constraints". And we should cover all of the following errors.
@@ -79,6 +77,7 @@
         cvc-minLength-valid = cvc-minLength-valid: Value ''{0}'' with length = ''{1}'' is not facet-valid with respect to minLength ''{2}'' for type ''{3}''.
         cvc-pattern-valid = cvc-pattern-valid: Value ''{0}'' is not facet-valid with respect to pattern ''{1}'' for type ''{2}''.
         cvc-totalDigits-valid = cvc-totalDigits-valid: Value ''{0}'' has {1} total digits, but the number of total digits has been limited to {2}.
+        cvc-type.1 = cvc-type.1: The type definition ''{0}'' was not found.
         cvc-type.2 = cvc-type.2: The type definition cannot be abstract for element {0}.
         cvc-type.3.1.1 = cvc-type.3.1.1: Element ''{0}'' is a simple type, so it cannot have attributes, excepting those whose namespace name is identical to ''http://www.w3.org/2001/XMLSchema-instance'' and whose [local name] is one of ''type'', ''nil'', ''schemaLocation'' or ''noNamespaceSchemaLocation''. However, the attribute, ''{1}'' was found.
         cvc-type.3.1.2 = cvc-type.3.1.2: Element ''{0}'' is a simple type, so it must have no element information item [children].
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/validation/ConfigurableValidationState.java	Fri Aug 29 11:49:38 2014 -0700
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.sun.org.apache.xerces.internal.impl.validation;
+
+/**
+ * <p>An extension of ValidationState which can be configured to turn
+ * off checking for ID/IDREF errors and unparsed entity errors.</p>
+ *
+ * @xerces.internal
+ *
+ * @author Peter McCracken, IBM
+ */
+public final class ConfigurableValidationState extends ValidationState {
+
+    /**
+     * Whether to check for ID/IDREF errors
+     */
+    private boolean fIdIdrefChecking;
+
+    /**
+     * Whether to check for unparsed entity errors
+     */
+    private boolean fUnparsedEntityChecking;
+
+    /**
+     * Creates a new ConfigurableValidationState.
+     * By default, error checking for both ID/IDREFs
+     * and unparsed entities are turned on.
+     */
+    public ConfigurableValidationState() {
+        super();
+        fIdIdrefChecking = true;
+        fUnparsedEntityChecking = true;
+    }
+
+    /**
+     * Turns checking for ID/IDREF errors on and off.
+     * @param setting: true to turn on error checking
+     *                 false to turn off error checking
+     */
+    public void setIdIdrefChecking(boolean setting) {
+        fIdIdrefChecking = setting;
+    }
+
+    /**
+     * Turns checking for unparsed entity errors on and off.
+     * @param setting: true to turn on error checking
+     *                 false to turn off error checking
+     */
+    public void setUnparsedEntityChecking(boolean setting) {
+        fUnparsedEntityChecking = setting;
+    }
+
+    /**
+     * Checks if all IDREFs have a corresponding ID.
+     * @return null, if ID/IDREF checking is turned off
+     *         otherwise, returns the value of the super implementation
+     */
+    public String checkIDRefID() {
+        return (fIdIdrefChecking) ? super.checkIDRefID() : null;
+    }
+
+    /**
+     * Checks if an ID has already been declared.
+     * @return false, if ID/IDREF checking is turned off
+     *         otherwise, returns the value of the super implementation
+     */
+    public boolean isIdDeclared(String name) {
+        return (fIdIdrefChecking) ? super.isIdDeclared(name) : false;
+    }
+
+    /**
+     * Checks if an entity is declared.
+     * @return true, if unparsed entity checking is turned off
+     *         otherwise, returns the value of the super implementation
+     */
+    public boolean isEntityDeclared(String name) {
+        return (fUnparsedEntityChecking) ? super.isEntityDeclared(name) : true;
+    }
+
+    /**
+     * Checks if an entity is unparsed.
+     * @return true, if unparsed entity checking is turned off
+     *         otherwise, returns the value of the super implementation
+     */
+    public boolean isEntityUnparsed(String name) {
+        return (fUnparsedEntityChecking) ? super.isEntityUnparsed(name) : true;
+    }
+
+    /**
+     * Adds the ID, if ID/IDREF checking is enabled.
+     * @param the ID to add
+     */
+    public void addId(String name) {
+        if (fIdIdrefChecking) {
+            super.addId(name);
+        }
+    }
+
+    /**
+     * Adds the IDREF, if ID/IDREF checking is enabled.
+     * @param the IDREF to add
+     */
+    public void addIdRef(String name) {
+        if (fIdIdrefChecking) {
+            super.addIdRef(name);
+        }
+    }
+}
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java	Mon Aug 18 10:08:34 2014 +0100
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java	Fri Aug 29 11:49:38 2014 -0700
@@ -1,13 +1,10 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * Copyright 1999-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * 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
  *
@@ -38,6 +35,7 @@
 import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException;
 import com.sun.org.apache.xerces.internal.impl.dv.ValidatedInfo;
 import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType;
+import com.sun.org.apache.xerces.internal.impl.validation.ConfigurableValidationState;
 import com.sun.org.apache.xerces.internal.impl.validation.ValidationManager;
 import com.sun.org.apache.xerces.internal.impl.validation.ValidationState;
 import com.sun.org.apache.xerces.internal.impl.xs.identity.Field;
@@ -185,6 +183,22 @@
     protected static final String TOLERATE_DUPLICATES =
         Constants.XERCES_FEATURE_PREFIX + Constants.TOLERATE_DUPLICATES_FEATURE;
 
+    /** Feature identifier: whether to ignore xsi:type attributes until a global element declaration is encountered */
+    protected static final String IGNORE_XSI_TYPE =
+        Constants.XERCES_FEATURE_PREFIX + Constants.IGNORE_XSI_TYPE_FEATURE;
+
+    /** Feature identifier: whether to ignore ID/IDREF errors */
+    protected static final String ID_IDREF_CHECKING =
+        Constants.XERCES_FEATURE_PREFIX + Constants.ID_IDREF_CHECKING_FEATURE;
+
+    /** Feature identifier: whether to ignore unparsed entity errors */
+    protected static final String UNPARSED_ENTITY_CHECKING =
+        Constants.XERCES_FEATURE_PREFIX + Constants.UNPARSED_ENTITY_CHECKING_FEATURE;
+
+    /** Feature identifier: whether to ignore identity constraint errors */
+    protected static final String IDENTITY_CONSTRAINT_CHECKING =
+        Constants.XERCES_FEATURE_PREFIX + Constants.IDC_CHECKING_FEATURE;
+
     protected static final String REPORT_WHITESPACE =
             Constants.SUN_SCHEMA_FEATURE_PREFIX + Constants.SUN_REPORT_IGNORED_ELEMENT_CONTENT_WHITESPACE;
 
@@ -228,6 +242,10 @@
     protected static final String JAXP_SCHEMA_LANGUAGE =
         Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE;
 
+    /** Property identifier: root type definition. */
+    protected static final String ROOT_TYPE_DEF =
+        Constants.XERCES_PROPERTY_PREFIX + Constants.ROOT_TYPE_DEFINITION_PROPERTY;
+
     /** Property identifier: Schema DV Factory */
     protected static final String SCHEMA_DV_FACTORY =
         Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_DV_FACTORY_PROPERTY;
@@ -254,6 +272,10 @@
             VALIDATE_ANNOTATIONS,
             HONOUR_ALL_SCHEMALOCATIONS,
             USE_GRAMMAR_POOL_ONLY,
+            IGNORE_XSI_TYPE,
+            ID_IDREF_CHECKING,
+            IDENTITY_CONSTRAINT_CHECKING,
+            UNPARSED_ENTITY_CHECKING,
             NAMESPACE_GROWTH,
             TOLERATE_DUPLICATES,
             USE_SERVICE_MECHANISM
@@ -267,6 +289,10 @@
         //       those set by the application. This goes against the
         //       whole purpose of XMLComponent#getFeatureDefault but
         //       it can't be helped in this case. -Ac
+        // NOTE: Instead of adding default values here, add them (and
+        //       the corresponding recognized features) to the objects
+        //       that have an XMLSchemaValidator instance as a member,
+        //       such as the parser configurations. -PM
         null, //Boolean.FALSE,
         null, //Boolean.FALSE,
         null, //Boolean.FALSE,
@@ -279,6 +305,10 @@
         null,
         null,
         null,
+        null,
+        null,
+        null,
+        null,
         Boolean.TRUE
     };
 
@@ -293,13 +323,14 @@
             SCHEMA_NONS_LOCATION,
             JAXP_SCHEMA_SOURCE,
             JAXP_SCHEMA_LANGUAGE,
+            ROOT_TYPE_DEF,
             SCHEMA_DV_FACTORY,
             XML_SECURITY_PROPERTY_MANAGER
             };
 
     /** Property defaults. */
     private static final Object[] PROPERTY_DEFAULTS =
-        { null, null, null, null, null, null, null, null, null, null, null, null, null};
+        { null, null, null, null, null, null, null, null, null, null, null};
 
     // this is the number of valuestores of each kind
     // we expect an element to have.  It's almost
@@ -482,7 +513,7 @@
 
     // updated during reset
     protected ValidationManager fValidationManager = null;
-    protected ValidationState fValidationState = new ValidationState();
+    protected ConfigurableValidationState fValidationState = new ConfigurableValidationState();
     protected XMLGrammarPool fGrammarPool;
 
     // schema location property values
@@ -562,6 +593,9 @@
      *                                  this exception.
      */
     public void setProperty(String propertyId, Object value) throws XMLConfigurationException {
+        if (propertyId.equals(ROOT_TYPE_DEF)) {
+            fRootTypeQName = (javax.xml.namespace.QName)value;
+        }
     } // setProperty(String,Object)
 
     /**
@@ -1234,6 +1268,12 @@
     /** temporary qname */
     private final QName fTempQName = new QName();
 
+    private javax.xml.namespace.QName fRootTypeQName = null;
+
+    private int fIgnoreXSITypeDepth;
+
+    private boolean fIDCChecking;
+
     /** temporary validated info */
     private ValidatedInfo fValidatedInfo = new ValidatedInfo();
 
@@ -1384,6 +1424,38 @@
         fValidationManager.addValidationState(fValidationState);
         fValidationState.setSymbolTable(fSymbolTable);
 
+        boolean ignoreXSIType;
+        try {
+            ignoreXSIType = componentManager.getFeature(IGNORE_XSI_TYPE);
+        }
+        catch (XMLConfigurationException e) {
+            ignoreXSIType = false;
+        }
+        // An initial value of -1 means that the root element considers itself
+        // below the depth where xsi:type stopped being ignored (which means that
+        // xsi:type attributes will not be ignored for the entire document)
+        fIgnoreXSITypeDepth = ignoreXSIType ? 0 : -1;
+
+        try {
+            fIDCChecking = componentManager.getFeature(IDENTITY_CONSTRAINT_CHECKING);
+        }
+        catch (XMLConfigurationException e) {
+            fIDCChecking = true;
+        }
+
+        try {
+            fValidationState.setIdIdrefChecking(componentManager.getFeature(ID_IDREF_CHECKING));
+        }
+        catch (XMLConfigurationException e) {
+            fValidationState.setIdIdrefChecking(true);
+        }
+
+        try {
+            fValidationState.setUnparsedEntityChecking(componentManager.getFeature(UNPARSED_ENTITY_CHECKING));
+        }
+        catch (XMLConfigurationException e) {
+            fValidationState.setUnparsedEntityChecking(true);
+        }
 
         // get schema location properties
         try {
@@ -1550,7 +1622,9 @@
 
     // handle start document
     void handleStartDocument(XMLLocator locator, String encoding) {
-        fValueStoreCache.startDocument();
+        if (fIDCChecking) {
+            fValueStoreCache.startDocument();
+        }
         if (fAugPSVI) {
             fCurrentPSVI.fGrammars = null;
             fCurrentPSVI.fSchemaInformation = null;
@@ -1558,7 +1632,9 @@
     } // handleStartDocument(XMLLocator,String)
 
     void handleEndDocument() {
-        fValueStoreCache.endDocument();
+        if (fIDCChecking) {
+            fValueStoreCache.endDocument();
+        }
     } // handleEndDocument()
 
     // handle character contents
@@ -1850,22 +1926,54 @@
             return augs;
         }
 
-        // try again to get the element decl:
-        // case 1: find declaration for root element
-        // case 2: find declaration for element from another namespace
-        if (fCurrentElemDecl == null) {
-            if (sGrammar != null) {
-                fCurrentElemDecl = sGrammar.getGlobalElementDecl(element.localpart);
+        // 1.2.1.1 A type definition was stipulated by the processor
+        if (fElementDepth == 0 && fRootTypeQName != null) {
+            String rootTypeNamespace = fRootTypeQName.getNamespaceURI();
+            if (rootTypeNamespace != null && rootTypeNamespace.equals(XMLConstants.NULL_NS_URI)) {
+                rootTypeNamespace = null;
+            }
+            SchemaGrammar grammarForRootType =
+                findSchemaGrammar(
+                        XSDDescription.CONTEXT_ELEMENT, rootTypeNamespace, null, null, null);
+            if (grammarForRootType != null) {
+                fCurrentType = grammarForRootType.getGlobalTypeDecl(fRootTypeQName.getLocalPart());
+            }
+            if (fCurrentType == null) {
+                String typeName = (fRootTypeQName.getPrefix().equals(XMLConstants.DEFAULT_NS_PREFIX)) ?
+                        fRootTypeQName.getLocalPart() :
+                            fRootTypeQName.getPrefix()+":"+fRootTypeQName.getLocalPart();
+                        reportSchemaError("cvc-type.1", new Object[] {typeName});
             }
         }
 
-        if (fCurrentElemDecl != null) {
-            // then get the type
-            fCurrentType = fCurrentElemDecl.fType;
+        // if there was no processor stipulated type
+        if (fCurrentType == null) {
+            // try again to get the element decl:
+            // case 1: find declaration for root element
+            // case 2: find declaration for element from another namespace
+            if (fCurrentElemDecl == null) {
+                if (sGrammar != null) {
+                    fCurrentElemDecl = sGrammar.getGlobalElementDecl(element.localpart);
+                }
+            }
+
+            if (fCurrentElemDecl != null) {
+                // then get the type
+                fCurrentType = fCurrentElemDecl.fType;
+            }
         }
 
-        // get type from xsi:type
-        String xsiType = attributes.getValue(SchemaSymbols.URI_XSI, SchemaSymbols.XSI_TYPE);
+
+        // check if we should be ignoring xsi:type on this element
+        if (fElementDepth == fIgnoreXSITypeDepth && fCurrentElemDecl == null) {
+            fIgnoreXSITypeDepth++;
+        }
+
+        // process xsi:type attribute information
+        String xsiType = null;
+        if (fElementDepth >= fIgnoreXSITypeDepth) {
+            xsiType = attributes.getValue(SchemaSymbols.URI_XSI, SchemaSymbols.XSI_TYPE);
+        }
 
         // if no decl/type found for the current element
         if (fCurrentType == null && xsiType == null) {
@@ -2044,13 +2152,17 @@
             XSComplexTypeDecl ctype = (XSComplexTypeDecl) fCurrentType;
             attrGrp = ctype.getAttrGrp();
         }
-        // activate identity constraints
-        fValueStoreCache.startElement();
-        fMatcherStack.pushContext();
-        if (fCurrentElemDecl != null && fCurrentElemDecl.fIDCPos > 0) {
-            fIdConstraint = true;
-            // initialize when identity constrains are defined for the elem
-            fValueStoreCache.initValueStoresFor(fCurrentElemDecl, this);
+
+        if (fIDCChecking) {
+            // activate identity constraints
+            fValueStoreCache.startElement();
+            fMatcherStack.pushContext();
+            //if (fCurrentElemDecl != null && fCurrentElemDecl.fIDCPos > 0 && !fIgnoreIDC) {
+            if (fCurrentElemDecl != null && fCurrentElemDecl.fIDCPos > 0) {
+                fIdConstraint = true;
+                // initialize when identity constrains are defined for the elem
+                fValueStoreCache.initValueStoresFor(fCurrentElemDecl, this);
+            }
         }
         processAttributes(element, attributes, attrGrp);
 
@@ -2138,66 +2250,75 @@
         // now validate the content of the element
         processElementContent(element);
 
-        // Element Locally Valid (Element)
-        // 6 The element information item must be valid with respect to each of the {identity-constraint definitions} as per Identity-constraint Satisfied (3.11.4).
-
-        // call matchers and de-activate context
-        int oldCount = fMatcherStack.getMatcherCount();
-        for (int i = oldCount - 1; i >= 0; i--) {
-            XPathMatcher matcher = fMatcherStack.getMatcherAt(i);
-            if (fCurrentElemDecl == null)
-                matcher.endElement(element, null, false, fValidatedInfo.actualValue, fValidatedInfo.actualValueType, fValidatedInfo.itemValueTypes);
-
-            else
-                matcher.endElement(
-                    element,
-                    fCurrentType,
-                    fCurrentElemDecl.getNillable(),
-                    fDefaultValue == null
-                        ? fValidatedInfo.actualValue
-                        : fCurrentElemDecl.fDefault.actualValue,
-                    fDefaultValue == null
-                        ? fValidatedInfo.actualValueType
-                        : fCurrentElemDecl.fDefault.actualValueType,
-                    fDefaultValue == null
-                        ? fValidatedInfo.itemValueTypes
-                        : fCurrentElemDecl.fDefault.itemValueTypes);
-        }
-
-        if (fMatcherStack.size() > 0) {
-            fMatcherStack.popContext();
-        }
-
-        int newCount = fMatcherStack.getMatcherCount();
-        // handle everything *but* keyref's.
-        for (int i = oldCount - 1; i >= newCount; i--) {
-            XPathMatcher matcher = fMatcherStack.getMatcherAt(i);
-            if (matcher instanceof Selector.Matcher) {
-                Selector.Matcher selMatcher = (Selector.Matcher) matcher;
-                IdentityConstraint id;
-                if ((id = selMatcher.getIdentityConstraint()) != null
-                    && id.getCategory() != IdentityConstraint.IC_KEYREF) {
-                    fValueStoreCache.transplant(id, selMatcher.getInitialDepth());
+        if (fIDCChecking) {
+            // Element Locally Valid (Element)
+            // 6 The element information item must be valid with respect to each of the {identity-constraint definitions} as per Identity-constraint Satisfied (3.11.4).
+
+            // call matchers and de-activate context
+            int oldCount = fMatcherStack.getMatcherCount();
+            for (int i = oldCount - 1; i >= 0; i--) {
+                XPathMatcher matcher = fMatcherStack.getMatcherAt(i);
+                if (fCurrentElemDecl == null)
+                    matcher.endElement(element, null, false, fValidatedInfo.actualValue, fValidatedInfo.actualValueType, fValidatedInfo.itemValueTypes);
+
+                else
+                    matcher.endElement(
+                            element,
+                            fCurrentType,
+                            fCurrentElemDecl.getNillable(),
+                            fDefaultValue == null
+                                ? fValidatedInfo.actualValue
+                                : fCurrentElemDecl.fDefault.actualValue,
+                            fDefaultValue == null
+                                ? fValidatedInfo.actualValueType
+                                : fCurrentElemDecl.fDefault.actualValueType,
+                            fDefaultValue == null
+                                ? fValidatedInfo.itemValueTypes
+                                : fCurrentElemDecl.fDefault.itemValueTypes);
+            }
+
+            if (fMatcherStack.size() > 0) {
+                fMatcherStack.popContext();
+            }
+
+            int newCount = fMatcherStack.getMatcherCount();
+            // handle everything *but* keyref's.
+            for (int i = oldCount - 1; i >= newCount; i--) {
+                XPathMatcher matcher = fMatcherStack.getMatcherAt(i);
+                if (matcher instanceof Selector.Matcher) {
+                    Selector.Matcher selMatcher = (Selector.Matcher) matcher;
+                    IdentityConstraint id;
+                    if ((id = selMatcher.getIdentityConstraint()) != null
+                            && id.getCategory() != IdentityConstraint.IC_KEYREF) {
+                        fValueStoreCache.transplant(id, selMatcher.getInitialDepth());
+                    }
                 }
             }
-        }
-
-        // now handle keyref's/...
-        for (int i = oldCount - 1; i >= newCount; i--) {
-            XPathMatcher matcher = fMatcherStack.getMatcherAt(i);
-            if (matcher instanceof Selector.Matcher) {
-                Selector.Matcher selMatcher = (Selector.Matcher) matcher;
-                IdentityConstraint id;
-                if ((id = selMatcher.getIdentityConstraint()) != null
-                    && id.getCategory() == IdentityConstraint.IC_KEYREF) {
-                    ValueStoreBase values =
-                        fValueStoreCache.getValueStoreFor(id, selMatcher.getInitialDepth());
-                    if (values != null) // nothing to do if nothing matched!
-                        values.endDocumentFragment();
+
+            // now handle keyref's/...
+            for (int i = oldCount - 1; i >= newCount; i--) {
+                XPathMatcher matcher = fMatcherStack.getMatcherAt(i);
+                if (matcher instanceof Selector.Matcher) {
+                    Selector.Matcher selMatcher = (Selector.Matcher) matcher;
+                    IdentityConstraint id;
+                    if ((id = selMatcher.getIdentityConstraint()) != null
+                            && id.getCategory() == IdentityConstraint.IC_KEYREF) {
+                        ValueStoreBase values =
+                            fValueStoreCache.getValueStoreFor(id, selMatcher.getInitialDepth());
+                        if (values != null) // nothing to do if nothing matched!
+                            values.endDocumentFragment();
+                    }
                 }
             }
+            fValueStoreCache.endElement();
         }
-        fValueStoreCache.endElement();
+
+        // Check if we should modify the xsi:type ignore depth
+        // This check is independent of whether this is the validation root,
+        // and should be done before the element depth is decremented.
+        if (fElementDepth < fIgnoreXSITypeDepth) {
+            fIgnoreXSITypeDepth--;
+        }
 
         SchemaGrammar[] grammars = null;
         // have we reached the end tag of the validation root?
@@ -2290,7 +2411,14 @@
             // otherwise partial, and anything above this level will be partial
             else {
                 fCurrentPSVI.fValidationAttempted = ElementPSVI.VALIDATION_PARTIAL;
-                fNFullValidationDepth = fNNoneValidationDepth = fElementDepth - 1;
+            }
+
+            // this guarantees that depth settings do not cross-over between sibling nodes
+            if (fNFullValidationDepth == fElementDepth) {
+                fNFullValidationDepth = fElementDepth - 1;
+            }
+            if (fNNoneValidationDepth == fElementDepth) {
+                fNNoneValidationDepth = fElementDepth - 1;
             }
 
             if (fDefaultValue != null)
@@ -2554,14 +2682,22 @@
         // if there is no current type, set this one as current.
         // and we don't need to do extra checking
         if (fCurrentType != null) {
+            short block = XSConstants.DERIVATION_NONE;
             // 4.3 The local type definition must be validly derived from the {type definition} given the union of the {disallowed substitutions} and the {type definition}'s {prohibited substitutions}, as defined in Type Derivation OK (Complex) (3.4.6) (if it is a complex type definition), or given {disallowed substitutions} as defined in Type Derivation OK (Simple) (3.14.6) (if it is a simple type definition).
-            short block = fCurrentElemDecl.fBlock;
-            if (fCurrentType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE)
+            // Note: It's possible to have fCurrentType be non-null and fCurrentElemDecl
+            // be null, if the current type is set using the property "root-type-definition".
+            // In that case, we don't disallow any substitutions. -PM
+            if (fCurrentElemDecl != null) {
+                block = fCurrentElemDecl.fBlock;
+            }
+            if (fCurrentType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
                 block |= ((XSComplexTypeDecl) fCurrentType).fBlock;
-            if (!XSConstraints.checkTypeDerivationOk(type, fCurrentType, block))
+            }
+            if (!XSConstraints.checkTypeDerivationOk(type, fCurrentType, block)) {
                 reportSchemaError(
-                    "cvc-elt.4.3",
-                    new Object[] { element.rawname, xsiType, fCurrentType.getName()});
+                        "cvc-elt.4.3",
+                        new Object[] { element.rawname, xsiType, fCurrentType.getName()});
+            }
         }
 
         return type;
@@ -2835,9 +2971,10 @@
         }
 
         // get the value constraint from use or decl
-        // 4 The item's actual value must match the value of the {value constraint}, if it is present and fixed.                 // now check the value against the simpleType
+        // 4 The item's actual value must match the value of the {value constraint}, if it is present and fixed.
+        // now check the value against the simpleType
         if (actualValue != null && currDecl.getConstraintType() == XSConstants.VC_FIXED) {
-            if (!isComparable(fValidatedInfo, currDecl.fDefault) || !actualValue.equals(currDecl.fDefault.actualValue)) {
+            if (!ValidatedInfo.isComparable(fValidatedInfo, currDecl.fDefault) || !actualValue.equals(currDecl.fDefault.actualValue)) {
                 reportSchemaError(
                     "cvc-attribute.4",
                     new Object[] {
@@ -2852,7 +2989,7 @@
         if (actualValue != null
             && currUse != null
             && currUse.fConstraintType == XSConstants.VC_FIXED) {
-            if (!isComparable(fValidatedInfo, currUse.fDefault) || !actualValue.equals(currUse.fDefault.actualValue)) {
+            if (!ValidatedInfo.isComparable(fValidatedInfo, currUse.fDefault) || !actualValue.equals(currUse.fDefault.actualValue)) {
                 reportSchemaError(
                     "cvc-complex-type.3.1",
                     new Object[] {
@@ -3083,7 +3220,7 @@
                     }
                     // 5.2.2.2.2 If the {content type} of the actual type definition is a simple type definition, then the actual value of the item must match the canonical lexical representation of the {value constraint} value.
                     else if (ctype.fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
-                        if (actualValue != null && (!isComparable(fValidatedInfo, fCurrentElemDecl.fDefault)
+                        if (actualValue != null && (!ValidatedInfo.isComparable(fValidatedInfo, fCurrentElemDecl.fDefault)
                                 || !actualValue.equals(fCurrentElemDecl.fDefault.actualValue))) {
                             reportSchemaError(
                                 "cvc-elt.5.2.2.2.2",
@@ -3094,7 +3231,7 @@
                         }
                     }
                 } else if (fCurrentType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
-                    if (actualValue != null && (!isComparable(fValidatedInfo, fCurrentElemDecl.fDefault)
+                    if (actualValue != null && (!ValidatedInfo.isComparable(fValidatedInfo, fCurrentElemDecl.fDefault)
                             || !actualValue.equals(fCurrentElemDecl.fDefault.actualValue))) {
                         // REVISIT: the spec didn't mention this case: fixed
                         //          value with simple type
@@ -3240,53 +3377,6 @@
                 XMLErrorReporter.SEVERITY_ERROR);
     }
 
-    /** Returns true if the two ValidatedInfo objects can be compared in the same value space. **/
-    private boolean isComparable(ValidatedInfo info1, ValidatedInfo info2) {
-        final short primitiveType1 = convertToPrimitiveKind(info1.actualValueType);
-        final short primitiveType2 = convertToPrimitiveKind(info2.actualValueType);
-        if (primitiveType1 != primitiveType2) {
-            return (primitiveType1 == XSConstants.ANYSIMPLETYPE_DT && primitiveType2 == XSConstants.STRING_DT ||
-                    primitiveType1 == XSConstants.STRING_DT && primitiveType2 == XSConstants.ANYSIMPLETYPE_DT);
-        }
-        else if (primitiveType1 == XSConstants.LIST_DT || primitiveType1 == XSConstants.LISTOFUNION_DT) {
-            final ShortList typeList1 = info1.itemValueTypes;
-            final ShortList typeList2 = info2.itemValueTypes;
-            final int typeList1Length = typeList1 != null ? typeList1.getLength() : 0;
-            final int typeList2Length = typeList2 != null ? typeList2.getLength() : 0;
-            if (typeList1Length != typeList2Length) {
-                return false;
-            }
-            for (int i = 0; i < typeList1Length; ++i) {
-                final short primitiveItem1 = convertToPrimitiveKind(typeList1.item(i));
-                final short primitiveItem2 = convertToPrimitiveKind(typeList2.item(i));
-                if (primitiveItem1 != primitiveItem2) {
-                    if (primitiveItem1 == XSConstants.ANYSIMPLETYPE_DT && primitiveItem2 == XSConstants.STRING_DT ||
-                        primitiveItem1 == XSConstants.STRING_DT && primitiveItem2 == XSConstants.ANYSIMPLETYPE_DT) {
-                        continue;
-                    }
-                    return false;
-                }
-            }
-        }
-        return true;
-    }
-
-    private short convertToPrimitiveKind(short valueType) {
-        /** Primitive datatypes. */
-        if (valueType <= XSConstants.NOTATION_DT) {
-            return valueType;
-        }
-        /** Types derived from string. */
-        if (valueType <= XSConstants.ENTITY_DT) {
-            return XSConstants.STRING_DT;
-        }
-        /** Types derived from decimal. */
-        if (valueType <= XSConstants.POSITIVEINTEGER_DT) {
-            return XSConstants.DECIMAL_DT;
-        }
-        /** Other types. */
-        return valueType;
-    }
 
     private String expectedStr(Vector expected) {
         StringBuffer ret = new StringBuffer("{");
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchema.java	Mon Aug 18 10:08:34 2014 +0100
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchema.java	Fri Aug 29 11:49:38 2014 -0700
@@ -1,13 +1,10 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * Copyright 2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * 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
  *
@@ -32,11 +29,19 @@
     /** The grammar pool is immutable */
     private final XMLGrammarPool fGrammarPool;
 
+    /** Whether to consider this schema to be fully composed */
+    private final boolean fFullyComposed;
+
     /** Constructor */
     public XMLSchema(XMLGrammarPool grammarPool) {
-        fGrammarPool = grammarPool;
+        this(grammarPool, true);
     }
 
+    public XMLSchema(XMLGrammarPool grammarPool, boolean fullyComposed) {
+         fGrammarPool = grammarPool;
+        fFullyComposed = fullyComposed;
+     }
+
     /*
      * XSGrammarPoolContainer methods
      */
@@ -60,7 +65,7 @@
      * can be considered to be a fully composed schema
      */
     public boolean isFullyComposed() {
-        return true;
+        return fFullyComposed;
     }
 
 } // XMLSchema
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java	Mon Aug 18 10:08:34 2014 +0100
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java	Fri Aug 29 11:49:38 2014 -0700
@@ -1,13 +1,10 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * Copyright 2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * 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
  *
@@ -68,12 +65,21 @@
  */
 public final class XMLSchemaFactory extends SchemaFactory {
 
-    // property identifiers
+    // feature identifiers
+
+    /** JAXP Source feature prefix. */
+    private static final String JAXP_SOURCE_FEATURE_PREFIX = "http://javax.xml.transform";
 
     /** Feature identifier: schema full checking. */
     private static final String SCHEMA_FULL_CHECKING =
         Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_FULL_CHECKING;
 
+    /** Feature identifier: use grammar pool only. */
+    private static final String USE_GRAMMAR_POOL_ONLY =
+        Constants.XERCES_FEATURE_PREFIX + Constants.USE_GRAMMAR_POOL_ONLY_FEATURE;
+
+    // property identifiers
+
     /** Property identifier: grammar pool. */
     private static final String XMLGRAMMAR_POOL =
         Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY;
@@ -104,7 +110,7 @@
     private final DOMEntityResolverWrapper fDOMEntityResolverWrapper;
 
     /** The ErrorHandlerWrapper */
-    private ErrorHandlerWrapper fErrorHandlerWrapper;
+    private final ErrorHandlerWrapper fErrorHandlerWrapper;
 
     /** The SecurityManager. */
     private XMLSecurityManager fSecurityManager;
@@ -113,7 +119,10 @@
     private XMLSecurityPropertyManager fSecurityPropertyMgr;
 
     /** The container for the real grammar pool. */
-    private XMLGrammarPoolWrapper fXMLGrammarPoolWrapper;
+    private final XMLGrammarPoolWrapper fXMLGrammarPoolWrapper;
+
+    /** Whether or not to allow new schemas to be added to the grammar pool */
+    private boolean fUseGrammarPoolOnly;
 
     /**
      * Indicates whether implementation parts should use
@@ -138,6 +147,7 @@
         fXMLSchemaLoader.setProperty(XMLGRAMMAR_POOL, fXMLGrammarPoolWrapper);
         fXMLSchemaLoader.setEntityResolver(fDOMEntityResolverWrapper);
         fXMLSchemaLoader.setErrorHandler(fErrorHandlerWrapper);
+        fUseGrammarPoolOnly = true;
 
         // Enable secure processing feature by default
         fSecurityManager = new XMLSecurityManager(true);
@@ -170,7 +180,8 @@
                     "SchemaLanguageLengthZero", null));
         }
         // only W3C XML Schema 1.0 is supported
-        return schemaLanguage.equals(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+        return schemaLanguage.equals(XMLConstants.W3C_XML_SCHEMA_NS_URI) ||
+                schemaLanguage.equals(Constants.W3C_XML_SCHEMA10_NS_URI);
     }
 
     public LSResourceResolver getResourceResolver() {
@@ -202,7 +213,7 @@
         XMLInputSource[] xmlInputSources = new XMLInputSource[schemas.length];
         InputStream inputStream;
         Reader reader;
-        for( int i=0; i<schemas.length; i++ ) {
+        for (int i = 0; i < schemas.length; ++i) {
             Source source = schemas[i];
             if (source instanceof StreamSource) {
                 StreamSource streamSource = (StreamSource) source;
@@ -210,9 +221,10 @@
                 String systemId = streamSource.getSystemId();
                 inputStream = streamSource.getInputStream();
                 reader = streamSource.getReader();
-                xmlInputSources[i] = new XMLInputSource(publicId, systemId, null);
-                xmlInputSources[i].setByteStream(inputStream);
-                xmlInputSources[i].setCharacterStream(reader);
+                XMLInputSource xmlInputSource = new XMLInputSource(publicId, systemId, null);
+                xmlInputSource.setByteStream(inputStream);
+                xmlInputSource.setCharacterStream(reader);
+                xmlInputSources[i] = xmlInputSource;
             }
             else if (source instanceof SAXSource) {
                 SAXSource saxSource = (SAXSource) source;
@@ -260,7 +272,9 @@
         catch (IOException e) {
             // this hasn't been reported, so do so now.
             SAXParseException se = new SAXParseException(e.getMessage(),null,e);
-            fErrorHandler.error(se);
+            if (fErrorHandler != null) {
+                fErrorHandler.error(se);
+            }
             throw se; // and we must throw it.
         }
 
@@ -270,15 +284,20 @@
         // Select Schema implementation based on grammar count.
         final int grammarCount = pool.getGrammarCount();
         AbstractXMLSchema schema = null;
-        if (grammarCount > 1) {
-            schema = new XMLSchema(new ReadOnlyGrammarPool(pool));
-        }
-        else if (grammarCount == 1) {
-            Grammar[] grammars = pool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA);
-            schema = new SimpleXMLSchema(grammars[0]);
+        if (fUseGrammarPoolOnly) {
+            if (grammarCount > 1) {
+                schema = new XMLSchema(new ReadOnlyGrammarPool(pool));
+            }
+            else if (grammarCount == 1) {
+                Grammar[] grammars = pool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA);
+                schema = new SimpleXMLSchema(grammars[0]);
+            }
+            else {
+                schema = new EmptyXMLSchema();
+            }
         }
         else {
-            schema = new EmptyXMLSchema();
+            schema = new XMLSchema(new ReadOnlyGrammarPool(pool), false);
         }
         propagateFeatures(schema);
         propagateProperties(schema);
@@ -286,6 +305,14 @@
     }
 
     public Schema newSchema() throws SAXException {
+        /*
+         * It would make sense to return an EmptyXMLSchema object here, if
+         * fUseGrammarPoolOnly is set to true. However, because the default
+         * value of this feature is true, doing so would change the default
+         * behaviour of this method. Thus, we return a WeakReferenceXMLSchema
+         * regardless of the value of fUseGrammarPoolOnly. -PM
+         */
+
         // Use a Schema that uses the system id as the equality source.
         AbstractXMLSchema schema = new WeakReferenceXMLSchema();
         propagateFeatures(schema);
@@ -293,15 +320,38 @@
         return schema;
     }
 
+    public Schema newSchema(XMLGrammarPool pool) throws SAXException {
+        // If the "use-grammar-pool-only" feature is set to true
+        // prevent the application's grammar pool from being mutated
+        // by wrapping it in a ReadOnlyGrammarPool.
+        final AbstractXMLSchema schema = (fUseGrammarPoolOnly) ?
+            new XMLSchema(new ReadOnlyGrammarPool(pool)) :
+            new XMLSchema(pool, false);
+        propagateFeatures(schema);
+        return schema;
+    }
+
     public boolean getFeature(String name)
         throws SAXNotRecognizedException, SAXNotSupportedException {
         if (name == null) {
             throw new NullPointerException(JAXPValidationMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
                     "FeatureNameNull", null));
         }
+        if (name.startsWith(JAXP_SOURCE_FEATURE_PREFIX)) {
+            // Indicates to the caller that this SchemaFactory supports a specific JAXP Source.
+            if (name.equals(StreamSource.FEATURE) ||
+                name.equals(SAXSource.FEATURE) ||
+                name.equals(DOMSource.FEATURE) ||
+                name.equals(StAXSource.FEATURE)) {
+                return true;
+            }
+        }
         if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
             return (fSecurityManager != null && fSecurityManager.isSecureProcessing());
         }
+        else if (name.equals(USE_GRAMMAR_POOL_ONLY)) {
+            return fUseGrammarPoolOnly;
+        }
         try {
             return fXMLSchemaLoader.getFeature(name);
         }
@@ -358,6 +408,16 @@
             throw new NullPointerException(JAXPValidationMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
                     "FeatureNameNull", null));
         }
+        if (name.startsWith(JAXP_SOURCE_FEATURE_PREFIX)) {
+            if (name.equals(StreamSource.FEATURE) ||
+                name.equals(SAXSource.FEATURE) ||
+                name.equals(DOMSource.FEATURE) ||
+                name.equals(StAXSource.FEATURE)) {
+                throw new SAXNotSupportedException(
+                        SAXMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
+                        "feature-read-only", new Object [] {name}));
+            }
+        }
         if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
             if (System.getSecurityManager() != null && (!value)) {
                 throw new SAXNotSupportedException(
@@ -377,7 +437,12 @@
 
             fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
             return;
-        } else if (name.equals(Constants.ORACLE_FEATURE_SERVICE_MECHANISM)) {
+        }
+        else if (name.equals(USE_GRAMMAR_POOL_ONLY)) {
+            fUseGrammarPoolOnly = value;
+            return;
+        }
+        else if (name.equals(Constants.ORACLE_FEATURE_SERVICE_MECHANISM)) {
             //in secure mode, let _useServicesMechanism be determined by the constructor
             if (System.getSecurityManager() != null)
                 return;
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java	Mon Aug 18 10:08:34 2014 +0100
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java	Fri Aug 29 11:49:38 2014 -0700
@@ -1,13 +1,10 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * Copyright 2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * 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
  *
@@ -69,13 +66,41 @@
     private static final String VALIDATION =
         Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE;
 
+    /** Feature identifier: use grammar pool only. */
+    private static final String USE_GRAMMAR_POOL_ONLY =
+        Constants.XERCES_FEATURE_PREFIX + Constants.USE_GRAMMAR_POOL_ONLY_FEATURE;
+
+    /** Feature identifier: whether to ignore xsi:type attributes until a global element declaration is encountered */
+    protected static final String IGNORE_XSI_TYPE =
+        Constants.XERCES_FEATURE_PREFIX + Constants.IGNORE_XSI_TYPE_FEATURE;
+
+    /** Feature identifier: whether to ignore ID/IDREF errors */
+    protected static final String ID_IDREF_CHECKING =
+        Constants.XERCES_FEATURE_PREFIX + Constants.ID_IDREF_CHECKING_FEATURE;
+
+    /** Feature identifier: whether to ignore unparsed entity errors */
+    protected static final String UNPARSED_ENTITY_CHECKING =
+        Constants.XERCES_FEATURE_PREFIX + Constants.UNPARSED_ENTITY_CHECKING_FEATURE;
+
+    /** Feature identifier: whether to ignore identity constraint errors */
+    protected static final String IDENTITY_CONSTRAINT_CHECKING =
+        Constants.XERCES_FEATURE_PREFIX + Constants.IDC_CHECKING_FEATURE;
+
+    /** Feature identifier: disallow DOCTYPE declaration */
+    private static final String DISALLOW_DOCTYPE_DECL_FEATURE =
+        Constants.XERCES_FEATURE_PREFIX + Constants.DISALLOW_DOCTYPE_DECL_FEATURE;
+
+    /** Feature identifier: expose schema normalized value */
+    private static final String NORMALIZE_DATA =
+        Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_NORMALIZED_VALUE;
+
     /** Feature identifier: send element default value via characters() */
     private static final String SCHEMA_ELEMENT_DEFAULT =
         Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_ELEMENT_DEFAULT;
 
-    /** Feature identifier: use grammar pool only. */
-    private static final String USE_GRAMMAR_POOL_ONLY =
-        Constants.XERCES_FEATURE_PREFIX + Constants.USE_GRAMMAR_POOL_ONLY_FEATURE;
+    /** Feature identifier: augment PSVI */
+    private static final String SCHEMA_AUGMENT_PSVI =
+        Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_AUGMENT_PSVI;
 
     // property identifiers
 
@@ -230,10 +255,32 @@
         fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, new XSMessageFormatter());
 
         // add all recognized features and properties and apply their defaults
+        final String [] recognizedFeatures = {
+                DISALLOW_DOCTYPE_DECL_FEATURE,
+                NORMALIZE_DATA,
+                SCHEMA_ELEMENT_DEFAULT,
+                SCHEMA_AUGMENT_PSVI
+        };
+        addRecognizedFeatures(recognizedFeatures);
+        fFeatures.put(DISALLOW_DOCTYPE_DECL_FEATURE, Boolean.FALSE);
+        fFeatures.put(NORMALIZE_DATA, Boolean.FALSE);
+        fFeatures.put(SCHEMA_ELEMENT_DEFAULT, Boolean.FALSE);
+        fFeatures.put(SCHEMA_AUGMENT_PSVI, Boolean.TRUE);
+
         addRecognizedParamsAndSetDefaults(fEntityManager, grammarContainer);
         addRecognizedParamsAndSetDefaults(fErrorReporter, grammarContainer);
         addRecognizedParamsAndSetDefaults(fSchemaValidator, grammarContainer);
 
+        /* TODO: are other XMLSchemaValidator default values never set?
+         * Initial investigation indicates that they aren't set, but
+         * that they all have default values of false, so it works out
+         * anyway -PM
+         */
+        fFeatures.put(IGNORE_XSI_TYPE, Boolean.FALSE);
+        fFeatures.put(ID_IDREF_CHECKING, Boolean.TRUE);
+        fFeatures.put(IDENTITY_CONSTRAINT_CHECKING, Boolean.TRUE);
+        fFeatures.put(UNPARSED_ENTITY_CHECKING, Boolean.TRUE);
+
         boolean secureProcessing = grammarContainer.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING);
         if (System.getSecurityManager() != null) {
             _isSecureMode = true;
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/StandardParserConfiguration.java	Mon Aug 18 10:08:34 2014 +0100
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/StandardParserConfiguration.java	Fri Aug 29 11:49:38 2014 -0700
@@ -1,13 +1,10 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * 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
  *
@@ -109,6 +106,22 @@
     protected static final String HONOUR_ALL_SCHEMALOCATIONS =
         Constants.XERCES_FEATURE_PREFIX + Constants.HONOUR_ALL_SCHEMALOCATIONS_FEATURE;
 
+    /** Feature identifier: whether to ignore xsi:type attributes until a global element declaration is encountered */
+    protected static final String IGNORE_XSI_TYPE =
+        Constants.XERCES_FEATURE_PREFIX + Constants.IGNORE_XSI_TYPE_FEATURE;
+
+    /** Feature identifier: whether to ignore ID/IDREF errors */
+    protected static final String ID_IDREF_CHECKING =
+        Constants.XERCES_FEATURE_PREFIX + Constants.ID_IDREF_CHECKING_FEATURE;
+
+    /** Feature identifier: whether to ignore unparsed entity errors */
+    protected static final String UNPARSED_ENTITY_CHECKING =
+        Constants.XERCES_FEATURE_PREFIX + Constants.UNPARSED_ENTITY_CHECKING_FEATURE;
+
+    /** Feature identifier: whether to ignore identity constraint errors */
+    protected static final String IDENTITY_CONSTRAINT_CHECKING =
+        Constants.XERCES_FEATURE_PREFIX + Constants.IDC_CHECKING_FEATURE;
+
     /** Feature identifier: namespace growth */
     protected static final String NAMESPACE_GROWTH =
         Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACE_GROWTH_FEATURE;
@@ -135,6 +148,10 @@
     protected static final String SCHEMA_DV_FACTORY =
         Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_DV_FACTORY_PROPERTY;
 
+    /** Property identifier: root type definition. */
+    protected static final String ROOT_TYPE_DEF =
+        Constants.XERCES_PROPERTY_PREFIX + Constants.ROOT_TYPE_DEFINITION_PROPERTY;
+
     //
     // Data
     //
@@ -211,6 +228,10 @@
             //       not-recognized exception to be thrown. -Ac
             XMLSCHEMA_VALIDATION,
             XMLSCHEMA_FULL_CHECKING,
+            IGNORE_XSI_TYPE,
+            ID_IDREF_CHECKING,
+            IDENTITY_CONSTRAINT_CHECKING,
+            UNPARSED_ENTITY_CHECKING,
         };
         addRecognizedFeatures(recognizedFeatures);
 
@@ -221,6 +242,10 @@
         setFeature(GENERATE_SYNTHETIC_ANNOTATIONS, false);
         setFeature(VALIDATE_ANNOTATIONS, false);
         setFeature(HONOUR_ALL_SCHEMALOCATIONS, false);
+        setFeature(IGNORE_XSI_TYPE, false);
+        setFeature(ID_IDREF_CHECKING, true);
+        setFeature(IDENTITY_CONSTRAINT_CHECKING, true);
+        setFeature(UNPARSED_ENTITY_CHECKING, true);
         setFeature(NAMESPACE_GROWTH, false);
         setFeature(TOLERATE_DUPLICATES, false);
 
@@ -233,11 +258,11 @@
             //       not-recognized exception to be thrown. -Ac
             SCHEMA_LOCATION,
             SCHEMA_NONS_LOCATION,
+            ROOT_TYPE_DEF,
             SCHEMA_DV_FACTORY,
-            };
+        };
 
-                        addRecognizedProperties(recognizedProperties);
-
+        addRecognizedProperties(recognizedProperties);
     } // <init>(SymbolTable,XMLGrammarPool)
 
     //
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java	Mon Aug 18 10:08:34 2014 +0100
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java	Fri Aug 29 11:49:38 2014 -0700
@@ -1,13 +1,10 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * Copyright 2001-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * 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
  *
@@ -184,7 +181,21 @@
         protected static final String EXTERNAL_PARAMETER_ENTITIES =
                 Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE;
 
+        /** Feature identifier: whether to ignore xsi:type attributes until a global element declaration is encountered */
+        protected static final String IGNORE_XSI_TYPE =
+            Constants.XERCES_FEATURE_PREFIX + Constants.IGNORE_XSI_TYPE_FEATURE;
 
+        /** Feature identifier: whether to ignore ID/IDREF errors */
+        protected static final String ID_IDREF_CHECKING =
+            Constants.XERCES_FEATURE_PREFIX + Constants.ID_IDREF_CHECKING_FEATURE;
+
+        /** Feature identifier: whether to ignore unparsed entity errors */
+        protected static final String UNPARSED_ENTITY_CHECKING =
+            Constants.XERCES_FEATURE_PREFIX + Constants.UNPARSED_ENTITY_CHECKING_FEATURE;
+
+        /** Feature identifier: whether to ignore identity constraint errors */
+        protected static final String IDENTITY_CONSTRAINT_CHECKING =
+            Constants.XERCES_FEATURE_PREFIX + Constants.IDC_CHECKING_FEATURE;
 
     // property identifiers
 
@@ -267,6 +278,10 @@
     protected static final String JAXP_SCHEMA_SOURCE =
         Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE;
 
+    /** Property identifier: root type definition. */
+    protected static final String ROOT_TYPE_DEF =
+        Constants.XERCES_PROPERTY_PREFIX + Constants.ROOT_TYPE_DEFINITION_PROPERTY;
+
     /** Property identifier: locale. */
     protected static final String LOCALE =
         Constants.XERCES_PROPERTY_PREFIX + Constants.LOCALE_PROPERTY;
@@ -467,25 +482,27 @@
 
         // add default recognized features
         final String[] recognizedFeatures =
-            {
-                CONTINUE_AFTER_FATAL_ERROR, LOAD_EXTERNAL_DTD, // from XMLDTDScannerImpl
-                VALIDATION,
-                NAMESPACES,
-                NORMALIZE_DATA, SCHEMA_ELEMENT_DEFAULT, SCHEMA_AUGMENT_PSVI,
-                GENERATE_SYNTHETIC_ANNOTATIONS, VALIDATE_ANNOTATIONS,
-                HONOUR_ALL_SCHEMALOCATIONS, NAMESPACE_GROWTH,
-                TOLERATE_DUPLICATES,
-                USE_GRAMMAR_POOL_ONLY,
-                // NOTE: These shouldn't really be here but since the XML Schema
-                //       validator is constructed dynamically, its recognized
-                //       features might not have been set and it would cause a
-                //       not-recognized exception to be thrown. -Ac
-                XMLSCHEMA_VALIDATION, XMLSCHEMA_FULL_CHECKING,
-                EXTERNAL_GENERAL_ENTITIES,
-                EXTERNAL_PARAMETER_ENTITIES,
-                PARSER_SETTINGS,
-                XMLConstants.FEATURE_SECURE_PROCESSING
-                        };
+        {
+            CONTINUE_AFTER_FATAL_ERROR, LOAD_EXTERNAL_DTD, // from XMLDTDScannerImpl
+            VALIDATION,
+            NAMESPACES,
+            NORMALIZE_DATA, SCHEMA_ELEMENT_DEFAULT, SCHEMA_AUGMENT_PSVI,
+            GENERATE_SYNTHETIC_ANNOTATIONS, VALIDATE_ANNOTATIONS,
+            HONOUR_ALL_SCHEMALOCATIONS, IGNORE_XSI_TYPE,
+            ID_IDREF_CHECKING, IDENTITY_CONSTRAINT_CHECKING,
+            UNPARSED_ENTITY_CHECKING,
+            NAMESPACE_GROWTH, TOLERATE_DUPLICATES,
+            USE_GRAMMAR_POOL_ONLY,
+            // NOTE: These shouldn't really be here but since the XML Schema
+            //       validator is constructed dynamically, its recognized
+            //       features might not have been set and it would cause a
+            //       not-recognized exception to be thrown. -Ac
+            XMLSCHEMA_VALIDATION, XMLSCHEMA_FULL_CHECKING,
+            EXTERNAL_GENERAL_ENTITIES,
+            EXTERNAL_PARAMETER_ENTITIES,
+            PARSER_SETTINGS,
+            XMLConstants.FEATURE_SECURE_PROCESSING
+        };
         addRecognizedFeatures(recognizedFeatures);
         // set state for default features
         fFeatures.put(VALIDATION, Boolean.FALSE);
@@ -500,6 +517,10 @@
         fFeatures.put(GENERATE_SYNTHETIC_ANNOTATIONS, Boolean.FALSE);
         fFeatures.put(VALIDATE_ANNOTATIONS, Boolean.FALSE);
         fFeatures.put(HONOUR_ALL_SCHEMALOCATIONS, Boolean.FALSE);
+        fFeatures.put(IGNORE_XSI_TYPE, Boolean.FALSE);
+        fFeatures.put(ID_IDREF_CHECKING, Boolean.TRUE);
+        fFeatures.put(IDENTITY_CONSTRAINT_CHECKING, Boolean.TRUE);
+        fFeatures.put(UNPARSED_ENTITY_CHECKING, Boolean.TRUE);
         fFeatures.put(NAMESPACE_GROWTH, Boolean.FALSE);
         fFeatures.put(TOLERATE_DUPLICATES, Boolean.FALSE);
         fFeatures.put(USE_GRAMMAR_POOL_ONLY, Boolean.FALSE);
@@ -508,41 +529,42 @@
 
         // add default recognized properties
         final String[] recognizedProperties =
-            {
-                                SYMBOL_TABLE,
-                                ERROR_HANDLER,
-                                ENTITY_RESOLVER,
-                ERROR_REPORTER,
-                ENTITY_MANAGER,
-                DOCUMENT_SCANNER,
-                DTD_SCANNER,
-                DTD_PROCESSOR,
-                DTD_VALIDATOR,
-                                DATATYPE_VALIDATOR_FACTORY,
-                                VALIDATION_MANAGER,
-                                SCHEMA_VALIDATOR,
-                                XML_STRING,
-                XMLGRAMMAR_POOL,
-                JAXP_SCHEMA_SOURCE,
-                JAXP_SCHEMA_LANGUAGE,
-                // NOTE: These shouldn't really be here but since the XML Schema
-                //       validator is constructed dynamically, its recognized
-                //       properties might not have been set and it would cause a
-                //       not-recognized exception to be thrown. -Ac
-                SCHEMA_LOCATION,
-                SCHEMA_NONS_LOCATION,
-                LOCALE,
-                SCHEMA_DV_FACTORY,
-                SECURITY_MANAGER,
-                XML_SECURITY_PROPERTY_MANAGER
+        {
+            SYMBOL_TABLE,
+            ERROR_HANDLER,
+            ENTITY_RESOLVER,
+            ERROR_REPORTER,
+            ENTITY_MANAGER,
+            DOCUMENT_SCANNER,
+            DTD_SCANNER,
+            DTD_PROCESSOR,
+            DTD_VALIDATOR,
+            DATATYPE_VALIDATOR_FACTORY,
+            VALIDATION_MANAGER,
+            SCHEMA_VALIDATOR,
+            XML_STRING,
+            XMLGRAMMAR_POOL,
+            JAXP_SCHEMA_SOURCE,
+            JAXP_SCHEMA_LANGUAGE,
+            // NOTE: These shouldn't really be here but since the XML Schema
+            //       validator is constructed dynamically, its recognized
+            //       properties might not have been set and it would cause a
+            //       not-recognized exception to be thrown. -Ac
+            SCHEMA_LOCATION,
+            SCHEMA_NONS_LOCATION,
+            ROOT_TYPE_DEF,
+            LOCALE,
+            SCHEMA_DV_FACTORY,
+            SECURITY_MANAGER,
+            XML_SECURITY_PROPERTY_MANAGER
         };
         addRecognizedProperties(recognizedProperties);
 
-                if (symbolTable == null) {
-                        symbolTable = new SymbolTable();
-                }
-                fSymbolTable = symbolTable;
-                fProperties.put(SYMBOL_TABLE, fSymbolTable);
+        if (symbolTable == null) {
+                symbolTable = new SymbolTable();
+        }
+        fSymbolTable = symbolTable;
+        fProperties.put(SYMBOL_TABLE, fSymbolTable);
 
         fGrammarPool = grammarPool;
         if (fGrammarPool != null) {
@@ -597,8 +619,7 @@
             // REVISIT: What is the right thing to do? -Ac
         }
 
-                fConfigUpdated = false;
-
+        fConfigUpdated = false;
     } // <init>(SymbolTable,XMLGrammarPool)
 
     //