Author: mrglavas Date: Mon Jan 23 10:41:49 2006 New Revision: 371617 URL: http://svn.apache.org/viewcvs?rev=371617&view=rev Log: Committing patch from Peter McCracken for supporting the following items in the Xerces 2.8.0 release plan:
- Feature: http://apache.org/xml/features/validation/schema/ignore-xsi-type-until-elemdecl - Feature: http://apache.org/xml/features/validation/id-idref-checking - Feature: http://apache.org/xml/features/validation/identity-constraint-checking - Feature: http://apache.org/xml/features/validation/unparsed-entity-checking - Property: http://apache.org/xml/properties/validation/schema/root-type-definition - Enhancements to SchemaFactory.newSchema(Source[]) See http://issues.apache.org/jira/browse/XERCESJ-1131. Modified: xerces/java/trunk/src/org/apache/xerces/impl/Constants.java xerces/java/trunk/src/org/apache/xerces/impl/dv/ValidatedInfo.java xerces/java/trunk/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java xerces/java/trunk/src/org/apache/xerces/jaxp/validation/XMLSchema.java xerces/java/trunk/src/org/apache/xerces/jaxp/validation/XMLSchemaFactory.java xerces/java/trunk/src/org/apache/xerces/jaxp/validation/XMLSchemaValidatorComponentManager.java xerces/java/trunk/src/org/apache/xerces/parsers/StandardParserConfiguration.java xerces/java/trunk/src/org/apache/xerces/parsers/XML11Configuration.java Modified: xerces/java/trunk/src/org/apache/xerces/impl/Constants.java URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/impl/Constants.java?rev=371617&r1=371616&r2=371617&view=diff ============================================================================== --- xerces/java/trunk/src/org/apache/xerces/impl/Constants.java (original) +++ xerces/java/trunk/src/org/apache/xerces/impl/Constants.java Mon Jan 23 10:41:49 2006 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2005 The Apache Software Foundation. + * Copyright 2000-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. @@ -286,6 +286,40 @@ 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. */ @@ -376,6 +410,9 @@ /** 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"; + // general constants /** Element PSVI is stored in augmentations using string "ELEMENT_PSVI" */ @@ -464,7 +501,11 @@ HONOUR_ALL_SCHEMALOCATIONS_FEATURE, XINCLUDE_FEATURE, XINCLUDE_FIXUP_BASE_URIS_FEATURE, - XINCLUDE_FIXUP_LANGUAGE_FEATURE + XINCLUDE_FIXUP_LANGUAGE_FEATURE, + IGNORE_XSI_TYPE_FEATURE, + ID_IDREF_CHECKING_FEATURE, + IDC_CHECKING_FEATURE, + UNPARSED_ENTITY_CHECKING_FEATURE, }; /** Xerces properties. */ @@ -485,7 +526,8 @@ SCHEMA_NONS_LOCATION, VALIDATION_MANAGER_PROPERTY, BUFFER_SIZE_PROPERTY, - SECURITY_MANAGER_PROPERTY + SECURITY_MANAGER_PROPERTY, + ROOT_TYPE_DEFINITION_PROPERTY, }; /** Empty enumeration. */ Modified: xerces/java/trunk/src/org/apache/xerces/impl/dv/ValidatedInfo.java URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/impl/dv/ValidatedInfo.java?rev=371617&r1=371616&r2=371617&view=diff ============================================================================== --- xerces/java/trunk/src/org/apache/xerces/impl/dv/ValidatedInfo.java (original) +++ xerces/java/trunk/src/org/apache/xerces/impl/dv/ValidatedInfo.java Mon Jan 23 10:41:49 2006 @@ -1,5 +1,5 @@ /* - * Copyright 2001, 2002,2004 The Apache Software Foundation. + * Copyright 2001,2002,2004,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. @@ -17,6 +17,7 @@ package org.apache.xerces.impl.dv; import org.apache.xerces.xs.ShortList; +import org.apache.xerces.xs.XSConstants; /** * Class to get the information back after content is validated. This info @@ -92,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; + } +} \ No newline at end of file Modified: xerces/java/trunk/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties?rev=371617&r1=371616&r2=371617&view=diff ============================================================================== --- xerces/java/trunk/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties (original) +++ xerces/java/trunk/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties Mon Jan 23 10:41:49 2006 @@ -76,6 +76,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]. Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java?rev=371617&r1=371616&r2=371617&view=diff ============================================================================== --- xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java (original) +++ xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java Mon Jan 23 10:41:49 2006 @@ -23,6 +23,8 @@ import java.util.Stack; import java.util.Vector; +import javax.xml.XMLConstants; + import org.apache.xerces.impl.Constants; import org.apache.xerces.impl.RevalidationHandler; import org.apache.xerces.impl.XMLErrorReporter; @@ -30,6 +32,7 @@ import org.apache.xerces.impl.dv.InvalidDatatypeValueException; import org.apache.xerces.impl.dv.ValidatedInfo; import org.apache.xerces.impl.dv.XSSimpleType; +import org.apache.xerces.impl.validation.ConfigurableValidationState; import org.apache.xerces.impl.validation.ValidationManager; import org.apache.xerces.impl.validation.ValidationState; import org.apache.xerces.impl.xs.identity.Field; @@ -169,6 +172,22 @@ protected static final String PARSER_SETTINGS = Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS; + /** 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 /** Property identifier: symbol table. */ @@ -209,6 +228,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; + // recognized features and properties /** Recognized features. */ @@ -224,7 +247,12 @@ GENERATE_SYNTHETIC_ANNOTATIONS, VALIDATE_ANNOTATIONS, HONOUR_ALL_SCHEMALOCATIONS, - USE_GRAMMAR_POOL_ONLY}; + USE_GRAMMAR_POOL_ONLY, + IGNORE_XSI_TYPE, + ID_IDREF_CHECKING, + IDENTITY_CONSTRAINT_CHECKING, + UNPARSED_ENTITY_CHECKING, + }; /** Feature defaults. */ @@ -235,6 +263,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, @@ -244,7 +276,12 @@ null, null, null, - null}; + null, + null, + null, + null, + null, + }; /** Recognized properties. */ private static final String[] RECOGNIZED_PROPERTIES = @@ -257,11 +294,12 @@ SCHEMA_NONS_LOCATION, JAXP_SCHEMA_SOURCE, JAXP_SCHEMA_LANGUAGE, - }; + ROOT_TYPE_DEF, + }; /** 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, }; // this is the number of valuestores of each kind // we expect an element to have. It's almost @@ -435,7 +473,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 @@ -513,6 +551,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) /** @@ -1166,6 +1207,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(); @@ -1358,8 +1405,40 @@ fValidationManager = (ValidationManager) componentManager.getProperty(VALIDATION_MANAGER); 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 { fExternalSchemas = (String) componentManager.getProperty(SCHEMA_LOCATION); @@ -1534,15 +1613,19 @@ // handle start document void handleStartDocument(XMLLocator locator, String encoding) { - fValueStoreCache.startDocument(); + if (fIDCChecking) { + fValueStoreCache.startDocument(); + } if (fAugPSVI) { fCurrentPSVI.fGrammars = null; fCurrentPSVI.fSchemaInformation = null; } } // handleStartDocument(XMLLocator,String) - + void handleEndDocument() { - fValueStoreCache.endDocument(); + if (fIDCChecking) { + fValueStoreCache.endDocument(); + } } // handleEndDocument() // handle character contents @@ -1745,7 +1828,7 @@ if (fSkipValidationDepth >= 0) { fElementDepth++; if (fAugPSVI) - augs = getEmptyAugs(augs); + augs = getEmptyAugs(augs); return augs; } @@ -1831,24 +1914,55 @@ augs = getEmptyAugs(augs); 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) { // if this is the validation root, report an error, because @@ -2026,13 +2140,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); @@ -2120,67 +2238,76 @@ // 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? if (fElementDepth == 0) { @@ -2478,14 +2605,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; @@ -2761,7 +2896,7 @@ // 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 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[] { @@ -2776,7 +2911,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[] { @@ -3007,7 +3142,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", @@ -3018,7 +3153,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 @@ -3149,54 +3284,6 @@ key, arguments, 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) { Modified: xerces/java/trunk/src/org/apache/xerces/jaxp/validation/XMLSchema.java URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/jaxp/validation/XMLSchema.java?rev=371617&r1=371616&r2=371617&view=diff ============================================================================== --- xerces/java/trunk/src/org/apache/xerces/jaxp/validation/XMLSchema.java (original) +++ xerces/java/trunk/src/org/apache/xerces/jaxp/validation/XMLSchema.java Mon Jan 23 10:41:49 2006 @@ -1,5 +1,5 @@ /* - * Copyright 2005 The Apache Software Foundation. + * Copyright 2005,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. @@ -27,11 +27,19 @@ final class XMLSchema extends AbstractXMLSchema { /** The grammar pool is immutable */ - private final XMLGrammarPool fGrammarPool; + private final XMLGrammarPool fGrammarPool; - /** Constructor */ + /** Whether to consider this schema to be fully composed */ + private final boolean fFullyComposed; + + /** Constructors */ public XMLSchema(XMLGrammarPool grammarPool) { + this(grammarPool, true); + } + + public XMLSchema(XMLGrammarPool grammarPool, boolean fullyComposed) { fGrammarPool = grammarPool; + fFullyComposed = fullyComposed; } /* @@ -46,7 +54,7 @@ public XMLGrammarPool getGrammarPool() { return fGrammarPool; } - + /** * <p>Returns whether the schema components contained in this object * can be considered to be a fully composed schema and should be @@ -57,7 +65,7 @@ * can be considered to be a fully composed schema */ public boolean isFullyComposed() { - return true; + return fFullyComposed; } } // XMLSchema Modified: xerces/java/trunk/src/org/apache/xerces/jaxp/validation/XMLSchemaFactory.java URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/jaxp/validation/XMLSchemaFactory.java?rev=371617&r1=371616&r2=371617&view=diff ============================================================================== --- xerces/java/trunk/src/org/apache/xerces/jaxp/validation/XMLSchemaFactory.java (original) +++ xerces/java/trunk/src/org/apache/xerces/jaxp/validation/XMLSchemaFactory.java Mon Jan 23 10:41:49 2006 @@ -1,5 +1,5 @@ /* - * Copyright 2005 The Apache Software Foundation. + * Copyright 2005,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. @@ -61,12 +61,18 @@ */ public final class XMLSchemaFactory extends SchemaFactory { - // property identifiers + // feature identifiers /** 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; @@ -100,6 +106,9 @@ /** The container for the real grammar pool. */ private XMLGrammarPoolWrapper fXMLGrammarPoolWrapper; + /** Whether or not to allow new schemas to be added to the grammar pool */ + private boolean fUseGrammarPoolOnly; + public XMLSchemaFactory() { fErrorHandlerWrapper = new ErrorHandlerWrapper(DraconianErrorHandler.getInstance()); fDOMEntityResolverWrapper = new DOMEntityResolverWrapper(); @@ -108,6 +117,7 @@ fXMLSchemaLoader.setProperty(XMLGRAMMAR_POOL, fXMLGrammarPoolWrapper); fXMLSchemaLoader.setEntityResolver(fDOMEntityResolverWrapper); fXMLSchemaLoader.setErrorHandler(fErrorHandlerWrapper); + fUseGrammarPoolOnly = true; } /** @@ -221,19 +231,32 @@ // Select Schema implementation based on grammar count. final int grammarCount = pool.getGrammarCount(); - if (grammarCount > 1) { - return new XMLSchema(new ReadOnlyGrammarPool(pool)); - } - else if (grammarCount == 1) { - Grammar[] grammars = pool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA); - return new SimpleXMLSchema(grammars[0]); + if (fUseGrammarPoolOnly) { + if (grammarCount > 1) { + return new XMLSchema(new ReadOnlyGrammarPool(pool)); + } + else if (grammarCount == 1) { + Grammar[] grammars = pool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA); + return new SimpleXMLSchema(grammars[0]); + } + else { + return EmptyXMLSchema.getInstance(); + } } else { - return EmptyXMLSchema.getInstance(); + return new XMLSchema(new ReadOnlyGrammarPool(pool), false); } } 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. return new WeakReferenceXMLSchema(); } @@ -247,6 +270,9 @@ if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) { return (fSecurityManager != null); } + else if (name.equals(USE_GRAMMAR_POOL_ONLY)) { + return fUseGrammarPoolOnly; + } try { return fXMLSchemaLoader.getFeature(name); } @@ -306,6 +332,10 @@ if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) { fSecurityManager = value ? new SecurityManager() : null; fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager); + return; + } + else if (name.equals(USE_GRAMMAR_POOL_ONLY)) { + fUseGrammarPoolOnly = value; return; } try { Modified: xerces/java/trunk/src/org/apache/xerces/jaxp/validation/XMLSchemaValidatorComponentManager.java URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/jaxp/validation/XMLSchemaValidatorComponentManager.java?rev=371617&r1=371616&r2=371617&view=diff ============================================================================== --- xerces/java/trunk/src/org/apache/xerces/jaxp/validation/XMLSchemaValidatorComponentManager.java (original) +++ xerces/java/trunk/src/org/apache/xerces/jaxp/validation/XMLSchemaValidatorComponentManager.java Mon Jan 23 10:41:49 2006 @@ -1,5 +1,5 @@ /* - * Copyright 2005 The Apache Software Foundation. + * Copyright 2005,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. @@ -63,6 +63,22 @@ 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; + // property identifiers /** Property identifier: entity manager. */ @@ -187,7 +203,17 @@ // add all recognized features and properties and apply their defaults addRecognizedParamsAndSetDefaults(fEntityManager); addRecognizedParamsAndSetDefaults(fErrorReporter); - addRecognizedParamsAndSetDefaults(fSchemaValidator); + addRecognizedParamsAndSetDefaults(fSchemaValidator); + + /* 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); } /** Modified: xerces/java/trunk/src/org/apache/xerces/parsers/StandardParserConfiguration.java URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/parsers/StandardParserConfiguration.java?rev=371617&r1=371616&r2=371617&view=diff ============================================================================== --- xerces/java/trunk/src/org/apache/xerces/parsers/StandardParserConfiguration.java (original) +++ xerces/java/trunk/src/org/apache/xerces/parsers/StandardParserConfiguration.java Mon Jan 23 10:41:49 2006 @@ -1,5 +1,5 @@ /* - * Copyright 2001-2004 The Apache Software Foundation. + * Copyright 2001-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. @@ -103,6 +103,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; + // property identifiers /** Property identifier: XML Schema validator. */ @@ -117,6 +133,10 @@ protected static final String SCHEMA_NONS_LOCATION = Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_NONS_LOCATION; + /** Property identifier: root type definition. */ + protected static final String ROOT_TYPE_DEF = + Constants.XERCES_PROPERTY_PREFIX + Constants.ROOT_TYPE_DEFINITION_PROPERTY; + // // Data // @@ -191,6 +211,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); @@ -201,6 +225,11 @@ 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); // add default recognized properties @@ -210,11 +239,11 @@ // properties might not have been set and it would cause a // not-recognized exception to be thrown. -Ac SCHEMA_LOCATION, - SCHEMA_NONS_LOCATION, - }; - - addRecognizedProperties(recognizedProperties); - + SCHEMA_NONS_LOCATION, + ROOT_TYPE_DEF, + }; + + addRecognizedProperties(recognizedProperties); } // <init>(SymbolTable,XMLGrammarPool) // Modified: xerces/java/trunk/src/org/apache/xerces/parsers/XML11Configuration.java URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/parsers/XML11Configuration.java?rev=371617&r1=371616&r2=371617&view=diff ============================================================================== --- xerces/java/trunk/src/org/apache/xerces/parsers/XML11Configuration.java (original) +++ xerces/java/trunk/src/org/apache/xerces/parsers/XML11Configuration.java Mon Jan 23 10:41:49 2006 @@ -1,5 +1,5 @@ /* - * Copyright 2001-2005 The Apache Software Foundation. + * Copyright 2001-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. @@ -168,6 +168,22 @@ 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 @@ -251,6 +267,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; + // debugging /** Set to true and recompile to print exception stack trace. */ @@ -439,64 +459,74 @@ fProperties = new HashMap(); // 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, 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 - }; + 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, IGNORE_XSI_TYPE, + ID_IDREF_CHECKING, IDENTITY_CONSTRAINT_CHECKING, + UNPARSED_ENTITY_CHECKING, 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, + + }; addRecognizedFeatures(recognizedFeatures); - // set state for default features - fFeatures.put(VALIDATION, Boolean.FALSE); - fFeatures.put(NAMESPACES, Boolean.TRUE); - fFeatures.put(EXTERNAL_GENERAL_ENTITIES, Boolean.TRUE); - fFeatures.put(EXTERNAL_PARAMETER_ENTITIES, Boolean.TRUE); - fFeatures.put(CONTINUE_AFTER_FATAL_ERROR, Boolean.FALSE); - fFeatures.put(LOAD_EXTERNAL_DTD, Boolean.TRUE); - fFeatures.put(SCHEMA_ELEMENT_DEFAULT, Boolean.TRUE); - fFeatures.put(NORMALIZE_DATA, Boolean.TRUE); - fFeatures.put(SCHEMA_AUGMENT_PSVI, Boolean.TRUE); + // set state for default features + fFeatures.put(VALIDATION, Boolean.FALSE); + fFeatures.put(NAMESPACES, Boolean.TRUE); + fFeatures.put(EXTERNAL_GENERAL_ENTITIES, Boolean.TRUE); + fFeatures.put(EXTERNAL_PARAMETER_ENTITIES, Boolean.TRUE); + fFeatures.put(CONTINUE_AFTER_FATAL_ERROR, Boolean.FALSE); + fFeatures.put(LOAD_EXTERNAL_DTD, Boolean.TRUE); + fFeatures.put(SCHEMA_ELEMENT_DEFAULT, Boolean.TRUE); + fFeatures.put(NORMALIZE_DATA, Boolean.TRUE); + fFeatures.put(SCHEMA_AUGMENT_PSVI, Boolean.TRUE); 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(USE_GRAMMAR_POOL_ONLY, Boolean.FALSE); - fFeatures.put(PARSER_SETTINGS, Boolean.TRUE); + fFeatures.put(PARSER_SETTINGS, Boolean.TRUE); // add default recognized properties final String[] recognizedProperties = - { - SYMBOL_TABLE, - ERROR_HANDLER, - ENTITY_RESOLVER, + { + 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, + 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, }; + // 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, + }; addRecognizedProperties(recognizedProperties); if (symbolTable == null) { --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
