You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by kn...@apache.org on 2009/01/19 23:26:52 UTC
svn commit: r735851 [1/2] - in
/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl: ./
dv/xs/ xs/ xs/models/ xs/traversers/ xs/util/
Author: knoaman
Date: Mon Jan 19 14:26:51 2009
New Revision: 735851
URL: http://svn.apache.org/viewvc?rev=735851&view=rev
Log:
Handle XML Schema Grammar: 1.0 vs. 1.1
Added:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java (with props)
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/Schema11DVFactoryImpl.java (with props)
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/Constants.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/SchemaDVFactoryImpl.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaGrammar.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SubstitutionGroupHandler.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XS10Constraints.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XS11Constraints.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSComplexTypeDecl.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSConstraints.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSModelImpl.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/models/CMBuilder.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/models/XS11AllCM.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/models/XSAllCM.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/models/XSDFACM.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/util/XSGrammarPool.java
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/Constants.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/Constants.java?rev=735851&r1=735850&r2=735851&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/Constants.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/Constants.java Mon Jan 19 14:26:51 2009
@@ -40,8 +40,9 @@
// Schema Versions:
public static final String W3C_XML_SCHEMA10_NS_URI = "http://www.w3.org/XML/XMLSchema/v1.0".intern();
- public static final String W3C_XML_SCHEMA11_NS_URI = "http://www.w3.org/XML/XMLSchema/v1.1".intern();
-
+ public static final String W3C_XML_SCHEMA11_NS_URI = "http://www.w3.org/XML/XMLSchema/v1.1".intern();
+ public static final String W3C_XML_SCHEMA10EX_NS_URI = "http://www.w3.org/XML/XMLSchema/v1.0EX".intern();
+
// sax features
/** SAX feature prefix ("http://xml.org/sax/features/"). */
@@ -469,6 +470,7 @@
// Constant to enable Schema 1.1 support
public final static boolean SCHEMA_1_1_SUPPORT = false;
public final static short SCHEMA_VERSION_1_0 = 1;
+ public final static short SCHEMA_VERSION_1_0_EXTENDED = 2;
public final static short SCHEMA_VERSION_1_1 = 4;
// private
Added: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java?rev=735851&view=auto
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java (added)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java Mon Jan 19 14:26:51 2009
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.impl.dv.xs;
+
+import org.apache.xerces.impl.dv.XSSimpleType;
+import org.apache.xerces.util.SymbolHash;
+
+/**
+ * A special factory to create/return built-in schema DVs and create user-defined DVs
+ * that includes anyAtomicType, yearMonthDuration and dayTimeDuration
+ *
+ * @xerces.internal
+ *
+ * @author Khaled Noaman, IBM
+ *
+ * @version $Id$
+ */
+public class ExtendedSchemaDVFactoryImpl extends BaseSchemaDVFactory {
+
+ static SymbolHash fBuiltInTypes = new SymbolHash();
+ static {
+ createBuiltInTypes();
+ }
+
+ // create all built-in types
+ static void createBuiltInTypes() {
+ final String ANYATOMICTYPE = "anyAtomicType";
+ final String DURATION = "duration";
+ final String YEARMONTHDURATION = "yearMonthDuration";
+ final String DAYTIMEDURATION = "dayTimeDuration";
+
+ createBuiltInTypes(fBuiltInTypes, XSSimpleTypeDecl.fAnyAtomicType);
+
+ // add anyAtomicType
+ fBuiltInTypes.put(ANYATOMICTYPE, XSSimpleTypeDecl.fAnyAtomicType);
+
+ // add 2 duration types
+ XSSimpleTypeDecl durationDV = (XSSimpleTypeDecl)fBuiltInTypes.get(DURATION);
+ fBuiltInTypes.put(YEARMONTHDURATION, new XSSimpleTypeDecl(durationDV, YEARMONTHDURATION, XSSimpleTypeDecl.DV_YEARMONTHDURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSSimpleTypeDecl.YEARMONTHDURATION_DT));
+ fBuiltInTypes.put(DAYTIMEDURATION, new XSSimpleTypeDecl(durationDV, DAYTIMEDURATION, XSSimpleTypeDecl.DV_DAYTIMEDURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSSimpleTypeDecl.DAYTIMEDURATION_DT));
+ } //createBuiltInTypes()
+
+ /**
+ * Get a built-in simple type of the given name
+ * REVISIT: its still not decided within the Schema WG how to define the
+ * ur-types and if all simple types should be derived from a
+ * complex type, so as of now we ignore the fact that anySimpleType
+ * is derived from anyType, and pass 'null' as the base of
+ * anySimpleType. It needs to be changed as per the decision taken.
+ *
+ * @param name the name of the datatype
+ * @return the datatype validator of the given name
+ */
+ public XSSimpleType getBuiltInType(String name) {
+ return (XSSimpleType)fBuiltInTypes.get(name);
+ }
+
+ /**
+ * get all built-in simple types, which are stored in a hashtable keyed by
+ * the name
+ *
+ * @return a hashtable which contains all built-in simple types
+ */
+ public SymbolHash getBuiltInTypes() {
+ return (SymbolHash)fBuiltInTypes.makeClone();
+ }
+}
Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/Schema11DVFactoryImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/Schema11DVFactoryImpl.java?rev=735851&view=auto
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/Schema11DVFactoryImpl.java (added)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/Schema11DVFactoryImpl.java Mon Jan 19 14:26:51 2009
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.impl.dv.xs;
+
+import org.apache.xerces.impl.dv.XSSimpleType;
+import org.apache.xerces.util.SymbolHash;
+
+/**
+ * A special factory to create/return built-in schema DVs and create user-defined DVs
+ * that includes anyAtomicType, yearMonthDuration and dayTimeDuration
+ *
+ * @xerces.internal
+ *
+ * @author Khaled Noaman, IBM
+ *
+ * @version $Id$
+ */
+public class Schema11DVFactoryImpl extends BaseSchemaDVFactory {
+
+ static SymbolHash fBuiltInTypes = new SymbolHash();
+ static {
+ createBuiltInTypes();
+ }
+
+ // create all built-in types
+ static void createBuiltInTypes() {
+ final String ANYATOMICTYPE = "anyAtomicType";
+ final String DURATION = "duration";
+ final String YEARMONTHDURATION = "yearMonthDuration";
+ final String DAYTIMEDURATION = "dayTimeDuration";
+ final String PRECISIONDECIMAL = "precisionDecimal";
+
+ createBuiltInTypes(fBuiltInTypes, XSSimpleTypeDecl.fAnyAtomicType);
+
+ // add anyAtomicType
+ fBuiltInTypes.put(ANYATOMICTYPE, XSSimpleTypeDecl.fAnyAtomicType);
+
+ // add 2 duration types
+ XSSimpleTypeDecl durationDV = (XSSimpleTypeDecl)fBuiltInTypes.get(DURATION);
+ fBuiltInTypes.put(YEARMONTHDURATION, new XSSimpleTypeDecl(durationDV, YEARMONTHDURATION, XSSimpleTypeDecl.DV_YEARMONTHDURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSSimpleTypeDecl.YEARMONTHDURATION_DT));
+ fBuiltInTypes.put(DAYTIMEDURATION, new XSSimpleTypeDecl(durationDV, DAYTIMEDURATION, XSSimpleTypeDecl.DV_DAYTIMEDURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSSimpleTypeDecl.DAYTIMEDURATION_DT));
+
+ // add precision decimal
+ fBuiltInTypes.put(PRECISIONDECIMAL, new XSSimpleTypeDecl(XSSimpleTypeDecl.fAnyAtomicType, PRECISIONDECIMAL, XSSimpleTypeDecl.DV_PRECISIONDECIMAL, XSSimpleType.ORDERED_PARTIAL, false, false, true, true, XSSimpleTypeDecl.PRECISIONDECIMAL_DT));
+ } //createBuiltInTypes()
+
+ /**
+ * Get a built-in simple type of the given name
+ * REVISIT: its still not decided within the Schema WG how to define the
+ * ur-types and if all simple types should be derived from a
+ * complex type, so as of now we ignore the fact that anySimpleType
+ * is derived from anyType, and pass 'null' as the base of
+ * anySimpleType. It needs to be changed as per the decision taken.
+ *
+ * @param name the name of the datatype
+ * @return the datatype validator of the given name
+ */
+ public XSSimpleType getBuiltInType(String name) {
+ return (XSSimpleType)fBuiltInTypes.get(name);
+ }
+
+ /**
+ * get all built-in simple types, which are stored in a hashtable keyed by
+ * the name
+ *
+ * @return a hashtable which contains all built-in simple types
+ */
+ public SymbolHash getBuiltInTypes() {
+ return (SymbolHash)fBuiltInTypes.makeClone();
+ }
+}
Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/Schema11DVFactoryImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/Schema11DVFactoryImpl.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/SchemaDVFactoryImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/SchemaDVFactoryImpl.java?rev=735851&r1=735850&r2=735851&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/SchemaDVFactoryImpl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/SchemaDVFactoryImpl.java Mon Jan 19 14:26:51 2009
@@ -17,14 +17,8 @@
package org.apache.xerces.impl.dv.xs;
-import org.apache.xerces.impl.Constants;
-import org.apache.xerces.impl.dv.SchemaDVFactory;
-import org.apache.xerces.impl.dv.XSFacets;
import org.apache.xerces.impl.dv.XSSimpleType;
-import org.apache.xerces.impl.xs.XSDeclarationPool;
import org.apache.xerces.util.SymbolHash;
-import org.apache.xerces.xs.XSConstants;
-import org.apache.xerces.xs.XSObjectList;
/**
* the factory to create/return built-in schema DVs and create user-defined DVs
@@ -36,16 +30,20 @@
*
* @version $Id$
*/
-public class SchemaDVFactoryImpl extends SchemaDVFactory {
-
- static final String URI_SCHEMAFORSCHEMA = "http://www.w3.org/2001/XMLSchema";
+public class SchemaDVFactoryImpl extends BaseSchemaDVFactory {
static final SymbolHash fBuiltInTypes = new SymbolHash();
+
static {
createBuiltInTypes();
}
- protected XSDeclarationPool fDeclPool = null;
+ // create all built-in types
+ static void createBuiltInTypes() {
+ createBuiltInTypes(fBuiltInTypes, XSSimpleTypeDecl.fAnySimpleType);
+
+ // TODO: move specific 1.0 DV implementation from base
+ } //createBuiltInTypes()
/**
* Get a built-in simple type of the given name
@@ -72,307 +70,4 @@
return (SymbolHash)fBuiltInTypes.makeClone();
}
- /**
- * Create a new simple type which is derived by restriction from another
- * simple type.
- *
- * @param name name of the new type, could be null
- * @param targetNamespace target namespace of the new type, could be null
- * @param finalSet value of "final"
- * @param base base type of the new type
- * @param annotations set of annotations
- * @return the newly created simple type
- */
- public XSSimpleType createTypeRestriction(String name, String targetNamespace,
- short finalSet, XSSimpleType base, XSObjectList annotations) {
-
- if (fDeclPool != null) {
- XSSimpleTypeDecl st= fDeclPool.getSimpleTypeDecl();
- return st.setRestrictionValues((XSSimpleTypeDecl)base, name, targetNamespace, finalSet, annotations);
- }
- return new XSSimpleTypeDecl((XSSimpleTypeDecl)base, name, targetNamespace, finalSet, false, annotations);
- }
-
- /**
- * Create a new simple type which is derived by list from another simple
- * type.
- *
- * @param name name of the new type, could be null
- * @param targetNamespace target namespace of the new type, could be null
- * @param finalSet value of "final"
- * @param itemType item type of the list type
- * @param annotations set of annotations
- * @return the newly created simple type
- */
- public XSSimpleType createTypeList(String name, String targetNamespace,
- short finalSet, XSSimpleType itemType,
- XSObjectList annotations) {
- if (fDeclPool != null) {
- XSSimpleTypeDecl st= fDeclPool.getSimpleTypeDecl();
- return st.setListValues(name, targetNamespace, finalSet, (XSSimpleTypeDecl)itemType, annotations);
- }
- return new XSSimpleTypeDecl(name, targetNamespace, finalSet, (XSSimpleTypeDecl)itemType, false, annotations);
- }
-
- /**
- * Create a new simple type which is derived by union from a list of other
- * simple types.
- *
- * @param name name of the new type, could be null
- * @param targetNamespace target namespace of the new type, could be null
- * @param finalSet value of "final"
- * @param memberTypes member types of the union type
- * @param annotations set of annotations
- * @return the newly created simple type
- */
- public XSSimpleType createTypeUnion(String name, String targetNamespace,
- short finalSet, XSSimpleType[] memberTypes,
- XSObjectList annotations) {
- int typeNum = memberTypes.length;
- XSSimpleTypeDecl[] mtypes = new XSSimpleTypeDecl[typeNum];
- System.arraycopy(memberTypes, 0, mtypes, 0, typeNum);
-
- if (fDeclPool != null) {
- XSSimpleTypeDecl st= fDeclPool.getSimpleTypeDecl();
- return st.setUnionValues(name, targetNamespace, finalSet, mtypes, annotations);
- }
- return new XSSimpleTypeDecl(name, targetNamespace, finalSet, mtypes, annotations);
- }
-
- // create all built-in types
- static void createBuiltInTypes() {
- // all schema simple type names
- final String ANYSIMPLETYPE = "anySimpleType";
- final String ANYATOMICTYPE = "anyAtomicType";
- final String ANYURI = "anyURI";
- final String BASE64BINARY = "base64Binary";
- final String BOOLEAN = "boolean";
- final String BYTE = "byte";
- final String DATE = "date";
- final String DATETIME = "dateTime";
- final String DAY = "gDay";
- final String DECIMAL = "decimal";
- final String DOUBLE = "double";
- final String DURATION = "duration";
- final String ENTITY = "ENTITY";
- final String ENTITIES = "ENTITIES";
- final String FLOAT = "float";
- final String HEXBINARY = "hexBinary";
- final String ID = "ID";
- final String IDREF = "IDREF";
- final String IDREFS = "IDREFS";
- final String INT = "int";
- final String INTEGER = "integer";
- final String LONG = "long";
- final String NAME = "Name";
- final String NEGATIVEINTEGER = "negativeInteger";
- final String MONTH = "gMonth";
- final String MONTHDAY = "gMonthDay";
- final String NCNAME = "NCName";
- final String NMTOKEN = "NMTOKEN";
- final String NMTOKENS = "NMTOKENS";
- final String LANGUAGE = "language";
- final String NONNEGATIVEINTEGER= "nonNegativeInteger";
- final String NONPOSITIVEINTEGER= "nonPositiveInteger";
- final String NORMALIZEDSTRING = "normalizedString";
- final String NOTATION = "NOTATION";
- final String POSITIVEINTEGER = "positiveInteger";
- final String QNAME = "QName";
- final String SHORT = "short";
- final String STRING = "string";
- final String TIME = "time";
- final String TOKEN = "token";
- final String UNSIGNEDBYTE = "unsignedByte";
- final String UNSIGNEDINT = "unsignedInt";
- final String UNSIGNEDLONG = "unsignedLong";
- final String UNSIGNEDSHORT = "unsignedShort";
- final String YEAR = "gYear";
- final String YEARMONTH = "gYearMonth";
- final String YEARMONTHDURATION = "yearMonthDuration";
- final String DAYTIMEDURATION = "dayTimeDuration";
- final String PRECISIONDECIMAL = "precisionDecimal";
-
- final XSFacets facets = new XSFacets();
-
- //REVISIT: passing "anyType" here.
- XSSimpleTypeDecl anySimpleType = XSSimpleTypeDecl.fAnySimpleType;
- XSSimpleTypeDecl anyAtomicType = XSSimpleTypeDecl.fAnyAtomicType;
- XSSimpleTypeDecl baseAtomicType = null;
-
- if (Constants.SCHEMA_1_1_SUPPORT) {
- baseAtomicType = anyAtomicType;
- fBuiltInTypes.put(ANYATOMICTYPE, anyAtomicType);
- }
- else {
- baseAtomicType = anySimpleType;
- }
-
- fBuiltInTypes.put(ANYSIMPLETYPE, anySimpleType);
- XSSimpleTypeDecl stringDV = new XSSimpleTypeDecl(baseAtomicType, STRING, XSSimpleTypeDecl.DV_STRING, XSSimpleType.ORDERED_FALSE, false, false, false , true, XSConstants.STRING_DT);
- fBuiltInTypes.put(STRING, stringDV);
- fBuiltInTypes.put(BOOLEAN, new XSSimpleTypeDecl(baseAtomicType, BOOLEAN, XSSimpleTypeDecl.DV_BOOLEAN, XSSimpleType.ORDERED_FALSE, false, true, false, true, XSConstants.BOOLEAN_DT));
- XSSimpleTypeDecl decimalDV = new XSSimpleTypeDecl(baseAtomicType, DECIMAL, XSSimpleTypeDecl.DV_DECIMAL, XSSimpleType.ORDERED_TOTAL, false, false, true, true, XSConstants.DECIMAL_DT);
- fBuiltInTypes.put(DECIMAL, decimalDV);
-
- fBuiltInTypes.put(ANYURI, new XSSimpleTypeDecl(baseAtomicType, ANYURI, XSSimpleTypeDecl.DV_ANYURI, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.ANYURI_DT));
- fBuiltInTypes.put(BASE64BINARY, new XSSimpleTypeDecl(baseAtomicType, BASE64BINARY, XSSimpleTypeDecl.DV_BASE64BINARY, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.BASE64BINARY_DT));
-
- XSSimpleTypeDecl durationDV = new XSSimpleTypeDecl(baseAtomicType, DURATION, XSSimpleTypeDecl.DV_DURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.DURATION_DT);
- fBuiltInTypes.put(DURATION, durationDV);
-
- if (Constants.SCHEMA_1_1_SUPPORT) {
- fBuiltInTypes.put(YEARMONTHDURATION, new XSSimpleTypeDecl(durationDV, YEARMONTHDURATION, XSSimpleTypeDecl.DV_YEARMONTHDURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSSimpleTypeDecl.YEARMONTHDURATION_DT));
- fBuiltInTypes.put(DAYTIMEDURATION, new XSSimpleTypeDecl(durationDV, DAYTIMEDURATION, XSSimpleTypeDecl.DV_DAYTIMEDURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSSimpleTypeDecl.DAYTIMEDURATION_DT));
- fBuiltInTypes.put(PRECISIONDECIMAL, new XSSimpleTypeDecl(anySimpleType, PRECISIONDECIMAL, XSSimpleTypeDecl.DV_PRECISIONDECIMAL, XSSimpleType.ORDERED_PARTIAL, false, false, true, true, XSSimpleTypeDecl.PRECISIONDECIMAL_DT));
- }
-
- fBuiltInTypes.put(DATETIME, new XSSimpleTypeDecl(baseAtomicType, DATETIME, XSSimpleTypeDecl.DV_DATETIME, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.DATETIME_DT));
- fBuiltInTypes.put(TIME, new XSSimpleTypeDecl(baseAtomicType, TIME, XSSimpleTypeDecl.DV_TIME, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.TIME_DT));
- fBuiltInTypes.put(DATE, new XSSimpleTypeDecl(baseAtomicType, DATE, XSSimpleTypeDecl.DV_DATE, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.DATE_DT));
- fBuiltInTypes.put(YEARMONTH, new XSSimpleTypeDecl(baseAtomicType, YEARMONTH, XSSimpleTypeDecl.DV_GYEARMONTH, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GYEARMONTH_DT));
- fBuiltInTypes.put(YEAR, new XSSimpleTypeDecl(baseAtomicType, YEAR, XSSimpleTypeDecl.DV_GYEAR, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GYEAR_DT));
- fBuiltInTypes.put(MONTHDAY, new XSSimpleTypeDecl(baseAtomicType, MONTHDAY, XSSimpleTypeDecl.DV_GMONTHDAY, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GMONTHDAY_DT));
- fBuiltInTypes.put(DAY, new XSSimpleTypeDecl(baseAtomicType, DAY, XSSimpleTypeDecl.DV_GDAY, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GDAY_DT));
- fBuiltInTypes.put(MONTH, new XSSimpleTypeDecl(baseAtomicType, MONTH, XSSimpleTypeDecl.DV_GMONTH, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.GMONTH_DT));
-
- XSSimpleTypeDecl integerDV = new XSSimpleTypeDecl(decimalDV, INTEGER, XSSimpleTypeDecl.DV_INTEGER, XSSimpleType.ORDERED_TOTAL, false, false, true, true, XSConstants.INTEGER_DT);
- fBuiltInTypes.put(INTEGER, integerDV);
-
- facets.maxInclusive = "0";
- XSSimpleTypeDecl nonPositiveDV = new XSSimpleTypeDecl(integerDV, NONPOSITIVEINTEGER, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NONPOSITIVEINTEGER_DT);
- nonPositiveDV.applyFacets1(facets , XSSimpleType.FACET_MAXINCLUSIVE, (short)0);
- fBuiltInTypes.put(NONPOSITIVEINTEGER, nonPositiveDV);
-
- facets.maxInclusive = "-1";
- XSSimpleTypeDecl negativeDV = new XSSimpleTypeDecl(nonPositiveDV, NEGATIVEINTEGER, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NEGATIVEINTEGER_DT);
- negativeDV.applyFacets1(facets , XSSimpleType.FACET_MAXINCLUSIVE, (short)0);
- fBuiltInTypes.put(NEGATIVEINTEGER, negativeDV);
-
- facets.maxInclusive = "9223372036854775807";
- facets.minInclusive = "-9223372036854775808";
- XSSimpleTypeDecl longDV = new XSSimpleTypeDecl(integerDV, LONG, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.LONG_DT);
- longDV.applyFacets1(facets , (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 );
- fBuiltInTypes.put(LONG, longDV);
-
-
- facets.maxInclusive = "2147483647";
- facets.minInclusive = "-2147483648";
- XSSimpleTypeDecl intDV = new XSSimpleTypeDecl(longDV, INT, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.INT_DT);
- intDV.applyFacets1(facets, (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 );
- fBuiltInTypes.put(INT, intDV);
-
- facets.maxInclusive = "32767";
- facets.minInclusive = "-32768";
- XSSimpleTypeDecl shortDV = new XSSimpleTypeDecl(intDV, SHORT , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.SHORT_DT);
- shortDV.applyFacets1(facets, (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 );
- fBuiltInTypes.put(SHORT, shortDV);
-
- facets.maxInclusive = "127";
- facets.minInclusive = "-128";
- XSSimpleTypeDecl byteDV = new XSSimpleTypeDecl(shortDV, BYTE , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.BYTE_DT);
- byteDV.applyFacets1(facets, (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 );
- fBuiltInTypes.put(BYTE, byteDV);
-
- facets.minInclusive = "0" ;
- XSSimpleTypeDecl nonNegativeDV = new XSSimpleTypeDecl(integerDV, NONNEGATIVEINTEGER , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NONNEGATIVEINTEGER_DT);
- nonNegativeDV.applyFacets1(facets, XSSimpleType.FACET_MININCLUSIVE, (short)0 );
- fBuiltInTypes.put(NONNEGATIVEINTEGER, nonNegativeDV);
-
- facets.maxInclusive = "18446744073709551615" ;
- XSSimpleTypeDecl unsignedLongDV = new XSSimpleTypeDecl(nonNegativeDV, UNSIGNEDLONG , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.UNSIGNEDLONG_DT);
- unsignedLongDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 );
- fBuiltInTypes.put(UNSIGNEDLONG, unsignedLongDV);
-
- facets.maxInclusive = "4294967295" ;
- XSSimpleTypeDecl unsignedIntDV = new XSSimpleTypeDecl(unsignedLongDV, UNSIGNEDINT , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.UNSIGNEDINT_DT);
- unsignedIntDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 );
- fBuiltInTypes.put(UNSIGNEDINT, unsignedIntDV);
-
- facets.maxInclusive = "65535" ;
- XSSimpleTypeDecl unsignedShortDV = new XSSimpleTypeDecl(unsignedIntDV, UNSIGNEDSHORT , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.UNSIGNEDSHORT_DT);
- unsignedShortDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 );
- fBuiltInTypes.put(UNSIGNEDSHORT, unsignedShortDV);
-
- facets.maxInclusive = "255" ;
- XSSimpleTypeDecl unsignedByteDV = new XSSimpleTypeDecl(unsignedShortDV, UNSIGNEDBYTE , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.UNSIGNEDBYTE_DT);
- unsignedByteDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 );
- fBuiltInTypes.put(UNSIGNEDBYTE, unsignedByteDV);
-
- facets.minInclusive = "1" ;
- XSSimpleTypeDecl positiveIntegerDV = new XSSimpleTypeDecl(nonNegativeDV, POSITIVEINTEGER , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.POSITIVEINTEGER_DT);
- positiveIntegerDV.applyFacets1(facets, XSSimpleType.FACET_MININCLUSIVE, (short)0 );
- fBuiltInTypes.put(POSITIVEINTEGER, positiveIntegerDV);
-
-
- fBuiltInTypes.put(FLOAT, new XSSimpleTypeDecl(baseAtomicType, FLOAT, XSSimpleTypeDecl.DV_FLOAT, XSSimpleType.ORDERED_PARTIAL, true, true, true, true, XSConstants.FLOAT_DT));
- fBuiltInTypes.put(DOUBLE, new XSSimpleTypeDecl(baseAtomicType, DOUBLE, XSSimpleTypeDecl.DV_DOUBLE, XSSimpleType.ORDERED_PARTIAL, true, true, true, true, XSConstants.DOUBLE_DT));
- fBuiltInTypes.put(HEXBINARY, new XSSimpleTypeDecl(baseAtomicType, HEXBINARY, XSSimpleTypeDecl.DV_HEXBINARY, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.HEXBINARY_DT));
- fBuiltInTypes.put(NOTATION, new XSSimpleTypeDecl(baseAtomicType, NOTATION, XSSimpleTypeDecl.DV_NOTATION, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.NOTATION_DT));
-
-
- facets.whiteSpace = XSSimpleType.WS_REPLACE;
- XSSimpleTypeDecl normalizedDV = new XSSimpleTypeDecl(stringDV, NORMALIZEDSTRING , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NORMALIZEDSTRING_DT);
- normalizedDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0 );
- fBuiltInTypes.put(NORMALIZEDSTRING, normalizedDV);
-
- facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
- XSSimpleTypeDecl tokenDV = new XSSimpleTypeDecl(normalizedDV, TOKEN , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.TOKEN_DT);
- tokenDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0 );
- fBuiltInTypes.put(TOKEN, tokenDV);
-
- facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
- facets.pattern = "([a-zA-Z]{1,8})(-[a-zA-Z0-9]{1,8})*";
- XSSimpleTypeDecl languageDV = new XSSimpleTypeDecl(tokenDV, LANGUAGE , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.LANGUAGE_DT);
- languageDV.applyFacets1(facets, (short)(XSSimpleType.FACET_WHITESPACE | XSSimpleType.FACET_PATTERN) ,(short)0);
- fBuiltInTypes.put(LANGUAGE, languageDV);
-
-
- facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
- XSSimpleTypeDecl nameDV = new XSSimpleTypeDecl(tokenDV, NAME , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NAME_DT);
- nameDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NAME);
- fBuiltInTypes.put(NAME, nameDV);
-
- facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
- XSSimpleTypeDecl ncnameDV = new XSSimpleTypeDecl(nameDV, NCNAME , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NCNAME_DT) ;
- ncnameDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NCNAME);
- fBuiltInTypes.put(NCNAME, ncnameDV);
-
- fBuiltInTypes.put(QNAME, new XSSimpleTypeDecl(baseAtomicType, QNAME, XSSimpleTypeDecl.DV_QNAME, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.QNAME_DT));
-
- fBuiltInTypes.put(ID, new XSSimpleTypeDecl(ncnameDV, ID, XSSimpleTypeDecl.DV_ID, XSSimpleType.ORDERED_FALSE, false, false, false , true, XSConstants.ID_DT));
- XSSimpleTypeDecl idrefDV = new XSSimpleTypeDecl(ncnameDV, IDREF , XSSimpleTypeDecl.DV_IDREF, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.IDREF_DT);
- fBuiltInTypes.put(IDREF, idrefDV);
-
- facets.minLength = 1;
- XSSimpleTypeDecl tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0, idrefDV, true, null);
- XSSimpleTypeDecl idrefsDV = new XSSimpleTypeDecl(tempDV, IDREFS, URI_SCHEMAFORSCHEMA, (short)0, false, null);
- idrefsDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0);
- fBuiltInTypes.put(IDREFS, idrefsDV);
-
- XSSimpleTypeDecl entityDV = new XSSimpleTypeDecl(ncnameDV, ENTITY , XSSimpleTypeDecl.DV_ENTITY, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.ENTITY_DT);
- fBuiltInTypes.put(ENTITY, entityDV);
-
- facets.minLength = 1;
- tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0, entityDV, true, null);
- XSSimpleTypeDecl entitiesDV = new XSSimpleTypeDecl(tempDV, ENTITIES, URI_SCHEMAFORSCHEMA, (short)0, false, null);
- entitiesDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0);
- fBuiltInTypes.put(ENTITIES, entitiesDV);
-
-
- facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
- XSSimpleTypeDecl nmtokenDV = new XSSimpleTypeDecl(tokenDV, NMTOKEN, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NMTOKEN_DT);
- nmtokenDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NMTOKEN);
- fBuiltInTypes.put(NMTOKEN, nmtokenDV);
-
- facets.minLength = 1;
- tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0, nmtokenDV, true, null);
- XSSimpleTypeDecl nmtokensDV = new XSSimpleTypeDecl(tempDV, NMTOKENS, URI_SCHEMAFORSCHEMA, (short)0, false, null);
- nmtokensDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0);
- fBuiltInTypes.put(NMTOKENS, nmtokensDV);
- }//createBuiltInTypes()
-
- public void setDeclPool (XSDeclarationPool declPool){
- fDeclPool = declPool;
- }
-
}//SchemaDVFactoryImpl
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaGrammar.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaGrammar.java?rev=735851&r1=735850&r2=735851&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaGrammar.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaGrammar.java Mon Jan 19 14:26:51 2009
@@ -123,6 +123,20 @@
*/
public SchemaGrammar(String targetNamespace, XSDDescription grammarDesc,
SymbolTable symbolTable) {
+ this(targetNamespace, grammarDesc, symbolTable, Constants.SCHEMA_VERSION_1_0);
+ }
+
+ /**
+ * Default constructor.
+ *
+ * @param targetNamespace
+ * @param grammarDesc the XMLGrammarDescription corresponding to this objec
+ * at the least a systemId should always be known.
+ * @param symbolTable needed for annotation support
+ * @param schemaVersion the XML schema version
+ */
+ public SchemaGrammar(String targetNamespace, XSDDescription grammarDesc,
+ SymbolTable symbolTable, short schemaVersion) {
fTargetNamespace = targetNamespace;
fGrammarDescription = grammarDesc;
fSymbolTable = symbolTable;
@@ -140,10 +154,12 @@
// if we are parsing S4S, put built-in types in first
// they might get overwritten by the types from S4S, but that's
// considered what the application wants to do.
- if (fTargetNamespace == SchemaSymbols.URI_SCHEMAFORSCHEMA)
- fGlobalTypeDecls = SG_SchemaNS.fGlobalTypeDecls.makeClone();
- else
+ if (fTargetNamespace == SchemaSymbols.URI_SCHEMAFORSCHEMA){
+ fGlobalTypeDecls = getS4SGrammar(schemaVersion).fGlobalTypeDecls.makeClone();
+ }
+ else {
fGlobalTypeDecls = new SymbolHash();
+ }
} // <init>(String, XSDDescription)
// number of built-in XSTypes we need to create for base and full
@@ -157,13 +173,26 @@
// this class makes sure the static, built-in schema grammars
// are immutable.
public static class BuiltinSchemaGrammar extends SchemaGrammar {
+
+ private static final String EXTENDED_SCHEMA_FACTORY_CLASS = "org.apache.xerces.impl.dv.xs.ExtendedSchemaDVFactoryImpl";
+ private static final String SCHEMA11_FACTORY_CLASS = "org.apache.xerces.impl.dv.xs.Schema11DVFactoryImpl";
+
/**
* Special constructor to create the grammars for the schema namespaces
*
* @param grammar
*/
- public BuiltinSchemaGrammar(int grammar) {
- SchemaDVFactory schemaFactory = SchemaDVFactory.getInstance();
+ public BuiltinSchemaGrammar(int grammar, short schemaVersion) {
+ SchemaDVFactory schemaFactory;
+ if (schemaVersion == Constants.SCHEMA_VERSION_1_0) {
+ schemaFactory = SchemaDVFactory.getInstance();
+ }
+ else if (schemaVersion == Constants.SCHEMA_VERSION_1_1) {
+ schemaFactory = SchemaDVFactory.getInstance(SCHEMA11_FACTORY_CLASS);
+ }
+ else {
+ schemaFactory = SchemaDVFactory.getInstance(EXTENDED_SCHEMA_FACTORY_CLASS);
+ }
if (grammar == GRAMMAR_XS) {
// target namespace
@@ -198,7 +227,8 @@
}
// add anyType
- fGlobalTypeDecls.put(fAnyType.getName(), fAnyType);
+ final XSComplexTypeDecl anyType = getXSAnyType(schemaVersion);
+ fGlobalTypeDecls.put(anyType.getName(), anyType);
}
else if (grammar == GRAMMAR_XSI) {
// target namespace
@@ -317,13 +347,24 @@
/**
* Singleton instance.
*/
- public static final Schema4Annotations INSTANCE = new Schema4Annotations();
-
+ private static final Schema4Annotations INSTANCE_10 = new Schema4Annotations(Constants.SCHEMA_VERSION_1_0);
+ private static final Schema4Annotations INSTANCE_Extended = new Schema4Annotations(Constants.SCHEMA_VERSION_1_0_EXTENDED);
+ private static final Schema4Annotations INSTANCE_11 = new Schema4Annotations(Constants.SCHEMA_VERSION_1_1);
+
+ public static Schema4Annotations getSchema4Annotations(short schemaVersion) {
+ if (schemaVersion == Constants.SCHEMA_VERSION_1_0) {
+ return INSTANCE_10;
+ }
+ else if (schemaVersion == Constants.SCHEMA_VERSION_1_1) {
+ return INSTANCE_11;
+ }
+ return INSTANCE_Extended;
+ }
/**
* Special constructor to create a schema
* capable of validating annotations.
*/
- private Schema4Annotations() {
+ private Schema4Annotations(short schemaVersion) {
// target namespace
fTargetNamespace = SchemaSymbols.URI_SCHEMAFORSCHEMA;
@@ -343,7 +384,7 @@
fGlobalIDConstraintDecls = new SymbolHash(1);
// get all built-in types
- fGlobalTypeDecls = SG_SchemaNS.fGlobalTypeDecls;
+ fGlobalTypeDecls = getS4SGrammar(schemaVersion).fGlobalTypeDecls;
// create element declarations for <annotation>, <documentation> and <appinfo>
XSElementDecl annotationDecl = createAnnotationElementDecl(SchemaSymbols.ELT_ANNOTATION);
@@ -433,21 +474,22 @@
// create wildcard particle for <documentation> and <appinfo>
XSParticleDecl anyWCSequenceParticle = createUnboundedAnyWildcardSequenceParticle();
-
+
// fill complex types
- annotationType.setValues("#AnonType_" + SchemaSymbols.ELT_ANNOTATION, fTargetNamespace, SchemaGrammar.fAnyType,
+ XSComplexTypeDecl anyType = getXSAnyType(schemaVersion);
+ annotationType.setValues("#AnonType_" + SchemaSymbols.ELT_ANNOTATION, fTargetNamespace, anyType,
XSConstants.DERIVATION_RESTRICTION, XSConstants.DERIVATION_NONE, (short) (XSConstants.DERIVATION_EXTENSION | XSConstants.DERIVATION_RESTRICTION),
XSComplexTypeDecl.CONTENTTYPE_ELEMENT, false, annotationAttrs, null, annotationParticle, new XSObjectListImpl(null, 0), null);
annotationType.setName("#AnonType_" + SchemaSymbols.ELT_ANNOTATION);
annotationType.setIsAnonymous();
- documentationType.setValues("#AnonType_" + SchemaSymbols.ELT_DOCUMENTATION, fTargetNamespace, SchemaGrammar.fAnyType,
+ documentationType.setValues("#AnonType_" + SchemaSymbols.ELT_DOCUMENTATION, fTargetNamespace, anyType,
XSConstants.DERIVATION_RESTRICTION, XSConstants.DERIVATION_NONE, (short) (XSConstants.DERIVATION_EXTENSION | XSConstants.DERIVATION_RESTRICTION),
XSComplexTypeDecl.CONTENTTYPE_MIXED, false, documentationAttrs, null, anyWCSequenceParticle, new XSObjectListImpl(null, 0), null);
documentationType.setName("#AnonType_" + SchemaSymbols.ELT_DOCUMENTATION);
documentationType.setIsAnonymous();
- appinfoType.setValues("#AnonType_" + SchemaSymbols.ELT_APPINFO, fTargetNamespace, SchemaGrammar.fAnyType,
+ appinfoType.setValues("#AnonType_" + SchemaSymbols.ELT_APPINFO, fTargetNamespace, anyType,
XSConstants.DERIVATION_RESTRICTION, XSConstants.DERIVATION_NONE, (short) (XSConstants.DERIVATION_EXTENSION | XSConstants.DERIVATION_RESTRICTION),
XSComplexTypeDecl.CONTENTTYPE_MIXED, false, appinfoAttrs, null, anyWCSequenceParticle, new XSObjectListImpl(null, 0), null);
appinfoType.setName("#AnonType_" + SchemaSymbols.ELT_APPINFO);
@@ -862,7 +904,24 @@
// anyType and anySimpleType: because there are so many places where
// we need direct access to these two types
- public final static XSComplexTypeDecl fAnyType = new XSAnyType();
+ private final static XSComplexTypeDecl fAnyType = new XSAnyType();
+ private final static XSComplexTypeDecl fAnyTypeExtended = new XSAnyTypeExtended();
+ private final static XSComplexTypeDecl fAnyType11 = new XS11AnyType();
+
+ public static XSComplexTypeDecl getXSAnyType(short schemaVersion) {
+ if (schemaVersion == Constants.SCHEMA_VERSION_1_0) {
+ return fAnyType;
+ }
+ else if (schemaVersion == Constants.SCHEMA_VERSION_1_1) {
+ return fAnyType11;
+ }
+ return fAnyTypeExtended;
+ }
+
+ public static boolean isAnyType(XSTypeDefinition type) {
+ return type == fAnyType || type == fAnyType11 || type == fAnyTypeExtended;
+ }
+
private static class XSAnyType extends XSComplexTypeDecl {
public XSAnyType () {
fName = SchemaSymbols.ATTVAL_ANYTYPE;
@@ -955,6 +1014,20 @@
return SG_SchemaNS;
}
}
+
+ private static class XS11AnyType extends XSAnyType {
+ public XSNamespaceItem getNamespaceItem() {
+ return SG_Schema11NS;
+ }
+ }
+
+ private static class XSAnyTypeExtended extends XSAnyType {
+ public XSNamespaceItem getNamespaceItem() {
+ return SG_SchemaNSExtended;
+ }
+ }
+
+
private static class BuiltinAttrDecl extends XSAttributeDecl {
public BuiltinAttrDecl(String name, String tns,
XSSimpleType type, short scope) {
@@ -985,12 +1058,25 @@
} // class BuiltinAttrDecl
// the grammars to hold components of the schema namespace
- public final static BuiltinSchemaGrammar SG_SchemaNS = new BuiltinSchemaGrammar(GRAMMAR_XS);
+ private final static BuiltinSchemaGrammar SG_SchemaNS = new BuiltinSchemaGrammar(GRAMMAR_XS, Constants.SCHEMA_VERSION_1_0);
+ private final static BuiltinSchemaGrammar SG_SchemaNSExtended = new BuiltinSchemaGrammar(GRAMMAR_XS, Constants.SCHEMA_VERSION_1_0_EXTENDED);
+ private final static BuiltinSchemaGrammar SG_Schema11NS = new BuiltinSchemaGrammar(GRAMMAR_XS, Constants.SCHEMA_VERSION_1_1);
public final static XSSimpleType fAnySimpleType = (XSSimpleType)SG_SchemaNS.getGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYSIMPLETYPE);
// the grammars to hold components of the schema-instance namespace
- public final static BuiltinSchemaGrammar SG_XSI = new BuiltinSchemaGrammar(GRAMMAR_XSI);
+ public final static BuiltinSchemaGrammar SG_XSI = new BuiltinSchemaGrammar(GRAMMAR_XSI, Constants.SCHEMA_VERSION_1_0);
+
+ public static SchemaGrammar getS4SGrammar(short schemaVersion) {
+ if (schemaVersion == Constants.SCHEMA_VERSION_1_0) {
+ return SG_SchemaNS;
+ }
+ else if (schemaVersion == Constants.SCHEMA_VERSION_1_1) {
+ return SG_Schema11NS;
+ }
+
+ return SG_SchemaNSExtended;
+ }
static final XSComplexTypeDecl[] resize(XSComplexTypeDecl[] oldArray, int newSize) {
XSComplexTypeDecl[] newArray = new XSComplexTypeDecl[newSize];
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SubstitutionGroupHandler.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SubstitutionGroupHandler.java?rev=735851&r1=735850&r2=735851&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SubstitutionGroupHandler.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SubstitutionGroupHandler.java Mon Jan 19 14:26:51 2009
@@ -51,7 +51,7 @@
// 3.9.4 Element Sequence Locally Valid (Particle) 2.3.3
// check whether one element decl matches an element with the given qname
- public XSElementDecl getMatchingElemDecl(QName element, XSElementDecl exemplar) {
+ public XSElementDecl getMatchingElemDecl(QName element, XSElementDecl exemplar, short schemaVersion) {
if (element.localpart == exemplar.fName &&
element.uri == exemplar.fTargetNamespace) {
return exemplar;
@@ -81,7 +81,7 @@
}
// and check by using substitutionGroup information
- if (substitutionGroupOK(eDecl, exemplar, exemplar.fBlock)) {
+ if (substitutionGroupOK(eDecl, exemplar, exemplar.fBlock, schemaVersion)) {
return eDecl;
}
@@ -90,7 +90,7 @@
// 3.3.6 Substitution Group OK (Transitive)
// check whether element can substitute exemplar
- protected boolean substitutionGroupOK(XSElementDecl element, XSElementDecl exemplar, short blockingConstraint) {
+ protected boolean substitutionGroupOK(XSElementDecl element, XSElementDecl exemplar, short blockingConstraint, short schemaVersion) {
// For an element declaration (call it D) to be validly substitutable for another element declaration (call it C) subject to a blocking constraint (a subset of {substitution, extension, restriction}, the value of a {disallowed substitutions}) one of the following must be true:
// 1. D and C are the same element declaration.
if (element == exemplar) {
@@ -112,7 +112,7 @@
// 2.3 The set of all {derivation method}s involved in the derivation of D's {type definition} from C's {type definition} does not intersect with the union of the blocking constraint, C's {prohibited substitutions} (if C is complex, otherwise the empty set) and the {prohibited substitutions} (respectively the empty set) of any intermediate {type definition}s in the derivation of D's {type definition} from C's {type definition}.
// prepare the combination of {derivation method} and
// {disallowed substitution}
- return typeDerivationOK(element.fType, exemplar.fType, blockingConstraint);
+ return typeDerivationOK(element.fType, exemplar.fType, blockingConstraint, schemaVersion);
}
// Recursively check if there is a element in substitution group matching exemplar
@@ -127,7 +127,7 @@
return false;
}
- private boolean typeDerivationOK(XSTypeDefinition derived, XSTypeDefinition base, short blockingConstraint) {
+ private boolean typeDerivationOK(XSTypeDefinition derived, XSTypeDefinition base, short blockingConstraint, short schemaVersion) {
short devMethod = 0, blockConstraint = blockingConstraint;
@@ -135,7 +135,7 @@
// add derivation methods of derived types to devMethod;
// add block of base types to blockConstraint.
XSTypeDefinition type = derived;
- while (type != base && type != SchemaGrammar.fAnyType) {
+ while (type != base && !SchemaGrammar.isAnyType(type)) {
if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
devMethod |= ((XSComplexTypeDecl)type).fDerivedBy;
}
@@ -146,7 +146,7 @@
// type == null means the current type is anySimpleType,
// whose base type should be anyType
if (type == null) {
- type = SchemaGrammar.fAnyType;
+ type = SchemaGrammar.getXSAnyType(schemaVersion);
}
if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
blockConstraint |= ((XSComplexTypeDecl)type).fBlock;
@@ -160,7 +160,7 @@
XSObjectList memberTypes = st.getMemberTypes();
final int length = memberTypes.getLength();
for (int i = 0; i < length; ++i) {
- if (typeDerivationOK(derived, (XSTypeDefinition) memberTypes.item(i), blockingConstraint)) {
+ if (typeDerivationOK(derived, (XSTypeDefinition) memberTypes.item(i), blockingConstraint, schemaVersion)) {
return true;
}
}
@@ -175,7 +175,7 @@
}
// check whether element is in exemplar's substitution group
- public boolean inSubstitutionGroup(XSElementDecl element, XSElementDecl exemplar) {
+ public boolean inSubstitutionGroup(XSElementDecl element, XSElementDecl exemplar, short schemaVersion) {
// [Definition:] Every element declaration (call this HEAD) in the {element declarations} of a schema defines a substitution group, a subset of those {element declarations}, as follows:
// Define PSG, the potential substitution group for HEAD, as follows:
// 1 The element declaration itself is in PSG;
@@ -183,7 +183,7 @@
// HEAD's actual substitution group is then the set consisting of each member of PSG such that all of the following must be true:
// 1 Its {abstract} is false.
// 2 It is validly substitutable for HEAD subject to an empty blocking constraint, as defined in Substitution Group OK (Transitive) (3.3.6).
- return substitutionGroupOK(element, exemplar, exemplar.fBlock);
+ return substitutionGroupOK(element, exemplar, exemplar.fBlock, schemaVersion);
}
// to store substitution group information
@@ -239,7 +239,7 @@
* the element itself. but the array returned from this method doesn't
* containt this element.
*/
- public XSElementDecl[] getSubstitutionGroup(XSElementDecl element) {
+ public XSElementDecl[] getSubstitutionGroup(XSElementDecl element, short schemaVersion) {
// If we already have sub group for this element, just return it.
Object subGroup = fSubGroups.get(element);
if (subGroup != null)
@@ -252,7 +252,7 @@
// Otherwise, get all potential sub group elements
// (without considering "block" on this element
- OneSubGroup[] groupB = getSubGroupB(element, new OneSubGroup());
+ OneSubGroup[] groupB = getSubGroupB(element, new OneSubGroup(), schemaVersion);
int len = groupB.length, rlen = 0;
XSElementDecl[] ret = new XSElementDecl[len];
// For each of such elements, check whether the derivation methods
@@ -274,7 +274,7 @@
}
// Get potential sub group element (without considering "block")
- private OneSubGroup[] getSubGroupB(XSElementDecl element, OneSubGroup methods) {
+ private OneSubGroup[] getSubGroupB(XSElementDecl element, OneSubGroup methods, short schemaVersion) {
Object subGroup = fSubGroupsB.get(element);
// substitution group for this one is empty
@@ -296,7 +296,7 @@
for (int i = group.size()-1, j; i >= 0; i--) {
// Check whether this element is blocked. If so, ignore it.
XSElementDecl sub = (XSElementDecl)group.elementAt(i);
- if (!getDBMethods(sub.fType, element.fType, methods))
+ if (!getDBMethods(sub.fType, element.fType, methods, schemaVersion))
continue;
// Remember derivation methods and blocks from the types
dMethod = methods.dMethod;
@@ -304,7 +304,7 @@
// Add this one to potential group
newGroup.addElement(new OneSubGroup(sub, methods.dMethod, methods.bMethod));
// Get potential group for this element
- group1 = getSubGroupB(sub, methods);
+ group1 = getSubGroupB(sub, methods, schemaVersion);
for (j = group1.length-1; j >= 0; j--) {
// For each of them, check whether it's blocked (by type)
dSubMethod = (short)(dMethod | group1[j].dMethod);
@@ -327,9 +327,9 @@
}
private boolean getDBMethods(XSTypeDefinition typed, XSTypeDefinition typeb,
- OneSubGroup methods) {
+ OneSubGroup methods, short schemaVersion) {
short dMethod = 0, bMethod = 0;
- while (typed != typeb && typed != SchemaGrammar.fAnyType) {
+ while (typed != typeb && !SchemaGrammar.isAnyType(typed)) {
if (typed.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE)
dMethod |= ((XSComplexTypeDecl)typed).fDerivedBy;
else
@@ -338,7 +338,7 @@
// type == null means the current type is anySimpleType,
// whose base type should be anyType
if (typed == null)
- typed = SchemaGrammar.fAnyType;
+ typed = SchemaGrammar.getXSAnyType(schemaVersion);
if (typed.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE)
bMethod |= ((XSComplexTypeDecl)typed).fBlock;
}
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java?rev=735851&r1=735850&r2=735851&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java Mon Jan 19 14:26:51 2009
@@ -486,13 +486,17 @@
* Sets the XML Schema Version
*/
void setSchemaVersion(String version) {
- if (version.equals(Constants.W3C_XML_SCHEMA11_NS_URI)) {
+ if (version.equals(Constants.W3C_XML_SCHEMA10_NS_URI)) {
+ fSchemaVersion = Constants.SCHEMA_VERSION_1_0;
+ fXSConstraints = XSConstraints.XS_1_0_CONSTRAINTS;
+ }
+ else if (version.equals(Constants.W3C_XML_SCHEMA11_NS_URI)) {
fSchemaVersion = Constants.SCHEMA_VERSION_1_1;
fXSConstraints = XSConstraints.XS_1_1_CONSTRAINTS;
}
else {
- fSchemaVersion = Constants.SCHEMA_VERSION_1_0;
- fXSConstraints = XSConstraints.XS_1_0_CONSTRAINTS;
+ fSchemaVersion = Constants.SCHEMA_VERSION_1_0_EXTENDED;
+ fXSConstraints = XSConstraints.XS_1_0_CONSTRAINTS_EXTENDED;
}
fSchemaHandler.setSchemaVersionInfo(fSchemaVersion, fXSConstraints);
fCMBuilder.setSchemaVersion(fSchemaVersion);
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java?rev=735851&r1=735850&r2=735851&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java Mon Jan 19 14:26:51 2009
@@ -1161,8 +1161,9 @@
/** the DV usd to convert xsi:type to a QName */
// REVISIT: in new simple type design, make things in DVs static,
// so that we can QNameDV.getCompiledForm()
+ // using 1.0 xs:QName
private final XSSimpleType fQNameDV =
- (XSSimpleType) SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(SchemaSymbols.ATTVAL_QNAME);
+ (XSSimpleType) SchemaGrammar.getS4SGrammar(Constants.SCHEMA_VERSION_1_0).getGlobalTypeDecl(SchemaSymbols.ATTVAL_QNAME);
private final CMNodeFactory nodeFactory = new CMNodeFactory();
/** used to build content models */
@@ -2099,7 +2100,7 @@
// no element decl or type found for this element.
// Allowed by the spec, we can choose to either laxly assess this
// element, or to skip it. Now we choose lax assessment.
- fCurrentType = SchemaGrammar.fAnyType;
+ fCurrentType = SchemaGrammar.getXSAnyType(fSchemaVersion);
fStrictAssess = false;
fNFullValidationDepth = fElementDepth;
// any type has mixed content, so we don't need to append buffer
@@ -2122,7 +2123,7 @@
// If it fails, use the old type. Use anyType if ther is no old type.
if (fCurrentType == null) {
if (oldType == null)
- fCurrentType = SchemaGrammar.fAnyType;
+ fCurrentType = SchemaGrammar.getXSAnyType(fSchemaVersion);
else
fCurrentType = oldType;
}
@@ -2337,7 +2338,8 @@
fGrammarBucket,
fSubGroupHandler,
fCMBuilder,
- fXSIErrorReporter.fErrorReporter);
+ fXSIErrorReporter.fErrorReporter,
+ fSchemaVersion);
}
if (fAugPSVI)
@@ -2666,6 +2668,16 @@
} //findSchemaGrammar
+ private boolean isValidBuiltInTypeName(String localpart) {
+ if (fSchemaVersion == Constants.SCHEMA_VERSION_1_0_EXTENDED) {
+ if (localpart.equals("duration") ||
+ localpart.equals("yearMonthDuration") ||
+ localpart.equals("dayTimeDuration")) {
+ return false;
+ }
+ }
+ return true;
+ }
XSTypeDefinition getAndCheckXsiType(QName element, String xsiType, XMLAttributes attributes) {
// This method also deals with clause 1.2.1.2 of the constraint
// Validation Rule: Schema-Validity Assessment (Element)
@@ -2691,7 +2703,10 @@
XSTypeDefinition type = null;
// if the namespace is schema namespace, first try built-in types
if (typeName.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA) {
- type = SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(typeName.localpart);
+ if (isValidBuiltInTypeName(typeName.localpart)) {
+ SchemaGrammar s4s = SchemaGrammar.getS4SGrammar(fSchemaVersion);
+ type = s4s.getGlobalTypeDecl(typeName.localpart);
+ }
}
// if it's not schema built-in types, then try to get a grammar
if (type == null) {
@@ -3421,7 +3436,11 @@
rootTypeNamespace = null;
}
if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(rootTypeNamespace)) {
- fCurrentType = SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(rootTypeQName.getLocalPart());
+ String rootLocalPart = rootTypeQName.getLocalPart();
+ if (isValidBuiltInTypeName(rootLocalPart)) {
+ SchemaGrammar s4s = SchemaGrammar.getS4SGrammar(fSchemaVersion);
+ fCurrentType = s4s.getGlobalTypeDecl(rootLocalPart);
+ }
}
else {
final SchemaGrammar grammarForRootType = findSchemaGrammar(
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XS10Constraints.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XS10Constraints.java?rev=735851&r1=735850&r2=735851&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XS10Constraints.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XS10Constraints.java Mon Jan 19 14:26:51 2009
@@ -17,6 +17,10 @@
package org.apache.xerces.impl.xs;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.xs.models.CMBuilder;
+import org.apache.xerces.util.SymbolHash;
+
/**
* XML Schema 1.0 constraints
*
@@ -30,8 +34,12 @@
*/
class XS10Constraints extends XSConstraints {
- public XS10Constraints() {
- super(SchemaGrammar.fAnyType);
+ // accomodate 1.0 extended
+ private short fSchemaVersion;
+
+ public XS10Constraints(short schemaVersion) {
+ super(SchemaGrammar.getXSAnyType(schemaVersion));
+ fSchemaVersion = schemaVersion;
}
public boolean overlapUPA(XSElementDecl element,
@@ -42,7 +50,7 @@
return true;
// or if the wildcard allows any element in the substitution group
- XSElementDecl[] subGroup = sgHandler.getSubstitutionGroup(element);
+ XSElementDecl[] subGroup = sgHandler.getSubstitutionGroup(element, fSchemaVersion);
for (int i = subGroup.length-1; i >= 0; i--) {
if (wildcard.allowNamespace(subGroup[i].fTargetNamespace))
return true;
@@ -63,6 +71,26 @@
return false;
}
+
+ public boolean overlapUPA(XSElementDecl element1,
+ XSElementDecl element2,
+ SubstitutionGroupHandler sgHandler) {
+ return overlapUPA(element1, element2, sgHandler, fSchemaVersion);
+ }
+
+ public void checkElementDeclsConsistent(XSComplexTypeDecl type,
+ XSParticleDecl particle,
+ SymbolHash elemDeclHash,
+ SubstitutionGroupHandler sgHandler) throws XMLSchemaException {
+ checkElementDeclsConsistent(type, particle, elemDeclHash, sgHandler, fSchemaVersion);
+ }
+
+ public void fullSchemaChecking(XSGrammarBucket grammarBucket,
+ SubstitutionGroupHandler SGHandler,
+ CMBuilder cmBuilder,
+ XMLErrorReporter errorReporter) {
+ fullSchemaChecking(grammarBucket, SGHandler, cmBuilder, errorReporter, fSchemaVersion);
+ }
/**
* Schema Component Constraint: Wildcard Subset
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XS11Constraints.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XS11Constraints.java?rev=735851&r1=735850&r2=735851&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XS11Constraints.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XS11Constraints.java Mon Jan 19 14:26:51 2009
@@ -17,6 +17,10 @@
package org.apache.xerces.impl.xs;
+import org.apache.xerces.impl.Constants;
+import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.xs.models.CMBuilder;
+import org.apache.xerces.util.SymbolHash;
import org.apache.xerces.xni.QName;
/**
@@ -32,7 +36,7 @@
class XS11Constraints extends XSConstraints {
public XS11Constraints() {
- super(SchemaGrammar.fAnyType);
+ super(SchemaGrammar.getXSAnyType(Constants.SCHEMA_VERSION_1_1));
}
public boolean overlapUPA(XSElementDecl element,
@@ -54,6 +58,26 @@
return false;
}
+ public boolean overlapUPA(XSElementDecl element1,
+ XSElementDecl element2,
+ SubstitutionGroupHandler sgHandler) {
+ return overlapUPA(element1, element2, sgHandler, Constants.SCHEMA_VERSION_1_1);
+ }
+
+ public void checkElementDeclsConsistent(XSComplexTypeDecl type,
+ XSParticleDecl particle,
+ SymbolHash elemDeclHash,
+ SubstitutionGroupHandler sgHandler) throws XMLSchemaException {
+ checkElementDeclsConsistent(type, particle, elemDeclHash, sgHandler, Constants.SCHEMA_VERSION_1_1);
+ }
+
+ public void fullSchemaChecking(XSGrammarBucket grammarBucket,
+ SubstitutionGroupHandler SGHandler,
+ CMBuilder cmBuilder,
+ XMLErrorReporter errorReporter) {
+ fullSchemaChecking(grammarBucket, SGHandler, cmBuilder, errorReporter, Constants.SCHEMA_VERSION_1_1);
+ }
+
/**
* Schema Component Constraint: Wildcard Subset
*/
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSComplexTypeDecl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSComplexTypeDecl.java?rev=735851&r1=735850&r2=735851&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSComplexTypeDecl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSComplexTypeDecl.java Mon Jan 19 14:26:51 2009
@@ -246,13 +246,13 @@
if (ancestor == null)
return false;
// ancestor is anyType, return true
- if (ancestor == SchemaGrammar.fAnyType)
+ if (SchemaGrammar.isAnyType(ancestor))
return true;
// recursively get base, and compare it with ancestor
XSTypeDefinition type = this;
while (type != ancestor && // compare with ancestor
type != SchemaGrammar.fAnySimpleType && // reached anySimpleType
- type != SchemaGrammar.fAnyType) { // reached anyType
+ !SchemaGrammar.isAnyType(type)) { // reached anyType
type = type.getBaseType();
}
@@ -276,12 +276,11 @@
((ancestorNS == null && type.getNamespace() == null) ||
(ancestorNS != null && ancestorNS.equals(type.getNamespace())))) && // compare with ancestor
type != SchemaGrammar.fAnySimpleType && // reached anySimpleType
- type != SchemaGrammar.fAnyType) { // reached anyType
+ !SchemaGrammar.isAnyType(type)) { // reached anyType
type = (XSTypeDefinition)type.getBaseType();
}
- return type != SchemaGrammar.fAnySimpleType &&
- type != SchemaGrammar.fAnyType;
+ return type != SchemaGrammar.fAnySimpleType && !SchemaGrammar.isAnyType(type);
}
/**
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSConstraints.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSConstraints.java?rev=735851&r1=735850&r2=735851&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSConstraints.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSConstraints.java Mon Jan 19 14:26:51 2009
@@ -21,6 +21,7 @@
import java.util.Comparator;
import java.util.Vector;
+import org.apache.xerces.impl.Constants;
import org.apache.xerces.impl.XMLErrorReporter;
import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
import org.apache.xerces.impl.dv.ValidatedInfo;
@@ -51,9 +52,11 @@
// (IHR@xbrl.org) (Ignacio@Hernandez-Ros.com)
static final int OCCURRENCE_UNKNOWN = SchemaSymbols.OCCURRENCE_UNBOUNDED-1;
- static final XSSimpleType STRING_TYPE = (XSSimpleType)SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(SchemaSymbols.ATTVAL_STRING);
+ // TODO: using 1.0 xs:string
+ static final XSSimpleType STRING_TYPE = (XSSimpleType)SchemaGrammar.getS4SGrammar(Constants.SCHEMA_VERSION_1_0).getGlobalTypeDecl(SchemaSymbols.ATTVAL_STRING);
- static final XSConstraints XS_1_0_CONSTRAINTS = new XS10Constraints();
+ static final XSConstraints XS_1_0_CONSTRAINTS = new XS10Constraints(Constants.SCHEMA_VERSION_1_0);
+ static final XSConstraints XS_1_0_CONSTRAINTS_EXTENDED = new XS10Constraints(Constants.SCHEMA_VERSION_1_0_EXTENDED);
static final XSConstraints XS_1_1_CONSTRAINTS = new XS11Constraints();
private final XSComplexTypeDecl fAnyType;
@@ -341,10 +344,16 @@
* Unique Particle Attribution, Particle Derivation (Restriction),
* Element Declrations Consistent.
*/
- public void fullSchemaChecking(XSGrammarBucket grammarBucket,
+ public abstract void fullSchemaChecking(XSGrammarBucket grammarBucket,
SubstitutionGroupHandler SGHandler,
CMBuilder cmBuilder,
- XMLErrorReporter errorReporter) {
+ XMLErrorReporter errorReporter);
+
+ protected void fullSchemaChecking(XSGrammarBucket grammarBucket,
+ SubstitutionGroupHandler SGHandler,
+ CMBuilder cmBuilder,
+ XMLErrorReporter errorReporter,
+ short schemaVersion) {
// get all grammars, and put all substitution group information
// in the substitution group handler
SchemaGrammar[] grammars = grammarBucket.getGrammars();
@@ -376,7 +385,7 @@
fakeDerived.fValue = derivedMG;
fakeBase.fValue = baseMG;
try {
- particleValidRestriction(fakeDerived, SGHandler, fakeBase, SGHandler);
+ particleValidRestriction(fakeDerived, SGHandler, fakeBase, SGHandler, schemaVersion);
} catch (XMLSchemaException e) {
String key = e.getKey();
reportSchemaError(errorReporter, rgLocators[i/2-1],
@@ -453,7 +462,7 @@
particleValidRestriction(types[j].fParticle,
SGHandler,
((XSComplexTypeDecl)(types[j].fBaseType)).fParticle,
- SGHandler);
+ SGHandler, schemaVersion);
} catch (XMLSchemaException e) {
reportSchemaError(errorReporter, ctLocators[j],
e.getKey(),
@@ -513,11 +522,15 @@
/*
Check that a given particle is a valid restriction of a base particle.
*/
+ public abstract void checkElementDeclsConsistent(XSComplexTypeDecl type,
+ XSParticleDecl particle,
+ SymbolHash elemDeclHash,
+ SubstitutionGroupHandler sgHandler) throws XMLSchemaException;
- public void checkElementDeclsConsistent(XSComplexTypeDecl type,
+ protected void checkElementDeclsConsistent(XSComplexTypeDecl type,
XSParticleDecl particle,
SymbolHash elemDeclHash,
- SubstitutionGroupHandler sgHandler)
+ SubstitutionGroupHandler sgHandler, short schemaVersion)
throws XMLSchemaException {
// check for elements in the tree with the same name and namespace
@@ -533,7 +546,7 @@
if (elem.fScope == XSConstants.SCOPE_GLOBAL) {
// Check for subsitution groups.
- XSElementDecl[] subGroup = sgHandler.getSubstitutionGroup(elem);
+ XSElementDecl[] subGroup = sgHandler.getSubstitutionGroup(elem, schemaVersion);
for (int i = 0; i < subGroup.length; i++) {
findElemInTable(type, subGroup[i], elemDeclHash);
}
@@ -582,16 +595,18 @@
private boolean particleValidRestriction(XSParticleDecl dParticle,
SubstitutionGroupHandler dSGHandler,
XSParticleDecl bParticle,
- SubstitutionGroupHandler bSGHandler)
+ SubstitutionGroupHandler bSGHandler,
+ short schemaVersion)
throws XMLSchemaException {
- return particleValidRestriction(dParticle, dSGHandler, bParticle, bSGHandler, true);
+ return particleValidRestriction(dParticle, dSGHandler, bParticle, bSGHandler, true, schemaVersion);
}
private boolean particleValidRestriction(XSParticleDecl dParticle,
SubstitutionGroupHandler dSGHandler,
XSParticleDecl bParticle,
SubstitutionGroupHandler bSGHandler,
- boolean checkWCOccurrence)
+ boolean checkWCOccurrence,
+ short schemaVersion)
throws XMLSchemaException {
Vector dChildren = null;
@@ -656,7 +671,7 @@
// Check for subsitution groups. Treat any element that has a
// subsitution group as a choice. Fill in the children vector with the
// members of the substitution group
- XSElementDecl[] subGroup = dSGHandler.getSubstitutionGroup(dElement);
+ XSElementDecl[] subGroup = dSGHandler.getSubstitutionGroup(dElement, schemaVersion);
if (subGroup.length >0 ) {
// Now, set the type to be CHOICE. The "group" will have the same
// occurrence information as the original particle.
@@ -713,7 +728,7 @@
// Check for subsitution groups. Treat any element that has a
// subsitution group as a choice. Fill in the children vector with the
// members of the substitution group
- XSElementDecl[] bsubGroup = bSGHandler.getSubstitutionGroup(bElement);
+ XSElementDecl[] bsubGroup = bSGHandler.getSubstitutionGroup(bElement, schemaVersion);
if (bsubGroup.length >0 ) {
// Now, set the type to be CHOICE
bType = XSModelGroupImpl.MODELGROUP_CHOICE;
@@ -768,7 +783,7 @@
dChildren.addElement(dParticle);
checkRecurseLax(dChildren, 1, 1, dSGHandler,
- bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
+ bChildren, bMinOccurs, bMaxOccurs, bSGHandler, schemaVersion);
return bExpansionHappened;
}
case XSModelGroupImpl.MODELGROUP_SEQUENCE:
@@ -780,7 +795,7 @@
dChildren.addElement(dParticle);
checkRecurse(dChildren, 1, 1, dSGHandler,
- bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
+ bChildren, bMinOccurs, bMaxOccurs, bSGHandler, schemaVersion);
return bExpansionHappened;
}
@@ -837,7 +852,7 @@
dMaxEffectiveTotalRange,
dSGHandler,
bParticle,bMinOccurs,bMaxOccurs,
- checkWCOccurrence);
+ checkWCOccurrence, schemaVersion);
return bExpansionHappened;
}
@@ -845,7 +860,7 @@
case XSModelGroupImpl.MODELGROUP_ALL:
{
checkRecurse(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
- bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
+ bChildren, bMinOccurs, bMaxOccurs, bSGHandler, schemaVersion);
return bExpansionHappened;
}
@@ -881,14 +896,14 @@
dMaxEffectiveTotalRange,
dSGHandler,
bParticle,bMinOccurs,bMaxOccurs,
- checkWCOccurrence);
+ checkWCOccurrence, schemaVersion);
return bExpansionHappened;
}
case XSModelGroupImpl.MODELGROUP_CHOICE:
{
checkRecurseLax(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
- bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
+ bChildren, bMinOccurs, bMaxOccurs, bSGHandler, schemaVersion);
return bExpansionHappened;
}
@@ -925,21 +940,21 @@
dMaxEffectiveTotalRange,
dSGHandler,
bParticle,bMinOccurs,bMaxOccurs,
- checkWCOccurrence);
+ checkWCOccurrence, schemaVersion);
return bExpansionHappened;
}
case XSModelGroupImpl.MODELGROUP_ALL:
{
checkRecurseUnordered(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
- bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
+ bChildren, bMinOccurs, bMaxOccurs, bSGHandler, schemaVersion);
return bExpansionHappened;
}
case XSModelGroupImpl.MODELGROUP_SEQUENCE:
{
checkRecurse(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
- bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
+ bChildren, bMinOccurs, bMaxOccurs, bSGHandler, schemaVersion);
return bExpansionHappened;
}
@@ -949,7 +964,7 @@
int max1 = (dMaxOccurs == SchemaSymbols.OCCURRENCE_UNBOUNDED)?
dMaxOccurs : dMaxOccurs * dChildren.size();
checkMapAndSum(dChildren, min1, max1, dSGHandler,
- bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
+ bChildren, bMinOccurs, bMaxOccurs, bSGHandler, schemaVersion);
return bExpansionHappened;
}
@@ -1200,7 +1215,7 @@
private void checkNSRecurseCheckCardinality(Vector children, int min1, int max1,
SubstitutionGroupHandler dSGHandler,
XSParticleDecl wildcard, int min2, int max2,
- boolean checkWCOccurrence)
+ boolean checkWCOccurrence, short schemaVersion)
throws XMLSchemaException {
@@ -1218,7 +1233,7 @@
try {
for (int i = 0; i < count; i++) {
XSParticleDecl particle1 = (XSParticleDecl)children.elementAt(i);
- particleValidRestriction(particle1, dSGHandler, wildcard, null, false);
+ particleValidRestriction(particle1, dSGHandler, wildcard, null, false, schemaVersion);
}
}
@@ -1233,7 +1248,7 @@
private void checkRecurse(Vector dChildren, int min1, int max1,
SubstitutionGroupHandler dSGHandler,
Vector bChildren, int min2, int max2,
- SubstitutionGroupHandler bSGHandler)
+ SubstitutionGroupHandler bSGHandler, short schemaVersion)
throws XMLSchemaException {
// check Occurrence ranges
@@ -1256,7 +1271,7 @@
XSParticleDecl particle2 = (XSParticleDecl)bChildren.elementAt(j);
current +=1;
try {
- particleValidRestriction(particle1, dSGHandler, particle2, bSGHandler);
+ particleValidRestriction(particle1, dSGHandler, particle2, bSGHandler, schemaVersion);
continue label;
}
catch (XMLSchemaException e) {
@@ -1280,7 +1295,8 @@
private void checkRecurseUnordered(Vector dChildren, int min1, int max1,
SubstitutionGroupHandler dSGHandler,
Vector bChildren, int min2, int max2,
- SubstitutionGroupHandler bSGHandler)
+ SubstitutionGroupHandler bSGHandler,
+ short schemaVersion)
throws XMLSchemaException {
@@ -1304,7 +1320,7 @@
for (int j = 0; j<count2; j++) {
XSParticleDecl particle2 = (XSParticleDecl)bChildren.elementAt(j);
try {
- particleValidRestriction(particle1, dSGHandler, particle2, bSGHandler);
+ particleValidRestriction(particle1, dSGHandler, particle2, bSGHandler, schemaVersion);
if (foundIt[j])
throw new XMLSchemaException("rcase-RecurseUnordered.2", null);
else
@@ -1332,7 +1348,8 @@
private void checkRecurseLax(Vector dChildren, int min1, int max1,
SubstitutionGroupHandler dSGHandler,
Vector bChildren, int min2, int max2,
- SubstitutionGroupHandler bSGHandler)
+ SubstitutionGroupHandler bSGHandler,
+ short schemaVersion)
throws XMLSchemaException {
// check Occurrence ranges
@@ -1357,7 +1374,7 @@
try {
// IHR: go back one element on b list because the next element may match
// this as well.
- if (particleValidRestriction(particle1, dSGHandler, particle2, bSGHandler))
+ if (particleValidRestriction(particle1, dSGHandler, particle2, bSGHandler, schemaVersion))
current--;
continue label;
}
@@ -1374,7 +1391,8 @@
private void checkMapAndSum(Vector dChildren, int min1, int max1,
SubstitutionGroupHandler dSGHandler,
Vector bChildren, int min2, int max2,
- SubstitutionGroupHandler bSGHandler)
+ SubstitutionGroupHandler bSGHandler,
+ short schemaVersion)
throws XMLSchemaException {
// See if the sequence group is a valid restriction of the choice
@@ -1409,7 +1427,7 @@
for (int j = 0; j<count2; j++) {
XSParticleDecl particle2 = (XSParticleDecl)bChildren.elementAt(j);
try {
- particleValidRestriction(particle1, dSGHandler, particle2, bSGHandler);
+ particleValidRestriction(particle1, dSGHandler, particle2, bSGHandler, schemaVersion);
continue label;
}
catch (XMLSchemaException e) {
@@ -1420,9 +1438,13 @@
}
}
// to check whether two element overlap, as defined in constraint UPA
- public boolean overlapUPA(XSElementDecl element1,
+ public abstract boolean overlapUPA(XSElementDecl element1,
XSElementDecl element2,
- SubstitutionGroupHandler sgHandler) {
+ SubstitutionGroupHandler sgHandler);
+
+ protected boolean overlapUPA(XSElementDecl element1,
+ XSElementDecl element2,
+ SubstitutionGroupHandler sgHandler, short schemaVersion) {
// if the two element have the same name and namespace,
if (element1.fName == element2.fName &&
element1.fTargetNamespace == element2.fTargetNamespace) {
@@ -1431,7 +1453,7 @@
// or if there is an element decl in element1's substitution group,
// who has the same name/namespace with element2
- XSElementDecl[] subGroup = sgHandler.getSubstitutionGroup(element1);
+ XSElementDecl[] subGroup = sgHandler.getSubstitutionGroup(element1, schemaVersion);
for (int i = subGroup.length-1; i >= 0; i--) {
if (subGroup[i].fName == element2.fName &&
subGroup[i].fTargetNamespace == element2.fTargetNamespace) {
@@ -1441,7 +1463,7 @@
// or if there is an element decl in element2's substitution group,
// who has the same name/namespace with element1
- subGroup = sgHandler.getSubstitutionGroup(element2);
+ subGroup = sgHandler.getSubstitutionGroup(element2, schemaVersion);
for (int i = subGroup.length-1; i >= 0; i--) {
if (subGroup[i].fName == element1.fName &&
subGroup[i].fTargetNamespace == element1.fTargetNamespace) {
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSModelImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSModelImpl.java?rev=735851&r1=735850&r2=735851&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSModelImpl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSModelImpl.java Mon Jan 19 14:26:51 2009
@@ -20,6 +20,7 @@
import java.util.AbstractList;
import java.util.Vector;
+import org.apache.xerces.impl.Constants;
import org.apache.xerces.impl.xs.util.StringListImpl;
import org.apache.xerces.impl.xs.util.XSNamedMap4Types;
import org.apache.xerces.impl.xs.util.XSNamedMapImpl;
@@ -104,6 +105,10 @@
* @param grammars the array of schema grammars
*/
public XSModelImpl(SchemaGrammar[] grammars) {
+ this(grammars, Constants.SCHEMA_VERSION_1_0);
+ }
+
+ public XSModelImpl(SchemaGrammar[] grammars, short s4sVersion) {
// copy namespaces/grammars from the array to our arrays
int len = grammars.length;
final int initialSize = Math.max(len+1, 5);
@@ -122,7 +127,7 @@
// If a schema for the schema namespace isn't included, include it here.
if (!hasS4S) {
namespaces[len] = SchemaSymbols.URI_SCHEMAFORSCHEMA;
- grammarList[len++] = SchemaGrammar.SG_SchemaNS;
+ grammarList[len++] = SchemaGrammar.getS4SGrammar(s4sVersion);
}
SchemaGrammar sg1, sg2;
@@ -181,10 +186,10 @@
fNamespacesList = new StringListImpl(fNamespaces, fGrammarCount);
// build substitution groups
- fSubGroupMap = buildSubGroups();
+ fSubGroupMap = buildSubGroups(s4sVersion);
}
- private SymbolHash buildSubGroups() {
+ private SymbolHash buildSubGroups(short s4sVersion) {
SubstitutionGroupHandler sgHandler = new SubstitutionGroupHandler(null);
for (int i = 0 ; i < fGrammarCount; i++) {
sgHandler.addSubstitutionGroup(fGrammarList[i].getSubstitutionGroups());
@@ -197,7 +202,7 @@
XSElementDeclaration[] subGroup;
for (int i = 0; i < len; i++) {
head = (XSElementDecl)elements.item(i);
- subGroup = sgHandler.getSubstitutionGroup(head);
+ subGroup = sgHandler.getSubstitutionGroup(head, s4sVersion);
subGroupMap.put(head, subGroup.length > 0 ?
new XSObjectListImpl(subGroup, subGroup.length) : XSObjectListImpl.EMPTY_LIST);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org