You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by sa...@apache.org on 2002/05/16 20:25:57 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/util SymbolHash.java
sandygao 02/05/16 11:25:56
Modified: java/src/org/apache/xerces/impl/dv SchemaDVFactory.java
XSSimpleType.java
java/src/org/apache/xerces/impl/dv/dtd DTDDVFactoryImpl.java
java/src/org/apache/xerces/impl/dv/xs
SchemaDVFactoryImpl.java XSSimpleTypeDecl.java
java/src/org/apache/xerces/impl/xs AttributePSVImpl.java
ElementPSVImpl.java SchemaGrammar.java
SchemaSymbols.java SubstitutionGroupHandler.java
XMLSchemaValidator.java XSAttributeDecl.java
XSAttributeGroupDecl.java XSComplexTypeDecl.java
XSConstraints.java XSDeclarationPool.java
XSElementDecl.java XSGrammarBucket.java
XSGroupDecl.java XSNotationDecl.java
XSParticleDecl.java XSTypeDecl.java
XSWildcardDecl.java
java/src/org/apache/xerces/impl/xs/identity
IdentityConstraint.java KeyRef.java
UniqueOrKey.java XPathMatcher.java
java/src/org/apache/xerces/impl/xs/models CMBuilder.java
XSCMBinOp.java XSDFACM.java
java/src/org/apache/xerces/impl/xs/psvi
XSTypeDefinition.java
java/src/org/apache/xerces/impl/xs/traversers
XSAttributeChecker.java
XSDAbstractParticleTraverser.java
XSDAbstractTraverser.java
XSDAttributeTraverser.java
XSDComplexTypeTraverser.java
XSDElementTraverser.java XSDGroupTraverser.java
XSDHandler.java XSDKeyrefTraverser.java
XSDSimpleTypeTraverser.java
XSDUniqueOrKeyTraverser.java
java/src/org/apache/xerces/util SymbolHash.java
Added: java/src/org/apache/xerces/impl/xs XSAttributeUseImpl.java
XSModelGroupImpl.java XSModelImpl.java
java/src/org/apache/xerces/impl/xs/util EnumerationImpl.java
XSNamedMap4Types.java XSNamedMapImpl.java
XSObjectListImpl.java
Removed: java/src/org/apache/xerces/impl/dv XSAtomicSimpleType.java
XSListSimpleType.java XSUnionSimpleType.java
java/src/org/apache/xerces/impl/xs XSAttributeUse.java
XSModelGroup.java
Log:
Implementing Schema Component Model API:
- All interfaces in impl.xs.psvi package except XSAnnotation are implemented
- Using a SymbolHash to store built-in simple types (Hashtable was used)
- Renamed XSAttributeUse to XSAttributeUseImpl
- Renamed XSModelGropu to XSModelGroupImpl
- Removed interfaces XSAtomicSimpleType, XSListSimpleType,
XSUnionSimpleType, because their methods are included in
XSSimpleTypeDefinition interface
- It's still an open issue (please refer to the message
"[Schema CM API] How it works with grammar loading")
how XSModel and grammar loading are related. I'll send a separate note
to the mailing lists to describe how to get XSModel from preparsed grammars.
Revision Changes Path
1.7 +9 -9 xml-xerces/java/src/org/apache/xerces/impl/dv/SchemaDVFactory.java
Index: SchemaDVFactory.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/SchemaDVFactory.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SchemaDVFactory.java 19 Mar 2002 15:49:11 -0000 1.6
+++ SchemaDVFactory.java 16 May 2002 18:25:53 -0000 1.7
@@ -57,7 +57,7 @@
package org.apache.xerces.impl.dv;
-import java.util.Hashtable;
+import org.apache.xerces.util.SymbolHash;
/**
* Defines a factory API that enables applications to <p>
@@ -73,7 +73,7 @@
*
* @author Sandy Gao, IBM
*
- * @version $Id: SchemaDVFactory.java,v 1.6 2002/03/19 15:49:11 sandygao Exp $
+ * @version $Id: SchemaDVFactory.java,v 1.7 2002/05/16 18:25:53 sandygao Exp $
*/
public abstract class SchemaDVFactory {
@@ -153,12 +153,12 @@
public abstract XSSimpleType getBuiltInType(String name);
/**
- * get all built-in simple types, which are stored in a hashtable keyed by
+ * get all built-in simple types, which are stored in a SymbolHash keyed by
* the name
*
- * @return a hashtable which contains all built-in simple types
+ * @return a SymbolHash which contains all built-in simple types
*/
- public abstract Hashtable getBuiltInTypes();
+ public abstract SymbolHash getBuiltInTypes();
/**
* Create a new simple type which is derived by restriction from another
@@ -183,8 +183,8 @@
* @param itemType item type of the list type
* @return the newly created simple type
*/
- public abstract XSListSimpleType createTypeList(String name, String targetNamespace,
- short finalSet, XSSimpleType itemType);
+ public abstract XSSimpleType createTypeList(String name, String targetNamespace,
+ short finalSet, XSSimpleType itemType);
/**
* Create a new simple type which is derived by union from a list of other
@@ -196,7 +196,7 @@
* @param base member types of the union type
* @return the newly created simple type
*/
- public abstract XSUnionSimpleType createTypeUnion(String name, String targetNamespace,
- short finalSet, XSSimpleType[] memberTypes);
+ public abstract XSSimpleType createTypeUnion(String name, String targetNamespace,
+ short finalSet, XSSimpleType[] memberTypes);
}
1.8 +56 -117 xml-xerces/java/src/org/apache/xerces/impl/dv/XSSimpleType.java
Index: XSSimpleType.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/XSSimpleType.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XSSimpleType.java 29 Jan 2002 01:15:11 -0000 1.7
+++ XSSimpleType.java 16 May 2002 18:25:53 -0000 1.8
@@ -57,6 +57,7 @@
package org.apache.xerces.impl.dv;
+import org.apache.xerces.impl.xs.psvi.XSSimpleTypeDefinition;
import org.apache.xerces.impl.validation.ValidationContext;
import org.apache.xerces.impl.xs.XSTypeDecl;
@@ -69,55 +70,9 @@
*
* @author Sandy Gao, IBM
*
- * @version $Id: XSSimpleType.java,v 1.7 2002/01/29 01:15:11 lehors Exp $
+ * @version $Id: XSSimpleType.java,v 1.8 2002/05/16 18:25:53 sandygao Exp $
*/
-public interface XSSimpleType extends XSTypeDecl {
-
- /**
- * Constant defined for the constraining facets as defined in schema.
- * see <a href='http://www.w3.org/TR/xmlschema-2/#rf-facets'> XML Schema
- * Part 2: Datatypes </a>
- * The bit combination of the following constants are used to tell
- * which facets are fixed, and which ones are present
- */
- /** the length facet */
- public static final short FACET_LENGTH = 1<<0;
- /** the minLength facet */
- public static final short FACET_MINLENGTH = 1<<1;
- /** the maxLength facet */
- public static final short FACET_MAXLENGTH = 1<<2;
- /** the pattern facet */
- public static final short FACET_PATTERN = 1<<3;
- /** the enumeration facet */
- public static final short FACET_ENUMERATION = 1<<4;
- /** the whiteSpace facet */
- public static final short FACET_WHITESPACE = 1<<5;
- /** the maxInclusive facet */
- public static final short FACET_MAXINCLUSIVE = 1<<6;
- /** the maxExclusive facet */
- public static final short FACET_MAXEXCLUSIVE = 1<<7;
- /** the minExclusive facet */
- public static final short FACET_MINEXCLUSIVE = 1<<8;
- /** the minInclusive facet */
- public static final short FACET_MININCLUSIVE = 1<<9;
- /** the totalDigits facet */
- public static final short FACET_TOTALDIGITS = 1<<10;
- /** the fractionDigits facet */
- public static final short FACET_FRACTIONDIGITS = 1<<11;
-
- /**
- * constants defined for the 'variety' property of Simple Type schema component.
- * see <a href='http://www.w3.org/TR/xmlschema-2/#defn-variety'> XML Schema
- * Part 2: Datatypes </a>
- */
- /** the absent variety, for anySimpleType */
- public static final short VARIETY_ABSENT = 0;
- /** the atomic variety */
- public static final short VARIETY_ATOMIC = 1;
- /** the list variety */
- public static final short VARIETY_LIST = 2;
- /** the union variety */
- public static final short VARIETY_UNION = 3;
+public interface XSSimpleType extends XSTypeDecl, XSSimpleTypeDefinition {
/**
* constants defined for the values of 'whitespace' facet.
@@ -132,26 +87,58 @@
public static final short WS_COLLAPSE = 2;
/**
- * constants defined for the 'ordered' fundamental facet.
- * see <a href='http://www.w3.org/TR/xmlschema-2/#rf-fund-facets'> XML
- * Schema Part 2: Datatypes </a>
- */
- /** not ordered */
- public static final short ORDERED_FALSE = 1;
- /** partically ordered */
- public static final short ORDERED_PARTIAL = 2;
- /** totally ordered */
- public static final short ORDERED_TOTAL = 3;
-
- /**
- * constants defined for the 'cardinality' fundamental facet.
- * see <a href='http://www.w3.org/TR/xmlschema-2/#rf-fund-facets'> XML
- * Schema Part 2: Datatypes </a>
- */
- /** finite cardinality */
- public static final short CARDINALITY_FINITE = 1;
- /** countably infinite cardinality */
- public static final short CARDINALITY_COUNTABLY_INFINITE = 2;
+ * Constant defined for the primitive built-in simple tpyes.
+ * see <a href='http://www.w3.org/TR/xmlschema-2/#built-in-primitive-datatypes'>
+ * XML Schema Part 2: Datatypes </a>
+ */
+ /** "string" type */
+ public static final short PRIMITIVE_STRING = 1;
+ /** "boolean" type */
+ public static final short PRIMITIVE_BOOLEAN = 2;
+ /** "decimal" type */
+ public static final short PRIMITIVE_DECIMAL = 3;
+ /** "float" type */
+ public static final short PRIMITIVE_FLOAT = 4;
+ /** "double" type */
+ public static final short PRIMITIVE_DOUBLE = 5;
+ /** "duration" type */
+ public static final short PRIMITIVE_DURATION = 6;
+ /** "dataTime" type */
+ public static final short PRIMITIVE_DATETIME = 7;
+ /** "time" type */
+ public static final short PRIMITIVE_TIME = 8;
+ /** "date" type */
+ public static final short PRIMITIVE_DATE = 9;
+ /** "gYearMonth" type */
+ public static final short PRIMITIVE_GYEARMONTH = 10;
+ /** "gYear" type */
+ public static final short PRIMITIVE_GYEAR = 11;
+ /** "gMonthDay" type */
+ public static final short PRIMITIVE_GMONTHDAY = 12;
+ /** "gDay" type */
+ public static final short PRIMITIVE_GDAY = 13;
+ /** "gMonth" type */
+ public static final short PRIMITIVE_GMONTH = 14;
+ /** "hexBinary" type */
+ public static final short PRIMITIVE_HEXBINARY = 15;
+ /** "base64Binary" type */
+ public static final short PRIMITIVE_BASE64BINARY = 16;
+ /** "anyURI" type */
+ public static final short PRIMITIVE_ANYURI = 17;
+ /** "QName" type */
+ public static final short PRIMITIVE_QNAME = 18;
+ /** "NOTATION" type */
+ public static final short PRIMITIVE_NOTATION = 19;
+
+ /**
+ * return an ID representing the built-in primitive base type.
+ * REVISIT: This method is (currently) for internal use only.
+ * the constants returned from this method are not finalized yet.
+ * the names and values might change in the further.
+ *
+ * @return an ID representing the built-in primitive base type
+ */
+ public short getPrimitiveKind();
/**
* validate a given string against this simple type.
@@ -193,13 +180,6 @@
throws InvalidDatatypeFacetException;
/**
- * Get the variety of the simple type: atomic, list or union.
- *
- * @return a constant corresponding to the variety, as defined above.
- */
- public short getVariety();
-
- /**
* Check whether two actual values are equal.
*
* @param value1 the first value
@@ -226,14 +206,6 @@
//public short compare(Object value1, Object value2);
/**
- * bit combination of the constants defined in this simple type.
- *
- * @return the bit combination of the constants corresponding to the
- * constraining facets, as defined above.
- */
- public short getDefinedFacets();
-
- /**
* Check whether this type is or is derived from ID.
* REVISIT: this method makes ID special, which is not a good design.
* but since ID is not a primitive, there doesn't seem to be a
@@ -243,39 +215,6 @@
*/
public boolean isIDType();
- // REVISIT: it's not decided yet how to return the facets,
- // as String's or as values (Object's).
- //public XSFacet[] getFacets();
-
- /**
- * Return the value of the "ordered" fundamental facet.
- *
- * @return a constant corresponding to the "ordered" facet.
- */
- public short getOrderedFacet();
-
- /**
- * Return the value of the "bounded" fundamental facet.
- *
- * @return whether the this type is bounded.
- */
- public boolean isBounded();
-
- /**
- * Return the value of the "numeric" fundamental facet.
- *
- * @return whether the this type is numeric.
- */
- public boolean isNumeric();
-
- /**
- * Return the value of the "cardinality" fundamental facet.
- *
- * @return a constant corresponding to the "cardinality" facet.
- */
- public short getCardinalityFacet();
-
-
/**
* Return the whitespace corresponding to this datatype.
*
@@ -283,5 +222,5 @@
* @exception DatatypeException
* union datatypes don't have whitespace facet associated with them
*/
- public short getWhitespace () throws DatatypeException;
+ public short getWhitespace() throws DatatypeException;
}
1.3 +15 -29 xml-xerces/java/src/org/apache/xerces/impl/dv/dtd/DTDDVFactoryImpl.java
Index: DTDDVFactoryImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/dtd/DTDDVFactoryImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DTDDVFactoryImpl.java 19 Mar 2002 15:49:11 -0000 1.2
+++ DTDDVFactoryImpl.java 16 May 2002 18:25:53 -0000 1.3
@@ -66,11 +66,14 @@
*
* @author Sandy Gao, IBM
*
- * @version $Id: DTDDVFactoryImpl.java,v 1.2 2002/03/19 15:49:11 sandygao Exp $
+ * @version $Id: DTDDVFactoryImpl.java,v 1.3 2002/05/16 18:25:53 sandygao Exp $
*/
public class DTDDVFactoryImpl extends DTDDVFactory {
- static Hashtable fBuiltInTypes = null;
+ static Hashtable fBuiltInTypes = new Hashtable();
+ static {
+ createBuiltInTypes();
+ }
/**
* return a dtd type of the given name
@@ -79,7 +82,6 @@
* @return the datatype validator of the given name
*/
public DatatypeValidator getBuiltInDV(String name) {
- prepareBuiltInTypes();
return (DatatypeValidator)fBuiltInTypes.get(name);
}
@@ -89,43 +91,27 @@
* @return a hashtable which contains all datatypes
*/
public Hashtable getBuiltInTypes() {
- prepareBuiltInTypes();
return (Hashtable)fBuiltInTypes.clone();
}
- // make sure the built-in types are created
- // the types are supposed to be reused for all factory objects,
- // so we synchorinize on the class object.
- static void prepareBuiltInTypes() {
- if (fBuiltInTypes == null) {
- createBuiltInTypes();
- }
- }
-
// create all built-in types
- // we are assumeing that fBuiltInTypes == null
- static synchronized void createBuiltInTypes() {
-
- if (fBuiltInTypes != null)
- return;
+ static void createBuiltInTypes() {
- Hashtable types = new Hashtable();
DatatypeValidator dvTemp;
- types.put("string", new StringDatatypeValidator());
- types.put("ID", new IDDatatypeValidator());
+ fBuiltInTypes.put("string", new StringDatatypeValidator());
+ fBuiltInTypes.put("ID", new IDDatatypeValidator());
dvTemp = new IDREFDatatypeValidator();
- types.put("IDREF", dvTemp);
- types.put("IDREFS", new ListDatatypeValidator(dvTemp));
+ fBuiltInTypes.put("IDREF", dvTemp);
+ fBuiltInTypes.put("IDREFS", new ListDatatypeValidator(dvTemp));
dvTemp = new ENTITYDatatypeValidator();
- types.put("ENTITY", new ENTITYDatatypeValidator());
- types.put("ENTITIES", new ListDatatypeValidator(dvTemp));
- types.put("NOTATION", new NOTATIONDatatypeValidator());
+ fBuiltInTypes.put("ENTITY", new ENTITYDatatypeValidator());
+ fBuiltInTypes.put("ENTITIES", new ListDatatypeValidator(dvTemp));
+ fBuiltInTypes.put("NOTATION", new NOTATIONDatatypeValidator());
dvTemp = new NMTOKENDatatypeValidator();
- types.put("NMTOKEN", dvTemp);
- types.put("NMTOKENS", new ListDatatypeValidator(dvTemp));
+ fBuiltInTypes.put("NMTOKEN", dvTemp);
+ fBuiltInTypes.put("NMTOKENS", new ListDatatypeValidator(dvTemp));
- fBuiltInTypes = types;
}//createBuiltInTypes()
}//SchemaDVFactory
1.6 +63 -85 xml-xerces/java/src/org/apache/xerces/impl/dv/xs/SchemaDVFactoryImpl.java
Index: SchemaDVFactoryImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/SchemaDVFactoryImpl.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- SchemaDVFactoryImpl.java 19 Apr 2002 17:20:23 -0000 1.5
+++ SchemaDVFactoryImpl.java 16 May 2002 18:25:53 -0000 1.6
@@ -59,13 +59,9 @@
import org.apache.xerces.impl.dv.SchemaDVFactory;
import org.apache.xerces.impl.dv.XSSimpleType;
-import org.apache.xerces.impl.dv.XSAtomicSimpleType;
-import org.apache.xerces.impl.dv.XSListSimpleType;
-import org.apache.xerces.impl.dv.XSUnionSimpleType;
import org.apache.xerces.impl.dv.XSFacets;
-
import org.apache.xerces.impl.xs.XSDeclarationPool;
-import java.util.Hashtable;
+import org.apache.xerces.util.SymbolHash;
/**
* the factory to create/return built-in schema DVs and create user-defined DVs
@@ -73,13 +69,16 @@
* @author Neeraj Bajaj, Sun Microsystems, inc.
* @author Sandy Gao, IBM
*
- * @version $Id: SchemaDVFactoryImpl.java,v 1.5 2002/04/19 17:20:23 sandygao Exp $
+ * @version $Id: SchemaDVFactoryImpl.java,v 1.6 2002/05/16 18:25:53 sandygao Exp $
*/
public class SchemaDVFactoryImpl extends SchemaDVFactory {
static final String URI_SCHEMAFORSCHEMA = "http://www.w3.org/2001/XMLSchema";
- static Hashtable fBuiltInTypes = null;
+ static SymbolHash fBuiltInTypes = new SymbolHash();
+ static {
+ createBuiltInTypes();
+ }
protected XSDeclarationPool fDeclPool = null;
@@ -95,7 +94,6 @@
* @return the datatype validator of the given name
*/
public XSSimpleType getBuiltInType(String name) {
- prepareBuiltInTypes();
return (XSSimpleType)fBuiltInTypes.get(name);
}
@@ -105,9 +103,8 @@
*
* @return a hashtable which contains all built-in simple types
*/
- public Hashtable getBuiltInTypes() {
- prepareBuiltInTypes();
- return (Hashtable)fBuiltInTypes.clone();
+ public SymbolHash getBuiltInTypes() {
+ return (SymbolHash)fBuiltInTypes.makeClone();
}
/**
@@ -140,10 +137,8 @@
* @param itemType item type of the list type
* @return the newly created simple type
*/
- public XSListSimpleType createTypeList(String name, String targetNamespace,
- short finalSet, XSSimpleType itemType) {
- prepareBuiltInTypes();
-
+ public XSSimpleType createTypeList(String name, String targetNamespace,
+ short finalSet, XSSimpleType itemType) {
if (fDeclPool != null) {
XSSimpleTypeDecl st= fDeclPool.getSimpleTypeDecl();
return st.setListValues(name, targetNamespace, finalSet, (XSSimpleTypeDecl)itemType);
@@ -161,9 +156,8 @@
* @param base member types of the union type
* @return the newly created simple type
*/
- public XSUnionSimpleType createTypeUnion(String name, String targetNamespace,
- short finalSet, XSSimpleType[] memberTypes) {
- prepareBuiltInTypes();
+ public XSSimpleType createTypeUnion(String name, String targetNamespace,
+ short finalSet, XSSimpleType[] memberTypes) {
int typeNum = memberTypes.length;
XSSimpleTypeDecl[] mtypes = new XSSimpleTypeDecl[typeNum];
System.arraycopy(memberTypes, 0, mtypes, 0, typeNum);
@@ -175,21 +169,8 @@
return new XSSimpleTypeDecl(name, targetNamespace, finalSet, mtypes);
}
- // make sure the built-in types are created
- // the types are supposed to be reused for all factory objects,
- // so we synchorinize on the class object.
- static void prepareBuiltInTypes() {
- if (fBuiltInTypes == null) {
- createBuiltInTypes();
- }
- }
-
// create all built-in types
- // we are assumeing that fBuiltInTypes == null
- static synchronized void createBuiltInTypes() {
- if (fBuiltInTypes != null)
- return;
-
+ static void createBuiltInTypes() {
// all schema simple type names
final String ANYSIMPLETYPE = "anySimpleType";
final String ANYURI = "anyURI";
@@ -239,166 +220,163 @@
final XSFacets facets = new XSFacets();
- Hashtable types = new Hashtable();
//REVISIT: passing "anyType" here.
XSSimpleTypeDecl anySimpleType = XSSimpleTypeDecl.fAnySimpleType;
- types.put(ANYSIMPLETYPE, anySimpleType);
- XSSimpleTypeDecl stringDV = new XSSimpleTypeDecl(anySimpleType, STRING, XSSimpleTypeDecl.DV_STRING, XSSimpleType.ORDERED_FALSE, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false );
- types.put(STRING, stringDV);
- types.put(BOOLEAN, new XSSimpleTypeDecl(anySimpleType, STRING, XSSimpleTypeDecl.DV_BOOLEAN, XSSimpleType.ORDERED_FALSE, false, XSSimpleType.CARDINALITY_FINITE, false));
- XSSimpleTypeDecl decimalDV = new XSSimpleTypeDecl(anySimpleType, DECIMAL, XSSimpleTypeDecl.DV_DECIMAL, XSSimpleType.ORDERED_TOTAL, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, true);
- types.put(DECIMAL, decimalDV);
-
- types.put(ANYURI, new XSSimpleTypeDecl(anySimpleType, ANYURI, XSSimpleTypeDecl.DV_ANYURI, XSSimpleType.ORDERED_FALSE, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false));
- types.put(BASE64BINARY, new XSSimpleTypeDecl(anySimpleType, BASE64BINARY, XSSimpleTypeDecl.DV_BASE64BINARY, XSSimpleType.ORDERED_FALSE, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false));
- types.put(DURATION, new XSSimpleTypeDecl(anySimpleType, DURATION, XSSimpleTypeDecl.DV_DURATION, XSSimpleType.ORDERED_PARTIAL, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false));
- types.put(DATETIME, new XSSimpleTypeDecl(anySimpleType, DATETIME, XSSimpleTypeDecl.DV_DATETIME, XSSimpleType.ORDERED_PARTIAL, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false));
- types.put(TIME, new XSSimpleTypeDecl(anySimpleType, TIME, XSSimpleTypeDecl.DV_TIME, XSSimpleType.ORDERED_PARTIAL, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false));
- types.put(DATE, new XSSimpleTypeDecl(anySimpleType, DATE, XSSimpleTypeDecl.DV_DATE, XSSimpleType.ORDERED_PARTIAL, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false));
- types.put(YEARMONTH, new XSSimpleTypeDecl(anySimpleType, YEARMONTH, XSSimpleTypeDecl.DV_GYEARMONTH, XSSimpleType.ORDERED_PARTIAL, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false));
- types.put(YEAR, new XSSimpleTypeDecl(anySimpleType, YEAR, XSSimpleTypeDecl.DV_GYEAR, XSSimpleType.ORDERED_PARTIAL, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false));
- types.put(MONTHDAY, new XSSimpleTypeDecl(anySimpleType, MONTHDAY, XSSimpleTypeDecl.DV_GMONTHDAY, XSSimpleType.ORDERED_PARTIAL, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false));
- types.put(DAY, new XSSimpleTypeDecl(anySimpleType, DAY, XSSimpleTypeDecl.DV_GDAY, XSSimpleType.ORDERED_PARTIAL, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false));
- types.put(MONTH, new XSSimpleTypeDecl(anySimpleType, MONTH, XSSimpleTypeDecl.DV_GMONTH, XSSimpleType.ORDERED_PARTIAL, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false));
+ fBuiltInTypes.put(ANYSIMPLETYPE, anySimpleType);
+ XSSimpleTypeDecl stringDV = new XSSimpleTypeDecl(anySimpleType, STRING, XSSimpleTypeDecl.DV_STRING, XSSimpleType.ORDERED_FALSE, false, false, false );
+ fBuiltInTypes.put(STRING, stringDV);
+ fBuiltInTypes.put(BOOLEAN, new XSSimpleTypeDecl(anySimpleType, STRING, XSSimpleTypeDecl.DV_BOOLEAN, XSSimpleType.ORDERED_FALSE, false, true, false));
+ XSSimpleTypeDecl decimalDV = new XSSimpleTypeDecl(anySimpleType, DECIMAL, XSSimpleTypeDecl.DV_DECIMAL, XSSimpleType.ORDERED_TOTAL, false, false, true);
+ fBuiltInTypes.put(DECIMAL, decimalDV);
+
+ fBuiltInTypes.put(ANYURI, new XSSimpleTypeDecl(anySimpleType, ANYURI, XSSimpleTypeDecl.DV_ANYURI, XSSimpleType.ORDERED_FALSE, false, false, false));
+ fBuiltInTypes.put(BASE64BINARY, new XSSimpleTypeDecl(anySimpleType, BASE64BINARY, XSSimpleTypeDecl.DV_BASE64BINARY, XSSimpleType.ORDERED_FALSE, false, false, false));
+ fBuiltInTypes.put(DURATION, new XSSimpleTypeDecl(anySimpleType, DURATION, XSSimpleTypeDecl.DV_DURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false));
+ fBuiltInTypes.put(DATETIME, new XSSimpleTypeDecl(anySimpleType, DATETIME, XSSimpleTypeDecl.DV_DATETIME, XSSimpleType.ORDERED_PARTIAL, false, false, false));
+ fBuiltInTypes.put(TIME, new XSSimpleTypeDecl(anySimpleType, TIME, XSSimpleTypeDecl.DV_TIME, XSSimpleType.ORDERED_PARTIAL, false, false, false));
+ fBuiltInTypes.put(DATE, new XSSimpleTypeDecl(anySimpleType, DATE, XSSimpleTypeDecl.DV_DATE, XSSimpleType.ORDERED_PARTIAL, false, false, false));
+ fBuiltInTypes.put(YEARMONTH, new XSSimpleTypeDecl(anySimpleType, YEARMONTH, XSSimpleTypeDecl.DV_GYEARMONTH, XSSimpleType.ORDERED_PARTIAL, false, false, false));
+ fBuiltInTypes.put(YEAR, new XSSimpleTypeDecl(anySimpleType, YEAR, XSSimpleTypeDecl.DV_GYEAR, XSSimpleType.ORDERED_PARTIAL, false, false, false));
+ fBuiltInTypes.put(MONTHDAY, new XSSimpleTypeDecl(anySimpleType, MONTHDAY, XSSimpleTypeDecl.DV_GMONTHDAY, XSSimpleType.ORDERED_PARTIAL, false, false, false));
+ fBuiltInTypes.put(DAY, new XSSimpleTypeDecl(anySimpleType, DAY, XSSimpleTypeDecl.DV_GDAY, XSSimpleType.ORDERED_PARTIAL, false, false, false));
+ fBuiltInTypes.put(MONTH, new XSSimpleTypeDecl(anySimpleType, MONTH, XSSimpleTypeDecl.DV_GMONTH, XSSimpleType.ORDERED_PARTIAL, false, false, false));
facets.fractionDigits = 0;
XSSimpleTypeDecl integerDV = new XSSimpleTypeDecl(decimalDV, INTEGER, URI_SCHEMAFORSCHEMA, (short)0);
integerDV.applyFacets1(facets , XSSimpleType.FACET_FRACTIONDIGITS, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_INTEGER);
- types.put(INTEGER, integerDV);
+ fBuiltInTypes.put(INTEGER, integerDV);
facets.maxInclusive = "0";
XSSimpleTypeDecl nonPositiveDV = new XSSimpleTypeDecl(integerDV, NONPOSITIVEINTEGER, URI_SCHEMAFORSCHEMA, (short)0);
nonPositiveDV.applyFacets1(facets , XSSimpleType.FACET_MAXINCLUSIVE, (short)0);
- types.put(NONPOSITIVEINTEGER, nonPositiveDV);
+ fBuiltInTypes.put(NONPOSITIVEINTEGER, nonPositiveDV);
facets.maxInclusive = "-1";
XSSimpleTypeDecl negativeDV = new XSSimpleTypeDecl(integerDV, NEGATIVEINTEGER, URI_SCHEMAFORSCHEMA, (short)0);
negativeDV.applyFacets1(facets , XSSimpleType.FACET_MAXINCLUSIVE, (short)0);
- types.put(NEGATIVEINTEGER, negativeDV);
+ fBuiltInTypes.put(NEGATIVEINTEGER, negativeDV);
facets.maxInclusive = "9223372036854775807";
facets.minInclusive = "-9223372036854775808";
XSSimpleTypeDecl longDV = new XSSimpleTypeDecl(integerDV, LONG, URI_SCHEMAFORSCHEMA, (short)0);
longDV.applyFacets1(facets , (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 );
- types.put(LONG, longDV);
+ fBuiltInTypes.put(LONG, longDV);
facets.maxInclusive = "2147483647";
facets.minInclusive = "-2147483648";
XSSimpleTypeDecl intDV = new XSSimpleTypeDecl(longDV, INT, URI_SCHEMAFORSCHEMA, (short)0);
intDV.applyFacets1(facets, (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 );
- types.put(INT, intDV);
+ fBuiltInTypes.put(INT, intDV);
facets.maxInclusive = "32767";
facets.minInclusive = "-32768";
XSSimpleTypeDecl shortDV = new XSSimpleTypeDecl(intDV, SHORT , URI_SCHEMAFORSCHEMA, (short)0);
shortDV.applyFacets1(facets, (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 );
- types.put(SHORT, shortDV);
+ fBuiltInTypes.put(SHORT, shortDV);
facets.maxInclusive = "127";
facets.minInclusive = "-128";
XSSimpleTypeDecl byteDV = new XSSimpleTypeDecl(shortDV, BYTE , URI_SCHEMAFORSCHEMA, (short)0);
byteDV.applyFacets1(facets, (short)(XSSimpleType.FACET_MAXINCLUSIVE | XSSimpleType.FACET_MININCLUSIVE), (short)0 );
- types.put(BYTE, byteDV);
+ fBuiltInTypes.put(BYTE, byteDV);
facets.minInclusive = "0" ;
XSSimpleTypeDecl nonNegativeDV = new XSSimpleTypeDecl(integerDV, NONNEGATIVEINTEGER , URI_SCHEMAFORSCHEMA, (short)0);
nonNegativeDV.applyFacets1(facets, XSSimpleType.FACET_MININCLUSIVE, (short)0 );
- types.put(NONNEGATIVEINTEGER, nonNegativeDV);
+ fBuiltInTypes.put(NONNEGATIVEINTEGER, nonNegativeDV);
facets.maxInclusive = "18446744073709551615" ;
XSSimpleTypeDecl unsignedLongDV = new XSSimpleTypeDecl(nonNegativeDV, UNSIGNEDLONG , URI_SCHEMAFORSCHEMA, (short)0);
unsignedLongDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 );
- types.put(UNSIGNEDLONG, unsignedLongDV);
+ fBuiltInTypes.put(UNSIGNEDLONG, unsignedLongDV);
facets.maxInclusive = "4294967295" ;
XSSimpleTypeDecl unsignedIntDV = new XSSimpleTypeDecl(unsignedLongDV, UNSIGNEDINT , URI_SCHEMAFORSCHEMA, (short)0);
unsignedIntDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 );
- types.put(UNSIGNEDINT, unsignedIntDV);
+ fBuiltInTypes.put(UNSIGNEDINT, unsignedIntDV);
facets.maxInclusive = "65535" ;
XSSimpleTypeDecl unsignedShortDV = new XSSimpleTypeDecl(unsignedIntDV, UNSIGNEDSHORT , URI_SCHEMAFORSCHEMA, (short)0);
unsignedShortDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 );
- types.put(UNSIGNEDSHORT, unsignedShortDV);
+ fBuiltInTypes.put(UNSIGNEDSHORT, unsignedShortDV);
facets.maxInclusive = "255" ;
XSSimpleTypeDecl unsignedByteDV = new XSSimpleTypeDecl(unsignedShortDV, UNSIGNEDBYTE , URI_SCHEMAFORSCHEMA, (short)0);
unsignedByteDV.applyFacets1(facets, XSSimpleType.FACET_MAXINCLUSIVE, (short)0 );
- types.put(UNSIGNEDBYTE, unsignedByteDV);
+ fBuiltInTypes.put(UNSIGNEDBYTE, unsignedByteDV);
facets.minInclusive = "1" ;
XSSimpleTypeDecl positiveIntegerDV = new XSSimpleTypeDecl(nonNegativeDV, POSITIVEINTEGER , URI_SCHEMAFORSCHEMA, (short)0);
positiveIntegerDV.applyFacets1(facets, XSSimpleType.FACET_MININCLUSIVE, (short)0 );
- types.put(POSITIVEINTEGER, positiveIntegerDV);
+ fBuiltInTypes.put(POSITIVEINTEGER, positiveIntegerDV);
- types.put(FLOAT, new XSSimpleTypeDecl(anySimpleType, FLOAT, XSSimpleTypeDecl.DV_FLOAT, XSSimpleType.ORDERED_TOTAL, true, XSSimpleType.CARDINALITY_FINITE, true));
- types.put(DOUBLE, new XSSimpleTypeDecl(anySimpleType, DOUBLE, XSSimpleTypeDecl.DV_DOUBLE, XSSimpleType.ORDERED_TOTAL, true, XSSimpleType.CARDINALITY_FINITE, true));
- types.put(HEXBINARY, new XSSimpleTypeDecl(anySimpleType, HEXBINARY, XSSimpleTypeDecl.DV_HEXBINARY, XSSimpleType.ORDERED_FALSE, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false));
- types.put(NOTATION, new XSSimpleTypeDecl(anySimpleType, NOTATION, XSSimpleTypeDecl.DV_NOTATION, XSSimpleType.ORDERED_FALSE, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false));
+ fBuiltInTypes.put(FLOAT, new XSSimpleTypeDecl(anySimpleType, FLOAT, XSSimpleTypeDecl.DV_FLOAT, XSSimpleType.ORDERED_TOTAL, true, true, true));
+ fBuiltInTypes.put(DOUBLE, new XSSimpleTypeDecl(anySimpleType, DOUBLE, XSSimpleTypeDecl.DV_DOUBLE, XSSimpleType.ORDERED_TOTAL, true, true, true));
+ fBuiltInTypes.put(HEXBINARY, new XSSimpleTypeDecl(anySimpleType, HEXBINARY, XSSimpleTypeDecl.DV_HEXBINARY, XSSimpleType.ORDERED_FALSE, false, false, false));
+ fBuiltInTypes.put(NOTATION, new XSSimpleTypeDecl(anySimpleType, NOTATION, XSSimpleTypeDecl.DV_NOTATION, XSSimpleType.ORDERED_FALSE, false, false, false));
facets.whiteSpace = XSSimpleType.WS_REPLACE;
XSSimpleTypeDecl normalizedDV = new XSSimpleTypeDecl(stringDV, NORMALIZEDSTRING , URI_SCHEMAFORSCHEMA, (short)0);
normalizedDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0 );
- types.put(NORMALIZEDSTRING, normalizedDV);
+ fBuiltInTypes.put(NORMALIZEDSTRING, normalizedDV);
facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
XSSimpleTypeDecl tokenDV = new XSSimpleTypeDecl(normalizedDV, TOKEN , URI_SCHEMAFORSCHEMA, (short)0);
tokenDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0 );
- types.put(TOKEN, tokenDV);
+ fBuiltInTypes.put(TOKEN, tokenDV);
facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
facets.pattern = "([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]+)(-[a-zA-Z]+)*";
XSSimpleTypeDecl languageDV = new XSSimpleTypeDecl(tokenDV, LANGUAGE , URI_SCHEMAFORSCHEMA, (short)0);
languageDV.applyFacets1(facets, (short)(XSSimpleType.FACET_WHITESPACE | XSSimpleType.FACET_PATTERN) ,(short)0);
- types.put(LANGUAGE, languageDV);
+ fBuiltInTypes.put(LANGUAGE, languageDV);
facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
XSSimpleTypeDecl nameDV = new XSSimpleTypeDecl(tokenDV, NAME , URI_SCHEMAFORSCHEMA, (short)0);
nameDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NAME);
- types.put(NAME, nameDV);
+ fBuiltInTypes.put(NAME, nameDV);
facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
XSSimpleTypeDecl ncnameDV = new XSSimpleTypeDecl(nameDV, NCNAME , URI_SCHEMAFORSCHEMA, (short)0) ;
ncnameDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NCNAME);
- types.put(NCNAME, ncnameDV);
+ fBuiltInTypes.put(NCNAME, ncnameDV);
- types.put(QNAME, new XSSimpleTypeDecl(anySimpleType, QNAME, XSSimpleTypeDecl.DV_QNAME, XSSimpleType.ORDERED_FALSE, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false));
+ fBuiltInTypes.put(QNAME, new XSSimpleTypeDecl(anySimpleType, QNAME, XSSimpleTypeDecl.DV_QNAME, XSSimpleType.ORDERED_FALSE, false, false, false));
- types.put(ID, new XSSimpleTypeDecl(ncnameDV, ID, XSSimpleTypeDecl.DV_ID, XSSimpleType.ORDERED_FALSE, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false ));
- XSSimpleTypeDecl idrefDV = new XSSimpleTypeDecl(ncnameDV, IDREF , XSSimpleTypeDecl.DV_IDREF, XSSimpleType.ORDERED_FALSE, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false);
- types.put(IDREF, idrefDV);
+ fBuiltInTypes.put(ID, new XSSimpleTypeDecl(ncnameDV, ID, XSSimpleTypeDecl.DV_ID, XSSimpleType.ORDERED_FALSE, false, false, false ));
+ XSSimpleTypeDecl idrefDV = new XSSimpleTypeDecl(ncnameDV, IDREF , XSSimpleTypeDecl.DV_IDREF, XSSimpleType.ORDERED_FALSE, false, false, false);
+ fBuiltInTypes.put(IDREF, idrefDV);
facets.minLength = 1;
XSSimpleTypeDecl tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0, idrefDV);
XSSimpleTypeDecl idrefsDV = new XSSimpleTypeDecl(tempDV, IDREFS, URI_SCHEMAFORSCHEMA, (short)0);
idrefsDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0);
- types.put(IDREFS, idrefsDV);
+ fBuiltInTypes.put(IDREFS, idrefsDV);
- XSSimpleTypeDecl entityDV = new XSSimpleTypeDecl(ncnameDV, ENTITY , XSSimpleTypeDecl.DV_ENTITY, XSSimpleType.ORDERED_FALSE, false, XSSimpleType.CARDINALITY_COUNTABLY_INFINITE, false);
- types.put(ENTITY, entityDV);
+ XSSimpleTypeDecl entityDV = new XSSimpleTypeDecl(ncnameDV, ENTITY , XSSimpleTypeDecl.DV_ENTITY, XSSimpleType.ORDERED_FALSE, false, false, false);
+ fBuiltInTypes.put(ENTITY, entityDV);
facets.minLength = 1;
tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0, entityDV);
XSSimpleTypeDecl entitiesDV = new XSSimpleTypeDecl(tempDV, ENTITIES, URI_SCHEMAFORSCHEMA, (short)0);
entitiesDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0);
- types.put(ENTITIES, entitiesDV);
+ fBuiltInTypes.put(ENTITIES, entitiesDV);
facets.whiteSpace = XSSimpleType.WS_COLLAPSE;
XSSimpleTypeDecl nmtokenDV = new XSSimpleTypeDecl(tokenDV, NMTOKEN, URI_SCHEMAFORSCHEMA, (short)0);
nmtokenDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NMTOKEN);
- types.put(NMTOKEN, nmtokenDV);
+ fBuiltInTypes.put(NMTOKEN, nmtokenDV);
facets.minLength = 1;
tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0, nmtokenDV);
XSSimpleTypeDecl nmtokensDV = new XSSimpleTypeDecl(tempDV, NMTOKENS, URI_SCHEMAFORSCHEMA, (short)0);
nmtokensDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0);
- types.put(NMTOKENS, nmtokensDV);
-
- fBuiltInTypes = types;
+ fBuiltInTypes.put(NMTOKENS, nmtokensDV);
}//createBuiltInTypes()
public void setDeclPool (XSDeclarationPool declPool){
1.9 +121 -50 xml-xerces/java/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java
Index: XSSimpleTypeDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XSSimpleTypeDecl.java 19 Apr 2002 17:20:23 -0000 1.8
+++ XSSimpleTypeDecl.java 16 May 2002 18:25:53 -0000 1.9
@@ -58,9 +58,6 @@
package org.apache.xerces.impl.dv.xs;
import org.apache.xerces.impl.dv.XSSimpleType;
-import org.apache.xerces.impl.dv.XSAtomicSimpleType;
-import org.apache.xerces.impl.dv.XSListSimpleType;
-import org.apache.xerces.impl.dv.XSUnionSimpleType;
import org.apache.xerces.impl.dv.XSFacets;
import org.apache.xerces.impl.dv.DatatypeException;
import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
@@ -68,21 +65,25 @@
import org.apache.xerces.impl.dv.ValidatedInfo;
import org.apache.xerces.impl.validation.ValidationContext;
import org.apache.xerces.impl.xs.XSTypeDecl;
+import org.apache.xerces.impl.xs.psvi.*;
import org.apache.xerces.impl.xs.SchemaGrammar;
import org.apache.xerces.impl.xs.SchemaSymbols;
+import org.apache.xerces.impl.xs.util.EnumerationImpl;
+import org.apache.xerces.impl.xs.util.XSObjectListImpl;
import org.apache.xerces.util.XMLChar;
import org.apache.xerces.impl.xpath.regex.RegularExpression;
import org.apache.xerces.xni.NamespaceContext;
import java.util.Vector;
+import java.util.Enumeration;
import java.util.StringTokenizer;
/**
* @author Sandy Gao, IBM
* @author Neeraj Bajaj, Sun Microsystems, inc.
*
- * @version $Id: XSSimpleTypeDecl.java,v 1.8 2002/04/19 17:20:23 sandygao Exp $
+ * @version $Id: XSSimpleTypeDecl.java,v 1.9 2002/05/16 18:25:53 sandygao Exp $
*/
-public class XSSimpleTypeDecl implements XSAtomicSimpleType, XSListSimpleType, XSUnionSimpleType {
+public class XSSimpleTypeDecl implements XSSimpleType {
static final short DV_STRING = PRIMITIVE_STRING;
static final short DV_BOOLEAN = PRIMITIVE_BOOLEAN;
@@ -184,7 +185,7 @@
// for fundamental facets
private short fOrdered;
- private short fCardinality;
+ private boolean fFinite;
private boolean fBounded;
private boolean fNumeric;
@@ -194,7 +195,7 @@
//Create a new built-in primitive types (and id/idref/entity)
protected XSSimpleTypeDecl(XSSimpleTypeDecl base, String name, short validateDV,
short ordered, boolean bounded,
- short cardinality, boolean numeric) {
+ boolean finite, boolean numeric) {
fBase = base;
fTypeName = name;
fTargetNamespace = SchemaDVFactoryImpl.URI_SCHEMAFORSCHEMA;
@@ -208,6 +209,10 @@
fWhiteSpace = WS_COLLAPSE;
fFixedFacet = FACET_WHITESPACE;
}
+ this.fOrdered = ordered;
+ this.fBounded = bounded;
+ this.fFinite = finite;
+ this.fNumeric = numeric;
}
//Create a new simple type for restriction.
@@ -375,28 +380,35 @@
return this;
}
+ public short getType () {
+ return XSConstants.TYPE_DEFINITION;
+ }
- public short getXSType () {
- return XSTypeDecl.SIMPLE_TYPE;
+ public short getTypeCategory () {
+ return SIMPLE_TYPE;
}
- public String getTypeName() {
+ public String getName() {
return fTypeName;
}
- public String getTargetNamespace() {
+ public String getNamespace() {
return fTargetNamespace;
}
- public short getFinalSet(){
+ public short getFinal(){
return fFinalSet;
}
- public XSTypeDecl getBaseType(){
+ public boolean getIsFinal(short derivation) {
+ return (fFinalSet & derivation) != 0;
+ }
+
+ public XSTypeDefinition getBaseType(){
return fBase;
}
- public boolean isAnonymous() {
+ public boolean getIsAnonymous() {
return fTypeName == null;
}
@@ -405,10 +417,6 @@
return fValidationDV == DV_ANYSIMPLETYPE ? VARIETY_ABSENT : fVariety;
}
- public short getDefinedFacets() {
- return fFacetsDefined;
- }
-
public boolean isIDType(){
return (fValidationDV == DV_ID);
}
@@ -433,7 +441,7 @@
}
}
- public XSSimpleType getPrimitiveType() {
+ public XSSimpleTypeDefinition getPrimitiveType() {
if (fVariety == VARIETY_ATOMIC && fValidationDV != DV_ANYSIMPLETYPE) {
XSSimpleTypeDecl pri = this;
// recursively get base, until we reach anySimpleType
@@ -447,7 +455,7 @@
}
}
- public XSSimpleType getItemType() {
+ public XSSimpleTypeDefinition getItemType() {
if (fVariety == VARIETY_LIST) {
return fItemType;
}
@@ -457,9 +465,9 @@
}
}
- public XSSimpleType[] getMemberTypes() {
+ public XSObjectList getMemberTypes() {
if (fVariety == VARIETY_UNION) {
- return fMemberTypes;
+ return new XSObjectListImpl(fMemberTypes, fMemberTypes.length);
}
else {
// REVISIT: error situation. runtime exception?
@@ -1555,22 +1563,85 @@
}
}
- public short getOrderedFacet() {
+ public short getOrdered() {
return fOrdered;
}
- public boolean isBounded(){
+ public boolean getIsBounded(){
return fBounded;
}
- public short getCardinalityFacet(){
- return fCardinality;
+ public boolean getIsFinite(){
+ return fFinite;
}
- public boolean isNumeric(){
+ public boolean getIsNumeric(){
return fNumeric;
}
+ public boolean getIsDefinedFacet(short facetName) {
+ return (fFacetsDefined & facetName) != 0;
+ }
+
+ public short getDefinedFacets() {
+ return fFacetsDefined;
+ }
+
+ public boolean getIsFixedFacet(short facetName) {
+ return (fFixedFacet & facetName) != 0;
+ }
+
+ public short getFixedFacets() {
+ return fFixedFacet;
+ }
+
+ public String getLexicalFacetValue(short facetName) {
+ switch (facetName) {
+ case FACET_LENGTH:
+ return Integer.toString(fLength);
+ case FACET_MINLENGTH:
+ return Integer.toString(fMinLength);
+ case FACET_MAXLENGTH:
+ return Integer.toString(fMaxLength);
+ case FACET_WHITESPACE:
+ return WS_FACET_STRING[fWhiteSpace];
+ case FACET_MAXINCLUSIVE:
+ return getStringValue(fMaxInclusive);
+ case FACET_MAXEXCLUSIVE:
+ return getStringValue(fMaxExclusive);
+ case FACET_MINEXCLUSIVE:
+ return getStringValue(fMinExclusive);
+ case FACET_MININCLUSIVE:
+ return getStringValue(fMinInclusive);
+ case FACET_TOTALDIGITS:
+ return Integer.toString(fTotalDigits);
+ case FACET_FRACTIONDIGITS:
+ return Integer.toString(fFractionDigits);
+ }
+ return null;
+ }
+
+ public Enumeration getLexicalEnumerations() {
+ int size = fEnumeration.size();
+ String[] strs = new String[size];
+ for (int i = 0; i < size; i++)
+ strs[i] = getStringValue(fEnumeration.elementAt(i));
+ return new EnumerationImpl(strs, size);
+ }
+
+ public Enumeration getLexicalPatterns() {
+ int size = fPattern.size();
+ String[] strs = new String[size];
+ for (int i = 0; i < size; i++)
+ strs[i] = ((RegularExpression)fPattern.elementAt(i)).toString();
+ return new EnumerationImpl(strs, size);
+ }
+
+ public XSAnnotation getAnnotation() {
+ // REVISIT: SCAPI: to implement
+ return null;
+ }
+
private void caclFundamentalFacets() {
setOrdered();
setNumeric();
@@ -1633,9 +1704,9 @@
this.fNumeric = false;
}
else if(fVariety == VARIETY_UNION){
- XSSimpleType [] memberTypes = this.getMemberTypes();
+ XSSimpleType[] memberTypes = fMemberTypes;
for(int i = 0 ; i < memberTypes.length ; i++){
- if( ! memberTypes[i].isNumeric() ){
+ if(!memberTypes[i].getIsNumeric() ){
this.fNumeric = false;
return;
}
@@ -1675,7 +1746,7 @@
}
for(int i = 0 ; i < memberTypes.length ; i++){
- if( ! memberTypes[i].isBounded() || (ancestorId != getPrimitiveDV(memberTypes[i].fValidationDV)) ){
+ if(!memberTypes[i].getIsBounded() || (ancestorId != getPrimitiveDV(memberTypes[i].fValidationDV)) ){
this.fBounded = false;
return;
}
@@ -1697,47 +1768,47 @@
private void setCardinality(){
if(fVariety == VARIETY_ATOMIC){
- if(fBase.fCardinality == CARDINALITY_FINITE){
- this.fCardinality = CARDINALITY_FINITE;
+ if(fBase.fFinite){
+ this.fFinite = true;
}
- else {// (fBase.fCardinality == CARDINALITY_COUNTABLY_INFINITE)
+ else {// (!fBase.fFinite)
if ( ((this.fFacetsDefined & FACET_LENGTH) != 0 ) || ((this.fFacetsDefined & FACET_MAXLENGTH) != 0 )
|| ((this.fFacetsDefined & FACET_TOTALDIGITS) != 0 ) ){
- this.fCardinality = CARDINALITY_FINITE;
+ this.fFinite = true;
}
else if( (((this.fFacetsDefined & FACET_MININCLUSIVE) != 0 ) || ((this.fFacetsDefined & FACET_MINEXCLUSIVE) != 0 ))
&& (((this.fFacetsDefined & FACET_MAXINCLUSIVE) != 0 ) || ((this.fFacetsDefined & FACET_MAXEXCLUSIVE) != 0 )) ){
if( ((this.fFacetsDefined & FACET_FRACTIONDIGITS) != 0 ) || specialCardinalityCheck()){
- this.fCardinality = CARDINALITY_FINITE;
+ this.fFinite = true;
}
else{
- this.fCardinality = CARDINALITY_COUNTABLY_INFINITE;
+ this.fFinite = false;
}
}
else{
- this.fCardinality = CARDINALITY_COUNTABLY_INFINITE;
+ this.fFinite = false;
}
}
}
else if(fVariety == VARIETY_LIST){
if( ((this.fFacetsDefined & FACET_LENGTH) != 0 ) || ( ((this.fFacetsDefined & FACET_MINLENGTH) != 0 )
&& ((this.fFacetsDefined & FACET_MAXLENGTH) != 0 )) ){
- this.fCardinality = CARDINALITY_FINITE;
+ this.fFinite = true;
}
else{
- this.fCardinality = CARDINALITY_COUNTABLY_INFINITE;
+ this.fFinite = false;
}
}
else if(fVariety == VARIETY_UNION){
- XSSimpleType [] memberTypes = this.getMemberTypes();
+ XSSimpleType [] memberTypes = fMemberTypes;
for(int i = 0 ; i < memberTypes.length ; i++){
- if( ! (memberTypes[i].getCardinalityFacet() == CARDINALITY_FINITE) ){
- this.fCardinality = CARDINALITY_COUNTABLY_INFINITE;
+ if(!(memberTypes[i].getIsFinite()) ){
+ this.fFinite = false;
return;
}
}
- this.fCardinality = CARDINALITY_FINITE;
+ this.fFinite = true;
}
}//setCardinality
@@ -1753,7 +1824,7 @@
}//getPrimitiveDV()
- public boolean derivedFrom(XSTypeDecl ancestor) {
+ public boolean derivedFrom(XSTypeDefinition ancestor) {
// ancestor is null, retur false
if (ancestor == null)
return false;
@@ -1761,7 +1832,7 @@
if (ancestor == SchemaGrammar.fAnyType)
return true;
// recursively get base, and compare it with ancestor
- XSTypeDecl type = this;
+ XSTypeDefinition type = this;
while (type != ancestor && // compare with ancestor
type != SchemaGrammar.fAnySimpleType) { // reached anySimpleType
type = type.getBaseType();
@@ -1783,17 +1854,17 @@
// recursively get base, and compare it with ancestor
XSTypeDecl type = this;
- while (!(ancestorName.equals(type.getTypeName()) &&
- ((ancestorNS == null && type.getTargetNamespace() == null) ||
- (ancestorNS != null && ancestorNS.equals(type.getTargetNamespace())))) && // compare with ancestor
+ while (!(ancestorName.equals(type.getName()) &&
+ ((ancestorNS == null && type.getNamespace() == null) ||
+ (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) && // compare with ancestor
type != SchemaGrammar.fAnySimpleType) { // reached anySimpleType
- type = type.getBaseType();
+ type = (XSTypeDecl)type.getBaseType();
}
return type != SchemaGrammar.fAnySimpleType;
}
- static final XSSimpleTypeDecl fAnySimpleType = new XSSimpleTypeDecl(null, "anySimpleType", DV_ANYSIMPLETYPE, ORDERED_FALSE, false, CARDINALITY_FINITE, false);
+ static final XSSimpleTypeDecl fAnySimpleType = new XSSimpleTypeDecl(null, "anySimpleType", DV_ANYSIMPLETYPE, ORDERED_FALSE, false, true, false);
/**
* Validation context used to validate facet values.
1.8 +6 -6 xml-xerces/java/src/org/apache/xerces/impl/xs/AttributePSVImpl.java
Index: AttributePSVImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/AttributePSVImpl.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- AttributePSVImpl.java 23 Apr 2002 13:38:30 -0000 1.7
+++ AttributePSVImpl.java 16 May 2002 18:25:54 -0000 1.8
@@ -111,7 +111,7 @@
* otherwise false.
*/
public boolean isMemberTypeAnonymous() {
- return (fMemberType !=null)? fMemberType.isAnonymous():false;
+ return (fMemberType !=null)? fMemberType.getIsAnonymous():false;
}
@@ -123,7 +123,7 @@
* value unique to the definition.
*/
public String getMemberTypeName() {
- return (fMemberType !=null)? fMemberType.getTypeName():null;
+ return (fMemberType !=null)? fMemberType.getName():null;
}
/**
@@ -132,7 +132,7 @@
* @return The {target namespace} of the actual member type definition.
*/
public String getMemberTypeNamespace() {
- return (fMemberType !=null)? fMemberType.getTargetNamespace():null;
+ return (fMemberType !=null)? fMemberType.getNamespace():null;
}
/**
@@ -176,7 +176,7 @@
* @return true if the {name} of the type definition is absent, otherwise false.
*/
public boolean isTypeAnonymous() {
- return (fTypeDecl !=null)? fTypeDecl.isAnonymous():false;
+ return (fTypeDecl !=null)? fTypeDecl.getIsAnonymous():false;
}
/**
@@ -187,7 +187,7 @@
* provide a value unique to the definition.
*/
public String getTypeName() {
- return (fTypeDecl !=null)? fTypeDecl.getTypeName():null;
+ return (fTypeDecl !=null)? fTypeDecl.getName():null;
}
/**
@@ -196,7 +196,7 @@
* @return The {target namespace} of the type definition.
*/
public String getTypeNamespace() {
- return (fTypeDecl !=null)? fTypeDecl.getTargetNamespace():null;
+ return (fTypeDecl !=null)? fTypeDecl.getNamespace():null;
}
/**
1.13 +7 -7 xml-xerces/java/src/org/apache/xerces/impl/xs/ElementPSVImpl.java
Index: ElementPSVImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/ElementPSVImpl.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ElementPSVImpl.java 23 Apr 2002 13:38:30 -0000 1.12
+++ ElementPSVImpl.java 16 May 2002 18:25:54 -0000 1.13
@@ -125,7 +125,7 @@
* otherwise false.
*/
public boolean isMemberTypeAnonymous() {
- return (fMemberType !=null)? fMemberType.isAnonymous():false;
+ return (fMemberType !=null)? fMemberType.getIsAnonymous():false;
}
@@ -137,7 +137,7 @@
* value unique to the definition.
*/
public String getMemberTypeName() {
- return (fMemberType !=null)? fMemberType.getTypeName():null;
+ return (fMemberType !=null)? fMemberType.getName():null;
}
/**
@@ -146,7 +146,7 @@
* @return The {target namespace} of the actual member type definition.
*/
public String getMemberTypeNamespace() {
- return (fMemberType !=null)? fMemberType.getTargetNamespace():null;
+ return (fMemberType !=null)? fMemberType.getNamespace():null;
}
/**
@@ -190,7 +190,7 @@
* @return true if the {name} of the type definition is absent, otherwise false.
*/
public boolean isTypeAnonymous() {
- return (fTypeDecl !=null)? fTypeDecl.isAnonymous():false;
+ return (fTypeDecl !=null)? fTypeDecl.getIsAnonymous():false;
}
/**
@@ -201,7 +201,7 @@
* provide a value unique to the definition.
*/
public String getTypeName() {
- return (fTypeDecl !=null)? fTypeDecl.getTypeName():null;
+ return (fTypeDecl !=null)? fTypeDecl.getName():null;
}
/**
@@ -210,7 +210,7 @@
* @return The {target namespace} of the type definition.
*/
public String getTypeNamespace() {
- return (fTypeDecl !=null)? fTypeDecl.getTargetNamespace():null;
+ return (fTypeDecl !=null)? fTypeDecl.getNamespace():null;
}
/**
@@ -221,7 +221,7 @@
* @return simple or complex, depending on the type definition.
*/
public short getTypeDefinitionType() {
- return (fTypeDecl !=null)? fTypeDecl.getXSType():XSTypeDecl.COMPLEX_TYPE;
+ return (fTypeDecl !=null)? fTypeDecl.getTypeCategory():XSTypeDecl.COMPLEX_TYPE;
}
/**
1.18 +14 -13 xml-xerces/java/src/org/apache/xerces/impl/xs/SchemaGrammar.java
Index: SchemaGrammar.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/SchemaGrammar.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- SchemaGrammar.java 26 Apr 2002 22:03:42 -0000 1.17
+++ SchemaGrammar.java 16 May 2002 18:25:54 -0000 1.18
@@ -61,6 +61,7 @@
import org.apache.xerces.impl.dv.XSSimpleType;
import org.apache.xerces.impl.xs.identity.IdentityConstraint;
import org.apache.xerces.impl.xs.util.SimpleLocator;
+import org.apache.xerces.impl.xs.psvi.XSConstants;
import org.apache.xerces.util.SymbolTable;
import org.apache.xerces.util.SymbolHash;
@@ -82,7 +83,7 @@
* @author Sandy Gao, IBM
* @author Elena Litani, IBM
*
- * @version $Id: SchemaGrammar.java,v 1.17 2002/04/26 22:03:42 sandygao Exp $
+ * @version $Id: SchemaGrammar.java,v 1.18 2002/05/16 18:25:54 sandygao Exp $
*/
public class SchemaGrammar implements Grammar {
@@ -97,7 +98,7 @@
SymbolHash fGlobalGroupDecls;
SymbolHash fGlobalNotationDecls;
SymbolHash fGlobalIDConstraintDecls;
- Hashtable fGlobalTypeDecls;
+ SymbolHash fGlobalTypeDecls;
// the XMLGrammarDescription member
XSDDescription fGrammarDescription = null;
@@ -125,7 +126,7 @@
fGlobalElemDecls = new SymbolHash();
fGlobalGroupDecls = new SymbolHash();
fGlobalNotationDecls = new SymbolHash();
- fGlobalTypeDecls = new Hashtable();
+ fGlobalTypeDecls = new SymbolHash();
fGlobalIDConstraintDecls = new SymbolHash();
} // <init>(String, XSDDescription)
@@ -180,7 +181,7 @@
fGlobalGroupDecls = new SymbolHash(1);
fGlobalNotationDecls = new SymbolHash(1);
fGlobalIDConstraintDecls = new SymbolHash(1);
- fGlobalTypeDecls = new Hashtable(1);
+ fGlobalTypeDecls = new SymbolHash(1);
// 4 attributes, so initialize the size as 4*2 = 8
fGlobalAttrDecls = new SymbolHash(8);
@@ -191,7 +192,7 @@
attr.fName = SchemaSymbols.OXSI_TYPE.intern();
attr.fTargetNamespace = SchemaSymbols.URI_XSI;
attr.fType = schemaFactory.getBuiltInType(SchemaSymbols.ATTVAL_QNAME);
- attr.setIsGlobal();
+ attr.fScope = XSConstants.SCOPE_GLOBAL;
fGlobalAttrDecls.put(attr.fName, attr);
// xsi:nil
@@ -199,7 +200,7 @@
attr.fName = SchemaSymbols.OXSI_NIL.intern();
attr.fTargetNamespace = SchemaSymbols.URI_XSI;
attr.fType = schemaFactory.getBuiltInType(SchemaSymbols.ATTVAL_BOOLEAN);
- attr.setIsGlobal();
+ attr.fScope = XSConstants.SCOPE_GLOBAL;
fGlobalAttrDecls.put(attr.fName, attr);
XSSimpleType anyURI = schemaFactory.getBuiltInType(SchemaSymbols.ATTVAL_ANYURI);
@@ -209,7 +210,7 @@
attr.fName = SchemaSymbols.OXSI_SCHEMALOCATION.intern();
attr.fTargetNamespace = SchemaSymbols.URI_XSI;
attr.fType = schemaFactory.createTypeList(null, SchemaSymbols.URI_XSI, (short)0, anyURI);
- attr.setIsGlobal();
+ attr.fScope = XSConstants.SCOPE_GLOBAL;
fGlobalAttrDecls.put(attr.fName, attr);
// xsi:noNamespaceSchemaLocation
@@ -217,7 +218,7 @@
attr.fName = SchemaSymbols.OXSI_NONAMESPACESCHEMALOCATION.intern();
attr.fTargetNamespace = SchemaSymbols.URI_XSI;
attr.fType = anyURI;
- attr.setIsGlobal();
+ attr.fScope = XSConstants.SCOPE_GLOBAL;
fGlobalAttrDecls.put(attr.fName, attr);
}
} // <init>(int)
@@ -299,7 +300,7 @@
* register one global type
*/
public final void addGlobalTypeDecl(XSTypeDecl decl) {
- fGlobalTypeDecls.put(decl.getTypeName(), decl);
+ fGlobalTypeDecls.put(decl.getName(), decl);
}
/**
@@ -480,13 +481,13 @@
fAnyType.fName = SchemaSymbols.ATTVAL_ANYTYPE;
fAnyType.fTargetNamespace = SchemaSymbols.URI_SCHEMAFORSCHEMA;
fAnyType.fBaseType = fAnyType;
- fAnyType.fDerivedBy = SchemaSymbols.RESTRICTION;
+ fAnyType.fDerivedBy = XSConstants.DERIVATION_RESTRICTION;
fAnyType.fContentType = XSComplexTypeDecl.CONTENTTYPE_MIXED;
// the wildcard used in anyType (content and attribute)
// the spec will change strict to lax for anyType
XSWildcardDecl wildcard = new XSWildcardDecl();
- wildcard.fProcessContents = SchemaSymbols.ANY_LAX;
+ wildcard.fProcessContents = XSWildcardDecl.PC_LAX;
// the particle for the content wildcard
XSParticleDecl particleW = new XSParticleDecl();
particleW.fMinOccurs = 0;
@@ -494,8 +495,8 @@
particleW.fType = XSParticleDecl.PARTICLE_WILDCARD;
particleW.fValue = wildcard;
// the model group of a sequence of the above particle
- XSModelGroup group = new XSModelGroup();
- group.fCompositor = XSModelGroup.MODELGROUP_SEQUENCE;
+ XSModelGroupImpl group = new XSModelGroupImpl();
+ group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
group.fParticleCount = 1;
group.fParticles = new XSParticleDecl[1];
group.fParticles[0] = particleW;
1.3 +3 -22 xml-xerces/java/src/org/apache/xerces/impl/xs/SchemaSymbols.java
Index: SchemaSymbols.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/SchemaSymbols.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SchemaSymbols.java 29 Jan 2002 01:15:14 -0000 1.2
+++ SchemaSymbols.java 16 May 2002 18:25:54 -0000 1.3
@@ -63,7 +63,7 @@
* Collection of symbols used to parse a Schema Grammar.
*
* @author jeffrey rodriguez
- * @version $Id: SchemaSymbols.java,v 1.2 2002/01/29 01:15:14 lehors Exp $
+ * @version $Id: SchemaSymbols.java,v 1.3 2002/05/16 18:25:54 sandygao Exp $
*/
public final class SchemaSymbols {
@@ -252,36 +252,17 @@
public static final String ATTVAL_YEAR = "gYear";
public static final String ATTVAL_YEARMONTH = "gYearMonth";
- // block/final values
- public static final short EMPTY_SET = 0;
- public static final short EXTENSION = 1;
- public static final short RESTRICTION = 2;
- public static final short UNION = 4;
- public static final short LIST = 8;
- public static final short ENUMERATION = 16;
- public static final short SUBSTITUTION = 32;
-
// form qualified/unqualified
public static final short FORM_UNQUALIFIED = 0;
public static final short FORM_QUALIFIED = 1;
- // any: processContents
- public static final short ANY_STRICT = 0;
- public static final short ANY_LAX = 1;
- public static final short ANY_SKIP = 2;
-
// attribute use
public static final short USE_OPTIONAL = 0;
public static final short USE_REQUIRED = 1;
public static final short USE_PROHIBITED = 2;
-
- // whiteSpace
- public static final short WS_PRESERVE = 0;
- public static final short WS_REPLACE = 1;
- public static final short WS_COLLAPSE = 2;
-
+
// maxOccurs = "unbounded"
- public static final int OCCURRENCE_UNBOUNDED = -1;
+ public static final int OCCURRENCE_UNBOUNDED = -1;
/**
1.7 +10 -9 xml-xerces/java/src/org/apache/xerces/impl/xs/SubstitutionGroupHandler.java
Index: SubstitutionGroupHandler.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/SubstitutionGroupHandler.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SubstitutionGroupHandler.java 29 Jan 2002 01:15:14 -0000 1.6
+++ SubstitutionGroupHandler.java 16 May 2002 18:25:54 -0000 1.7
@@ -57,6 +57,7 @@
package org.apache.xerces.impl.xs;
+import org.apache.xerces.impl.xs.psvi.XSConstants;
import org.apache.xerces.xni.QName;
import java.util.Hashtable;
import java.util.Vector;
@@ -66,7 +67,7 @@
*
* @author Sandy Gao, IBM
*
- * @version $Id: SubstitutionGroupHandler.java,v 1.6 2002/01/29 01:15:14 lehors Exp $
+ * @version $Id: SubstitutionGroupHandler.java,v 1.7 2002/05/16 18:25:54 sandygao Exp $
*/
public class SubstitutionGroupHandler {
@@ -90,11 +91,11 @@
// if the exemplar is not a global element decl, then it's not possible
// to be substituted by another element.
- if (!exemplar.isGlobal())
+ if (exemplar.fScope != XSConstants.SCOPE_GLOBAL)
return null;
// if the decl blocks substitution, return false
- if ((exemplar.fBlock & SchemaSymbols.SUBSTITUTION) != 0)
+ if ((exemplar.fBlock & XSConstants.DERIVATION_SUBSTITUTION) != 0)
return null;
// get grammar of the element
@@ -119,7 +120,7 @@
protected boolean substitutionGroupOK(XSElementDecl element, XSElementDecl exemplar, short blockingConstraint) {
// For an element declaration (call it D) together with a blocking constraint (a subset of {substitution, extension, restriction}, the value of a {disallowed substitutions}) to be validly substitutable for another element declaration (call it C) all of the following must be true:
// 1 The blocking constraint does not contain substitution.
- if ((blockingConstraint & SchemaSymbols.SUBSTITUTION) != 0)
+ if ((blockingConstraint & XSConstants.DERIVATION_SUBSTITUTION) != 0)
return false;
// prepare the combination of {derivation method} and
@@ -128,14 +129,14 @@
// initialize the derivation method to be that of the type of D
XSTypeDecl type = element.fType;
- if (type.getXSType() == XSTypeDecl.COMPLEX_TYPE)
+ if (type.getTypeCategory() == XSTypeDecl.COMPLEX_TYPE)
devMethod = ((XSComplexTypeDecl)type).fDerivedBy;
else
- devMethod = SchemaSymbols.RESTRICTION;
+ devMethod = XSConstants.DERIVATION_RESTRICTION;
// initialize disallowed substitution to the passed in blocking constraint
type = exemplar.fType;
- if (type.getXSType() == XSTypeDecl.COMPLEX_TYPE)
+ if (type.getTypeCategory() == XSTypeDecl.COMPLEX_TYPE)
blockConstraint |= ((XSComplexTypeDecl)type).fBlock;
// 2 There is a chain of {substitution group affiliation}s from D to C, that is, either D's {substitution group affiliation} is C, or D's {substitution group affiliation}'s {substitution group affiliation} is C, or . . .
@@ -144,11 +145,11 @@
// add the derivation method and disallowed substitution info
// of the current type to the corresponding variables
type = subGroup.fType;
- if (type.getXSType() == XSTypeDecl.COMPLEX_TYPE) {
+ if (type.getTypeCategory() == XSTypeDecl.COMPLEX_TYPE) {
devMethod |= ((XSComplexTypeDecl)type).fDerivedBy;
blockConstraint |= ((XSComplexTypeDecl)type).fBlock;
} else {
- devMethod |= SchemaSymbols.RESTRICTION;
+ devMethod |= XSConstants.DERIVATION_RESTRICTION;
}
subGroup = subGroup.fSubGroup;
}
1.62 +58 -57 xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
Index: XMLSchemaValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- XMLSchemaValidator.java 15 May 2002 04:04:31 -0000 1.61
+++ XMLSchemaValidator.java 16 May 2002 18:25:54 -0000 1.62
@@ -58,7 +58,6 @@
package org.apache.xerces.impl.xs;
import org.apache.xerces.impl.dv.XSSimpleType;
-import org.apache.xerces.impl.dv.XSAtomicSimpleType;
import org.apache.xerces.impl.dv.ValidatedInfo;
import org.apache.xerces.impl.dv.DatatypeException;
import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
@@ -71,6 +70,8 @@
import org.apache.xerces.impl.xs.traversers.XSAttributeChecker;
import org.apache.xerces.impl.xs.models.CMBuilder;
import org.apache.xerces.impl.xs.models.XSCMValidator;
+import org.apache.xerces.impl.xs.psvi.XSConstants;
+import org.apache.xerces.impl.xs.psvi.XSObjectList;
import org.apache.xerces.impl.msg.XMLMessageFormatter;
import org.apache.xerces.impl.validation.ValidationState;
import org.apache.xerces.impl.XMLEntityManager;
@@ -141,7 +142,7 @@
* @author Elena Litani IBM
* @author Andy Clark IBM
* @author Neeraj Bajaj, Sun Microsystems, inc.
- * @version $Id: XMLSchemaValidator.java,v 1.61 2002/05/15 04:04:31 sandygao Exp $
+ * @version $Id: XMLSchemaValidator.java,v 1.62 2002/05/16 18:25:54 sandygao Exp $
*/
public class XMLSchemaValidator
implements XMLComponent, XMLDocumentFilter, FieldActivator {
@@ -1440,7 +1441,7 @@
}
boolean mixed = false;
- if (fCurrentType != null && fCurrentType.getXSType() == XSTypeDecl.COMPLEX_TYPE) {
+ if (fCurrentType != null && fCurrentType.getTypeCategory() == XSTypeDecl.COMPLEX_TYPE) {
XSComplexTypeDecl ctype = (XSComplexTypeDecl)fCurrentType;
if (ctype.fContentType == XSComplexTypeDecl.CONTENTTYPE_MIXED) {
mixed = true;
@@ -1448,7 +1449,7 @@
}
if (DEBUG) {
- System.out.println("==>characters()"+fCurrentType.getTypeName()+":"+mixed);
+ System.out.println("==>characters()"+fCurrentType.getName()+":"+mixed);
}
if (mixed || fWhiteSpace !=-1 || fUnionType) {
@@ -1725,7 +1726,7 @@
}
// if the wildcard is skip, then return
- if (wildcard != null && wildcard.fProcessContents == XSWildcardDecl.WILDCARD_SKIP) {
+ if (wildcard != null && wildcard.fProcessContents == XSWildcardDecl.PC_SKIP) {
fSkipValidationDepth = fElementDepth;
return augs;
}
@@ -1746,7 +1747,7 @@
// Element Locally Valid (Element)
// 2 Its {abstract} must be false.
- if (fCurrentElemDecl != null && fCurrentElemDecl.isAbstract())
+ if (fCurrentElemDecl != null && fCurrentElemDecl.getIsAbstract())
reportSchemaError("cvc-elt.2", new Object[]{element.rawname});
if (fCurrentElemDecl != null) {
@@ -1771,7 +1772,7 @@
}
// if wildcard = strict, report error
else if (wildcard != null &&
- wildcard.fProcessContents == XSWildcardDecl.WILDCARD_STRICT) {
+ wildcard.fProcessContents == XSWildcardDecl.PC_STRICT) {
// report error, because wilcard = strict
reportSchemaError("cvc-complex-type.2.4.c", new Object[]{element.rawname});
}
@@ -1798,9 +1799,9 @@
// Element Locally Valid (Type)
// 2 Its {abstract} must be false.
- if (fCurrentType.getXSType() == XSTypeDecl.COMPLEX_TYPE) {
+ if (fCurrentType.getTypeCategory() == XSTypeDecl.COMPLEX_TYPE) {
XSComplexTypeDecl ctype = (XSComplexTypeDecl)fCurrentType;
- if (ctype.isAbstractType()) {
+ if (ctype.getIsAbstract()) {
reportSchemaError("cvc-type.2", new Object[]{"Element " + element.rawname + " is declared with a type that is abstract. Use xsi:type to specify a non-abstract type"});
}
if (fNormalizeData) {
@@ -1820,7 +1821,7 @@
}
}
// normalization
- if (fNormalizeData && fCurrentType.getXSType() == XSTypeDecl.SIMPLE_TYPE) {
+ if (fNormalizeData && fCurrentType.getTypeCategory() == XSTypeDecl.SIMPLE_TYPE) {
// if !union type
XSSimpleType dv = (XSSimpleType)fCurrentType;
if (dv.getVariety() == XSSimpleType.VARIETY_UNION) {
@@ -1837,7 +1838,7 @@
// then try to get the content model
fCurrentCM = null;
- if (fCurrentType.getXSType() == XSTypeDecl.COMPLEX_TYPE) {
+ if (fCurrentType.getTypeCategory() == XSTypeDecl.COMPLEX_TYPE) {
fCurrentCM = ((XSComplexTypeDecl)fCurrentType).getContentModel(fCMBuilder);
}
@@ -1855,7 +1856,7 @@
// now validate everything related with the attributes
// first, get the attribute group
XSAttributeGroupDecl attrGrp = null;
- if (fCurrentType.getXSType() == XSTypeDecl.COMPLEX_TYPE) {
+ if (fCurrentType.getTypeCategory() == XSTypeDecl.COMPLEX_TYPE) {
XSComplexTypeDecl ctype = (XSComplexTypeDecl)fCurrentType;
attrGrp = ctype.fAttrGrp;
}
@@ -1870,7 +1871,7 @@
int icCount = fCurrentElemDecl.fIDCPos;
int uniqueOrKey = 0;
for (;uniqueOrKey < icCount; uniqueOrKey++) {
- if (fCurrentElemDecl.fIDConstraints[uniqueOrKey].getType() != IdentityConstraint.KEYREF) {
+ if (fCurrentElemDecl.fIDConstraints[uniqueOrKey].getCategory() != IdentityConstraint.IC_KEYREF) {
activateSelectorFor(fCurrentElemDecl.fIDConstraints[uniqueOrKey]);
}
else
@@ -1976,7 +1977,7 @@
for (int i = oldCount - 1; i >= newCount; i--) {
XPathMatcher matcher = fMatcherStack.getMatcherAt(i);
IdentityConstraint id;
- if ((id = matcher.getIDConstraint()) != null && id.getType() != IdentityConstraint.KEYREF) {
+ if ((id = matcher.getIDConstraint()) != null && id.getCategory() != IdentityConstraint.IC_KEYREF) {
matcher.endDocumentFragment();
fValueStoreCache.transplant(id);
}
@@ -1987,7 +1988,7 @@
for (int i = oldCount - 1; i >= newCount; i--) {
XPathMatcher matcher = fMatcherStack.getMatcherAt(i);
IdentityConstraint id;
- if ((id = matcher.getIDConstraint()) != null && id.getType() == IdentityConstraint.KEYREF) {
+ if ((id = matcher.getIDConstraint()) != null && id.getCategory() == IdentityConstraint.IC_KEYREF) {
ValueStoreBase values = fValueStoreCache.getValueStoreFor(id);
if (values != null) // nothing to do if nothing matched!
values.endDocumentFragment();
@@ -2366,7 +2367,7 @@
if (fCurrentType != null) {
// 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.getXSType() == XSTypeDecl.COMPLEX_TYPE)
+ if (fCurrentType.getTypeCategory() == XSTypeDecl.COMPLEX_TYPE)
block |= ((XSComplexTypeDecl)fCurrentType).fBlock;
if (!XSConstraints.checkTypeDerivationOk(type, fCurrentType, block))
reportSchemaError("cvc-elt.4.3", new Object[]{element.rawname, xsiType});
@@ -2379,7 +2380,7 @@
// Element Locally Valid (Element)
// 3 The appropriate case among the following must be true:
// 3.1 If {nillable} is false, then there must be no attribute information item among the element information item's [attributes] whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is nil.
- if (fCurrentElemDecl != null && !fCurrentElemDecl.isNillable()) {
+ if (fCurrentElemDecl != null && !fCurrentElemDecl.getIsNillable()) {
reportSchemaError("cvc-elt.3.1", new Object[]{element.rawname, URI_XSI+","+XSI_NIL});
}
// 3.2 If {nillable} is true and there is such an attribute information item and its actual value is true , then all of the following must be true:
@@ -2389,7 +2390,7 @@
if (value.equals(SchemaSymbols.ATTVAL_TRUE) ||
value.equals(SchemaSymbols.ATTVAL_TRUE_1)) {
if (fCurrentElemDecl != null &&
- fCurrentElemDecl.getConstraintType() == XSElementDecl.FIXED_VALUE) {
+ fCurrentElemDecl.getConstraintType() == XSConstants.VC_FIXED) {
reportSchemaError("cvc-elt.3.2.2", new Object[]{element.rawname, URI_XSI+","+XSI_NIL});
}
return true;
@@ -2438,7 +2439,7 @@
// 3.1.1 The element information item's [attributes] must be empty, 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.
- if (fCurrentType == null || fCurrentType.getXSType() == XSTypeDecl.SIMPLE_TYPE) {
+ if (fCurrentType == null || fCurrentType.getTypeCategory() == XSTypeDecl.SIMPLE_TYPE) {
int attCount = attributes.getLength();
for (int index = 0; index < attCount; index++) {
@@ -2473,8 +2474,8 @@
return;
}
- XSAttributeUse attrUses[] = attrGrp.getAttributeUses();
- int useCount = (attrUses!=null)? attrUses.length:0;
+ XSObjectList attrUses = attrGrp.getAttributeUses();
+ int useCount = attrUses.getListLength();
XSWildcardDecl attrWildcard = attrGrp.fAttributeWC;
// whether we have seen a Wildcard ID.
@@ -2516,12 +2517,12 @@
}
// it's not xmlns, and not xsi, then we need to find a decl for it
- XSAttributeUse currUse = null;
+ XSAttributeUseImpl currUse = null, oneUse;
for (int i = 0; i < useCount; i++) {
-
- if (attrUses[i].fAttrDecl.fName == fTempQName.localpart &&
- attrUses[i].fAttrDecl.fTargetNamespace == fTempQName.uri) {
- currUse = attrUses[i];
+ oneUse = (XSAttributeUseImpl)attrUses.getItem(i);
+ if (oneUse.fAttrDecl.fName == fTempQName.localpart &&
+ oneUse.fAttrDecl.fTargetNamespace == fTempQName.uri) {
+ currUse = oneUse;
break;
}
}
@@ -2549,7 +2550,7 @@
else {
// which means it matches a wildcard
// skip it if processContents is skip
- if (attrWildcard.fProcessContents == XSWildcardDecl.WILDCARD_SKIP)
+ if (attrWildcard.fProcessContents == XSWildcardDecl.PC_SKIP)
continue;
//try to find grammar by different means...
@@ -2562,7 +2563,7 @@
// if can't find
if (currDecl == null) {
// if strict, report error
- if (attrWildcard.fProcessContents == XSWildcardDecl.WILDCARD_STRICT){
+ if (attrWildcard.fProcessContents == XSWildcardDecl.PC_STRICT){
reportSchemaError("cvc-complex-type.3.2.2", new Object[]{element.rawname, fTempQName.rawname});
}
@@ -2572,7 +2573,7 @@
else {
// 5 Let [Definition:] the wild IDs be the set of all attribute information item to which clause 3.2 applied and whose validation resulted in a context-determined declaration of mustFind or no context-determined declaration at all, and whose [local name] and [namespace name] resolve (as defined by QName resolution (Instance) (3.15.4)) to an attribute declaration whose {type definition} is or is derived from ID. Then all of the following must be true:
// 5.1 There must be no more than one item in wild IDs.
- if (currDecl.fType.getXSType() == XSTypeDecl.SIMPLE_TYPE &&
+ if (currDecl.fType.getTypeCategory() == XSTypeDecl.SIMPLE_TYPE &&
((XSSimpleType)currDecl.fType).isIDType()) {
if (wildcardIDName != null){
reportSchemaError("cvc-complex-type.5.1", new Object[]{element.rawname, currDecl.fName, wildcardIDName});
@@ -2600,7 +2601,7 @@
} //processAttributes
void processOneAttribute(QName element, String attrValue,
- XSAttributeDecl currDecl, XSAttributeUse currUse,
+ XSAttributeDecl currDecl, XSAttributeUseImpl currUse,
AttributePSVImpl attrPSVI) {
// Attribute Locally Valid
// For an attribute information item to be locally valid with respect to an attribute declaration all of the following must be true:
@@ -2626,7 +2627,7 @@
attrPSVI.fMemberType = fValidatedInfo.memberType;
// PSVI: element notation
if (attDV.getVariety() == XSSimpleType.VARIETY_ATOMIC &&
- ((XSAtomicSimpleType)attDV).getPrimitiveKind() == XSAtomicSimpleType.PRIMITIVE_NOTATION){
+ attDV.getPrimitiveKind() == XSSimpleType.PRIMITIVE_NOTATION){
QName qName = (QName)actualValue;
SchemaGrammar grammar = fGrammarBucket.getGrammar(qName.uri);
@@ -2656,7 +2657,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() == XSAttributeDecl.FIXED_VALUE) {
+ currDecl.getConstraintType() == XSConstants.VC_FIXED) {
if (!attDV.isEqual(actualValue, currDecl.fDefault.actualValue)){
// PSVI: attribute is invalid, record errors
@@ -2668,7 +2669,7 @@
// 3.1 If there is among the {attribute uses} an attribute use with an {attribute declaration} whose {name} matches the attribute information item's [local name] and whose {target namespace} is identical to the attribute information item's [namespace name] (where an absent {target namespace} is taken to be identical to a [namespace name] with no value), then the attribute information must be valid with respect to that attribute use as per Attribute Locally Valid (Use) (3.5.4). In this case the {attribute declaration} of that attribute use is the context-determined declaration for the attribute information item with respect to Schema-Validity Assessment (Attribute) (3.2.4) and Assessment Outcome (Attribute) (3.2.5).
if (actualValue != null &&
- currUse != null && currUse.fConstraintType == XSAttributeDecl.FIXED_VALUE) {
+ currUse != null && currUse.fConstraintType == XSConstants.VC_FIXED) {
if (!attDV.isEqual(actualValue, currUse.fDefault.actualValue)){
// PSVI: attribute is invalid, record errors
attrPSVI.fValidity = AttributePSVI.INVALID_VALIDITY;
@@ -2688,9 +2689,9 @@
if (DEBUG) {
System.out.println("addDefaultAttributes: " + element);
}
- XSAttributeUse attrUses[] = attrGrp.getAttributeUses();
- int useCount = (attrUses!=null)? attrUses.length:0;
- XSAttributeUse currUse;
+ XSObjectList attrUses = attrGrp.getAttributeUses();
+ int useCount = attrUses.getListLength();
+ XSAttributeUseImpl currUse;
XSAttributeDecl currDecl;
short constType;
ValidatedInfo defaultValue;
@@ -2699,12 +2700,12 @@
// for each attribute use
for (int i = 0; i < useCount; i++) {
- currUse = attrUses[i];
+ currUse = (XSAttributeUseImpl)attrUses.getItem(i);
currDecl = currUse.fAttrDecl;
// get value constraint
constType = currUse.fConstraintType;
defaultValue = currUse.fDefault;
- if (constType == XSAttributeDecl.NO_CONSTRAINT) {
+ if (constType == XSConstants.VC_NONE) {
constType = currDecl.getConstraintType();
defaultValue = currDecl.fDefault;
}
@@ -2720,7 +2721,7 @@
reportSchemaError("cvc-complex-type.4", new Object[]{element.rawname, currDecl.fName});
}
// if the attribute is not specified, then apply the value constraint
- if (!isSpecified && constType != XSAttributeDecl.NO_CONSTRAINT) {
+ if (!isSpecified && constType != XSConstants.VC_NONE) {
attName = new QName(null, currDecl.fName, currDecl.fName, currDecl.fTargetNamespace);
int attrIndex = attributes.addAttribute(attName, "CDATA", (defaultValue!=null)?defaultValue.normalizedValue:"");
@@ -2782,7 +2783,7 @@
}
if (fCurrentElemDecl != null &&
- fCurrentElemDecl.getConstraintType() == XSElementDecl.DEFAULT_VALUE) {
+ fCurrentElemDecl.getConstraintType() == XSConstants.VC_DEFAULT) {
}
if (fDoValidation) {
@@ -2803,13 +2804,13 @@
// 5 The appropriate case among the following must be true:
// 5.1 If the declaration has a {value constraint}, the item has neither element nor character [children] and clause 3.2 has not applied, then all of the following must be true:
if (fCurrentElemDecl != null &&
- fCurrentElemDecl.getConstraintType() != XSElementDecl.NO_CONSTRAINT &&
+ fCurrentElemDecl.getConstraintType() != XSConstants.VC_NONE &&
fChildCount == 0 && content.length() == 0 && !fNil) {
// 5.1.1 If the actual type definition is a local type definition then the canonical lexical representation of the {value constraint} value must be a valid default for the actual type definition as defined in Element Default Valid (Immediate) (3.3.6).
if (fCurrentType != fCurrentElemDecl.fType) {
//REVISIT:we should pass ValidatedInfo here.
if (XSConstraints.ElementDefaultValidImmediate(fCurrentType, fCurrentElemDecl.fDefault, fState4XsiType, null) == null)
- reportSchemaError("cvc-elt.5.1.1", new Object[]{element.rawname, fCurrentType.getTypeName(), fCurrentElemDecl.fDefault.normalizedValue});
+ reportSchemaError("cvc-elt.5.1.1", new Object[]{element.rawname, fCurrentType.getName(), fCurrentElemDecl.fDefault.normalizedValue});
}
// 5.1.2 The element information item with the canonical lexical representation of the {value constraint} value used as its normalized value must be valid with respect to the actual type definition as defined by Element Locally Valid (Type) (3.3.4).
// REVISIT: don't use toString, but validateActualValue instead
@@ -2825,13 +2826,13 @@
Object actualValue = elementLocallyValidType(element, content);
// 5.2.2 If there is a fixed {value constraint} and clause 3.2 has not applied, all of the following must be true:
if (fCurrentElemDecl != null &&
- fCurrentElemDecl.getConstraintType() == XSElementDecl.FIXED_VALUE &&
+ fCurrentElemDecl.getConstraintType() == XSConstants.VC_FIXED &&
!fNil) {
// 5.2.2.1 The element information item must have no element information item [children].
if (fChildCount != 0)
reportSchemaError("cvc-elt.5.2.2.1", new Object[]{element.rawname});
// 5.2.2.2 The appropriate case among the following must be true:
- if (fCurrentType.getXSType() == XSTypeDecl.COMPLEX_TYPE) {
+ if (fCurrentType.getTypeCategory() == XSTypeDecl.COMPLEX_TYPE) {
XSComplexTypeDecl ctype = (XSComplexTypeDecl)fCurrentType;
// 5.2.2.2.1 If the {content type} of the actual type definition is mixed, then the initial value of the item must match the canonical lexical representation of the {value constraint} value.
if (ctype.fContentType == XSComplexTypeDecl.CONTENTTYPE_MIXED) {
@@ -2846,7 +2847,7 @@
reportSchemaError("cvc-elt.5.2.2.2.2", new Object[]{element.rawname, content, fCurrentElemDecl.fDefault.normalizedValue});
}
}
- else if (fCurrentType.getXSType() == XSTypeDecl.SIMPLE_TYPE) {
+ else if (fCurrentType.getTypeCategory() == XSTypeDecl.SIMPLE_TYPE) {
XSSimpleType sType = (XSSimpleType)fCurrentType;
if (!sType.isEqual(actualValue, fCurrentElemDecl.fDefault.actualValue))
reportSchemaError("cvc-elt.5.2.2.2.2", new Object[]{element.rawname, content, fCurrentElemDecl.fDefault.normalizedValue});
@@ -2879,7 +2880,7 @@
// Element Locally Valid (Type)
// 3 The appropriate case among the following must be true:
// 3.1 If the type definition is a simple type definition, then all of the following must be true:
- if (fCurrentType.getXSType() == XSTypeDecl.SIMPLE_TYPE) {
+ if (fCurrentType.getTypeCategory() == XSTypeDecl.SIMPLE_TYPE) {
// 3.1.2 The element information item must have no element information item [children].
if (fChildCount != 0)
reportSchemaError("cvc-type.3.1.2", new Object[]{element.rawname});
@@ -3179,7 +3180,7 @@
// REVISIT: Is this a problem? -Ac
// Yes - NG
if (fValuesCount == 0) {
- if (fIdentityConstraint.getType() == IdentityConstraint.KEY) {
+ if (fIdentityConstraint.getCategory() == IdentityConstraint.IC_KEY) {
String code = "AbsentKeyValue";
String eName = fIdentityConstraint.getElementName();
reportSchemaError(code, new Object[]{eName});
@@ -3189,14 +3190,14 @@
// do we have enough values?
if (fValuesCount != fIdentityConstraint.getFieldCount()) {
- switch (fIdentityConstraint.getType()) {
- case IdentityConstraint.UNIQUE: {
+ switch (fIdentityConstraint.getCategory()) {
+ case IdentityConstraint.IC_UNIQUE: {
String code = "UniqueNotEnoughValues";
String ename = fIdentityConstraint.getElementName();
reportSchemaError(code, new Object[]{ename});
break;
}
- case IdentityConstraint.KEY: {
+ case IdentityConstraint.IC_KEY: {
String code = "KeyNotEnoughValues";
UniqueOrKey key = (UniqueOrKey)fIdentityConstraint;
String ename = fIdentityConstraint.getElementName();
@@ -3204,7 +3205,7 @@
reportSchemaError(code, new Object[]{ename,kname});
break;
}
- case IdentityConstraint.KEYREF: {
+ case IdentityConstraint.IC_KEYREF: {
String code = "KeyRefNotEnoughValues";
KeyRef keyref = (KeyRef)fIdentityConstraint;
String ename = fIdentityConstraint.getElementName();
@@ -3244,7 +3245,7 @@
*/
public void reportNilError(IdentityConstraint id) {
- if (id.getType() == IdentityConstraint.KEY) {
+ if (id.getCategory() == IdentityConstraint.IC_KEY) {
String code = "KeyMatchesNillable";
reportSchemaError(code, new Object[]{id.getElementName()});
}
@@ -3623,8 +3624,8 @@
IdentityConstraint [] icArray = eDecl.fIDConstraints;
int icCount = eDecl.fIDCPos;
for (int i = 0; i < icCount; i++) {
- switch (icArray[i].getType()) {
- case (IdentityConstraint.UNIQUE):
+ switch (icArray[i].getCategory()) {
+ case (IdentityConstraint.IC_UNIQUE):
// initialize value stores for unique fields
UniqueOrKey unique = (UniqueOrKey)icArray[i];
UniqueValueStore uniqueValueStore = (UniqueValueStore)fIdentityConstraint2ValueStoreMap.get(unique);
@@ -3637,7 +3638,7 @@
fValueStores.addElement(uniqueValueStore);
fIdentityConstraint2ValueStoreMap.put(unique, uniqueValueStore);
break;
- case (IdentityConstraint.KEY):
+ case (IdentityConstraint.IC_KEY):
// initialize value stores for key fields
UniqueOrKey key = (UniqueOrKey)icArray[i];
KeyValueStore keyValueStore = (KeyValueStore)fIdentityConstraint2ValueStoreMap.get(key);
@@ -3650,7 +3651,7 @@
fValueStores.addElement(keyValueStore);
fIdentityConstraint2ValueStoreMap.put(key, keyValueStore);
break;
- case (IdentityConstraint.KEYREF):
+ case (IdentityConstraint.IC_KEYREF):
// initialize value stores for key reference fields
KeyRef keyRef = (KeyRef)icArray[i];
KeyRefValueStore keyRefValueStore = (KeyRefValueStore)fIdentityConstraint2ValueStoreMap.get(keyRef);
@@ -3687,7 +3688,7 @@
// hashtable, if id is a <unique> or a <key>.
// If it's a <keyRef>, then we leave it for later.
public void transplant(IdentityConstraint id) {
- if (id.getType() == IdentityConstraint.KEYREF) return;
+ if (id.getCategory() == IdentityConstraint.IC_KEYREF) return;
ValueStoreBase newVals = (ValueStoreBase)fIdentityConstraint2ValueStoreMap.get(id);
fIdentityConstraint2ValueStoreMap.remove(id);
ValueStoreBase currVals = (ValueStoreBase)fGlobalIDConstraintMap.get(id);
1.8 +86 -20 xml-xerces/java/src/org/apache/xerces/impl/xs/XSAttributeDecl.java
Index: XSAttributeDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSAttributeDecl.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XSAttributeDecl.java 7 May 2002 15:54:27 -0000 1.7
+++ XSAttributeDecl.java 16 May 2002 18:25:54 -0000 1.8
@@ -58,6 +58,7 @@
package org.apache.xerces.impl.xs;
import org.apache.xerces.impl.dv.XSSimpleType;
+import org.apache.xerces.impl.xs.psvi.*;
import org.apache.xerces.impl.dv.ValidatedInfo;
/**
@@ -66,14 +67,9 @@
*
* @author Elena Litani, IBM
* @author Sandy Gao, IBM
- * @version $Id: XSAttributeDecl.java,v 1.7 2002/05/07 15:54:27 sandygao Exp $
+ * @version $Id: XSAttributeDecl.java,v 1.8 2002/05/16 18:25:54 sandygao Exp $
*/
-public class XSAttributeDecl {
-
- // types of value constraint
- public final static short NO_CONSTRAINT = 0;
- public final static short DEFAULT_VALUE = 1;
- public final static short FIXED_VALUE = 2;
+public class XSAttributeDecl implements XSAttributeDeclaration {
// scopes
public final static short SCOPE_ABSENT = 0;
@@ -87,26 +83,18 @@
// the simple type of the attribute
public XSSimpleType fType = null;
// value constraint type: default, fixed or !specified
- short fMiscFlags = 0;
+ public short fConstraintType = XSConstants.VC_NONE;
// scope
- short fScope = SCOPE_ABSENT;
+ public short fScope = XSConstants.SCOPE_ABSENT;
// enclosing complex type, when the scope is local
XSComplexTypeDecl fEnclosingCT = null;
// value constraint value
public ValidatedInfo fDefault = null;
- // methods to get/set misc flag
-
- public short getConstraintType() {
- return fMiscFlags;
- }
- public boolean isGlobal() {
- return fScope == SCOPE_GLOBAL;
- }
-
public void setConstraintType(short constraintType) {
- fMiscFlags = constraintType;
+ fConstraintType = constraintType;
}
+
public void setIsGlobal() {
fScope = SCOPE_GLOBAL;
}
@@ -119,8 +107,86 @@
fName = null;
fTargetNamespace = null;
fType = null;
- fMiscFlags = 0;
+ fConstraintType = XSConstants.VC_NONE;
+ fScope = XSConstants.SCOPE_ABSENT;
fDefault = null;
}
+ /**
+ * Get the type of the object, i.e ELEMENT_DECLARATION.
+ */
+ public short getType() {
+ return XSConstants.ATTRIBUTE_DECLARATION;
+ }
+
+ /**
+ * The <code>name</code> of this <code>XSObject</code> depending on the
+ * <code>XSObject</code> type.
+ */
+ public String getName() {
+ return fName;
+ }
+
+ /**
+ * The namespace URI of this node, or <code>null</code> if it is
+ * unspecified. defines how a namespace URI is attached to schema
+ * components.
+ */
+ public String getNamespace() {
+ return fTargetNamespace;
+ }
+
+ /**
+ * A simple type definition
+ */
+ public XSSimpleTypeDefinition getTypeDefinition() {
+ return fType;
+ }
+
+ /**
+ * Optional. Either global or a complex type definition (
+ * <code>ctDefinition</code>). This property is absent in the case of
+ * declarations within attribute group definitions: their scope will be
+ * determined when they are used in the construction of complex type
+ * definitions.
+ */
+ public short getScope() {
+ return fScope;
+ }
+
+ /**
+ * Locally scoped declarations are available for use only within the
+ * complex type definition identified by the <code>scope</code>
+ * property.
+ */
+ public XSComplexTypeDefinition getEnclosingCTDefinition() {
+ return fEnclosingCT;
+ }
+
+ /**
+ * Value constraint: one of default, fixed.
+ */
+ public short getConstraintType() {
+ return fConstraintType;
+ }
+
+ /**
+ * Value constraint: The actual value (with respect to the {type
+ * definition}) Should we return Object instead of DOMString?
+ */
+ public String getConstraintValue() {
+ // REVISIT: SCAPI: what's the proper representation
+ return getConstraintType() == XSConstants.VC_NONE ?
+ null :
+ fDefault.normalizedValue;
+ }
+
+ /**
+ * Optional. Annotation.
+ */
+ public XSAnnotation getAnnotation() {
+ // REVISIT: SCAPI: to implement
+ return null;
+ }
+
} // class XSAttributeDecl
1.9 +64 -26 xml-xerces/java/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java
Index: XSAttributeGroupDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XSAttributeGroupDecl.java 8 Apr 2002 19:54:15 -0000 1.8
+++ XSAttributeGroupDecl.java 16 May 2002 18:25:54 -0000 1.9
@@ -57,6 +57,8 @@
package org.apache.xerces.impl.xs;
+import org.apache.xerces.impl.xs.psvi.*;
+import org.apache.xerces.impl.xs.util.XSObjectListImpl;
import org.apache.xerces.impl.dv.ValidatedInfo;
/**
@@ -66,9 +68,9 @@
* @author Sandy Gao, IBM
* @author Rahul Srivastava, Sun Microsystems Inc.
*
- * @version $Id: XSAttributeGroupDecl.java,v 1.8 2002/04/08 19:54:15 sandygao Exp $
+ * @version $Id: XSAttributeGroupDecl.java,v 1.9 2002/05/16 18:25:54 sandygao Exp $
*/
-public class XSAttributeGroupDecl {
+public class XSAttributeGroupDecl implements XSAttributeGroupDefinition {
// name of the attribute group
public String fName = null;
@@ -78,7 +80,7 @@
int fAttrUseNum = 0;
// attribute uses included by this attribute group
private static final int INITIAL_SIZE = 5;
- XSAttributeUse[] fAttributeUses = new XSAttributeUse[INITIAL_SIZE];
+ XSAttributeUseImpl[] fAttributeUses = new XSAttributeUseImpl[INITIAL_SIZE];
// attribute wildcard included by this attribute group
public XSWildcardDecl fAttributeWC = null;
// whether there is an attribute use whose type is or is derived from ID.
@@ -88,7 +90,7 @@
// if the type is derived from ID, but there is already another attribute
// use of type ID, then return the name of the other attribute use;
// otherwise, return null
- public String addAttributeUse(XSAttributeUse attrUse) {
+ public String addAttributeUse(XSAttributeUseImpl attrUse) {
if (fAttrUseNum == fAttributeUses.length) {
fAttributeUses = resize(fAttributeUses, fAttrUseNum*2);
@@ -110,7 +112,7 @@
return null;
}
- public XSAttributeUse getAttributeUse(String uri, String localpart) {
+ public XSAttributeUseImpl getAttributeUse(String uri, String localpart) {
for (int i=0; i<fAttrUseNum; i++) {
if ( (fAttributeUses[i].fAttrDecl.fTargetNamespace == uri) &&
(fAttributeUses[i].fAttrDecl.fName == localpart) )
@@ -123,7 +125,7 @@
public void removeProhibitedAttrs() {
if (fAttrUseNum == 0) return;
int pCount = 0;
- XSAttributeUse[] pUses = new XSAttributeUse[fAttrUseNum];
+ XSAttributeUseImpl[] pUses = new XSAttributeUseImpl[fAttrUseNum];
for (int i = 0; i < fAttrUseNum; i++) {
if (fAttributeUses[i].fUse == SchemaSymbols.USE_PROHIBITED) {
pCount++;
@@ -152,24 +154,14 @@
}
}
- public XSAttributeUse[] getAttributeUses() {
- if (fAttrUseNum == 0) {
- return null;
- }
- if (fAttrUseNum < fAttributeUses.length) {
- fAttributeUses = resize(fAttributeUses, fAttrUseNum);
- }
- return fAttributeUses;
- }
-
// Check that the attributes in this group validly restrict those from a base group
// If an error is found, the error code is returned.
public String validRestrictionOf(XSAttributeGroupDecl baseGroup) {
String errorCode = null;
- XSAttributeUse attrUse = null;
+ XSAttributeUseImpl attrUse = null;
XSAttributeDecl attrDecl = null;
- XSAttributeUse baseAttrUse = null;
+ XSAttributeUseImpl baseAttrUse = null;
XSAttributeDecl baseAttrDecl = null;
for (int i=0; i<fAttrUseNum; i++) {
@@ -203,7 +195,7 @@
//
if (! XSConstraints.checkSimpleDerivationOk(attrDecl.fType,
baseAttrDecl.fType,
- baseAttrDecl.fType.getFinalSet()) ) {
+ baseAttrDecl.fType.getFinal()) ) {
errorCode="derivation-ok-restriction.2.1.2";
return errorCode;
}
@@ -212,14 +204,14 @@
//
// derivation-ok-restriction. Constraint 2.1.3
//
- int baseConsType=baseAttrUse.fConstraintType!=XSAttributeDecl.NO_CONSTRAINT?
+ int baseConsType=baseAttrUse.fConstraintType!=XSConstants.VC_NONE?
baseAttrUse.fConstraintType:baseAttrDecl.getConstraintType();
- int thisConstType = attrUse.fConstraintType!=XSAttributeDecl.NO_CONSTRAINT?
+ int thisConstType = attrUse.fConstraintType!=XSConstants.VC_NONE?
attrUse.fConstraintType:attrDecl.getConstraintType();
- if (baseConsType == XSAttributeDecl.FIXED_VALUE) {
+ if (baseConsType == XSConstants.VC_FIXED) {
- if (thisConstType != XSAttributeDecl.FIXED_VALUE) {
+ if (thisConstType != XSConstants.VC_FIXED) {
errorCode="derivation-ok-restriction.2.1.3";
return errorCode;
} else {
@@ -265,7 +257,7 @@
baseAttrDecl = baseAttrUse.fAttrDecl;
// Look for a match in this group
- XSAttributeUse thisAttrUse = getAttributeUse(
+ XSAttributeUseImpl thisAttrUse = getAttributeUse(
baseAttrDecl.fTargetNamespace,baseAttrDecl.fName);
if (thisAttrUse == null) {
errorCode = "derivation-ok-restriction.3";
@@ -294,8 +286,8 @@
}
- static final XSAttributeUse[] resize(XSAttributeUse[] oldArray, int newSize) {
- XSAttributeUse[] newArray = new XSAttributeUse[newSize];
+ static final XSAttributeUseImpl[] resize(XSAttributeUseImpl[] oldArray, int newSize) {
+ XSAttributeUseImpl[] newArray = new XSAttributeUseImpl[newSize];
System.arraycopy(oldArray, 0, newArray, 0, Math.min(oldArray.length, newSize));
return newArray;
}
@@ -314,4 +306,50 @@
}
+ /**
+ * Get the type of the object, i.e ELEMENT_DECLARATION.
+ */
+ public short getType() {
+ return XSConstants.ATTRIBUTE_GROUP;
+ }
+
+ /**
+ * The <code>name</code> of this <code>XSObject</code> depending on the
+ * <code>XSObject</code> type.
+ */
+ public String getName() {
+ return fName;
+ }
+
+ /**
+ * The namespace URI of this node, or <code>null</code> if it is
+ * unspecified. defines how a namespace URI is attached to schema
+ * components.
+ */
+ public String getNamespace() {
+ return fTargetNamespace;
+ }
+
+ /**
+ * {attribute uses} A set of attribute uses.
+ */
+ public XSObjectList getAttributeUses() {
+ return new XSObjectListImpl(fAttributeUses, fAttrUseNum);
+ }
+
+ /**
+ * {attribute wildcard} Optional. A wildcard.
+ */
+ public XSWildcard getAttributeWildcard() {
+ return fAttributeWC;
+ }
+
+ /**
+ * Optional. Annotation.
+ */
+ public XSAnnotation getAnnotation() {
+ // REVISIT: SCAPI: to implement
+ return null;
+ }
+
} // class XSAttributeGroupDecl
1.9 +166 -34 xml-xerces/java/src/org/apache/xerces/impl/xs/XSComplexTypeDecl.java
Index: XSComplexTypeDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSComplexTypeDecl.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XSComplexTypeDecl.java 10 Apr 2002 20:18:09 -0000 1.8
+++ XSComplexTypeDecl.java 16 May 2002 18:25:54 -0000 1.9
@@ -58,6 +58,7 @@
package org.apache.xerces.impl.xs;
import org.apache.xerces.impl.dv.XSSimpleType;
+import org.apache.xerces.impl.xs.psvi.*;
import org.apache.xerces.impl.xs.models.XSCMValidator;
import org.apache.xerces.impl.xs.models.CMBuilder;
@@ -67,15 +68,9 @@
*
* @author Elena Litani, IBM
* @author Sandy Gao, IBM
- * @version $Id: XSComplexTypeDecl.java,v 1.8 2002/04/10 20:18:09 sandygao Exp $
+ * @version $Id: XSComplexTypeDecl.java,v 1.9 2002/05/16 18:25:54 sandygao Exp $
*/
-public class XSComplexTypeDecl implements XSTypeDecl {
-
- // content types of complextype
- public static final short CONTENTTYPE_EMPTY = 0;
- public static final short CONTENTTYPE_SIMPLE = 1;
- public static final short CONTENTTYPE_MIXED = 2;
- public static final short CONTENTTYPE_ELEMENT = 3;
+public class XSComplexTypeDecl implements XSTypeDecl, XSComplexTypeDefinition {
// name of the complexType
public String fName = null;
@@ -87,13 +82,13 @@
public XSTypeDecl fBaseType = null;
// derivation method of the complexType
- public short fDerivedBy = SchemaSymbols.RESTRICTION;
+ public short fDerivedBy = XSConstants.DERIVATION_RESTRICTION;
// final set of the complexType
- public short fFinal = SchemaSymbols.EMPTY_SET;
+ public short fFinal = XSConstants.DERIVATION_NONE;
// block set (prohibited substitution) of the complexType
- public short fBlock = SchemaSymbols.EMPTY_SET;
+ public short fBlock = XSConstants.DERIVATION_NONE;
// flags: whether is abstract; whether contains ID type;
// whether it's an anonymous tpye
@@ -114,7 +109,7 @@
// if there is a particle, the content model corresponding to that particle
public XSCMValidator fCMValidator = null;
- public short getXSType () {
+ public short getTypeCategory() {
return COMPLEX_TYPE;
}
@@ -130,10 +125,6 @@
return fTargetNamespace;
}
- public XSTypeDecl getBaseType(){
- return fBaseType;
- }
-
// flags for the misc flag
private static final short CT_IS_ABSTRACT = 1;
private static final short CT_HAS_TYPE_ID = 2;
@@ -141,15 +132,9 @@
// methods to get/set misc flag
- public boolean isAbstractType() {
- return((fMiscFlags & CT_IS_ABSTRACT) != 0);
- }
public boolean containsTypeID () {
return((fMiscFlags & CT_HAS_TYPE_ID) != 0);
}
- public boolean isAnonymous() {
- return((fMiscFlags & CT_IS_ANONYMOUS) != 0);
- }
public void setIsAbstractType() {
fMiscFlags |= CT_IS_ABSTRACT;
@@ -169,7 +154,6 @@
}
public String toString() {
-
StringBuffer str = new StringBuffer();
appendTypeInfo(str);
return str.toString();
@@ -181,10 +165,10 @@
str.append("Complex type name='" + fTargetNamespace + "," + getTypeName() + "', ");
if (fBaseType != null)
- str.append(" base type name='" + fBaseType.getTypeName() + "', ");
+ str.append(" base type name='" + fBaseType.getName() + "', ");
str.append(" content type='" + contentType[fContentType] + "', ");
- str.append(" isAbstract='" + isAbstractType() + "', ");
+ str.append(" isAbstract='" + getIsAbstract() + "', ");
str.append(" hasTypeId='" + containsTypeID() + "', ");
str.append(" final='" + fFinal + "', ");
str.append(" block='" + fBlock + "', ");
@@ -194,7 +178,7 @@
}
- public boolean derivedFrom(XSTypeDecl ancestor) {
+ public boolean derivedFrom(XSTypeDefinition ancestor) {
// ancestor is null, retur false
if (ancestor == null)
return false;
@@ -202,7 +186,7 @@
if (ancestor == SchemaGrammar.fAnyType)
return true;
// recursively get base, and compare it with ancestor
- XSTypeDecl type = this;
+ XSTypeDefinition type = this;
while (type != ancestor && // compare with ancestor
type != SchemaGrammar.fAnySimpleType && // reached anySimpleType
type != SchemaGrammar.fAnyType) { // reached anyType
@@ -225,12 +209,12 @@
// recursively get base, and compare it with ancestor
XSTypeDecl type = this;
- while (!(ancestorName.equals(type.getTypeName()) &&
- ((ancestorNS == null && type.getTargetNamespace() == null) ||
- (ancestorNS != null && ancestorNS.equals(type.getTargetNamespace())))) && // compare with ancestor
+ while (!(ancestorName.equals(type.getName()) &&
+ ((ancestorNS == null && type.getNamespace() == null) ||
+ (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) && // compare with ancestor
type != SchemaGrammar.fAnySimpleType && // reached anySimpleType
type != SchemaGrammar.fAnyType) { // reached anyType
- type = type.getBaseType();
+ type = (XSTypeDecl)type.getBaseType();
}
return type != SchemaGrammar.fAnySimpleType &&
@@ -241,9 +225,9 @@
fName = null;
fTargetNamespace = null;
fBaseType = null;
- fDerivedBy = SchemaSymbols.RESTRICTION;
- fFinal = SchemaSymbols.EMPTY_SET;
- fBlock = SchemaSymbols.EMPTY_SET;
+ fDerivedBy = XSConstants.DERIVATION_RESTRICTION;
+ fFinal = XSConstants.DERIVATION_NONE;
+ fBlock = XSConstants.DERIVATION_NONE;
fMiscFlags = 0;
@@ -255,4 +239,152 @@
fCMValidator = null;
}
+ /**
+ * Get the type of the object, i.e ELEMENT_DECLARATION.
+ */
+ public short getType() {
+ return XSConstants.TYPE_DEFINITION;
+ }
+
+ /**
+ * The <code>name</code> of this <code>XSObject</code> depending on the
+ * <code>XSObject</code> type.
+ */
+ public String getName() {
+ return fName;
+ }
+
+ /**
+ * A boolean that specifies if the type definition is anonymous.
+ * Convenience attribute. This is a field is not part of
+ * XML Schema component model.
+ */
+ public boolean getIsAnonymous() {
+ return((fMiscFlags & CT_IS_ANONYMOUS) != 0);
+ }
+
+ /**
+ * The namespace URI of this node, or <code>null</code> if it is
+ * unspecified. defines how a namespace URI is attached to schema
+ * components.
+ */
+ public String getNamespace() {
+ return fTargetNamespace;
+ }
+
+ /**
+ * {base type definition} Either a simple type definition or a complex
+ * type definition.
+ */
+ public XSTypeDefinition getBaseType() {
+ return fBaseType;
+ }
+
+ /**
+ * {derivation method} Either extension or restriction. The valid constant
+ * value for this <code>XSConstants</code> EXTENTION, RESTRICTION.
+ */
+ public short getDerivationMethod() {
+ return fDerivedBy;
+ }
+
+ /**
+ * {final} For complex type definition it is a subset of {extension,
+ * restriction}. For simple type definition it is a subset of
+ * {extension, list, restriction, union}.
+ * @param derivation Extension, restriction, list, union constants
+ * (defined in <code>XSConstants</code>).
+ * @return True if derivation is in the final set, otherwise false.
+ */
+ public boolean getIsFinal(short derivation) {
+ return (fFinal & derivation) != 0;
+ }
+
+ /**
+ * {final} For complex type definition it is a subset of {extension, restriction}.
+ *
+ * @return A bit flag that represents:
+ * {extension, restriction) or none for complexTypes;
+ * {extension, list, restriction, union} or none for simpleTypes;
+ */
+ public short getFinal() {
+ return fFinal;
+ }
+
+ /**
+ * {abstract} A boolean. Complex types for which {abstract} is true must
+ * not be used as the {type definition} for the validation of element
+ * information items.
+ */
+ public boolean getIsAbstract() {
+ return((fMiscFlags & CT_IS_ABSTRACT) != 0);
+ }
+
+ /**
+ * {attribute uses} A set of attribute uses.
+ */
+ public XSObjectList getAttributeUses() {
+ return fAttrGrp.getAttributeUses();
+ }
+
+ /**
+ * {attribute wildcard} Optional. A wildcard.
+ */
+ public XSWildcard getAttributeWildcard() {
+ return fAttrGrp.getAttributeWildcard();
+ }
+
+ /**
+ * {content type} One of empty, a simple type definition (see
+ * <code>simpleType</code>, or mixed, element-only (see
+ * <code>cmParticle</code>).
+ */
+ public short getContentType() {
+ return fContentType;
+ }
+
+ /**
+ * A simple type definition corresponding to simple content model,
+ * otherwise <code>null</code>
+ */
+ public XSSimpleTypeDefinition getSimpleType() {
+ return fXSSimpleType;
+ }
+
+ /**
+ * A particle for mixed or element-only content model, otherwise
+ * <code>null</code>
+ */
+ public XSParticle getParticle() {
+ return fParticle;
+ }
+
+ /**
+ * {prohibited substitutions} A subset of {extension, restriction}.
+ * @param prohibited extention or restriction constants (defined in
+ * <code>XSConstants</code>).
+ * @return True if prohibited is a prohibited substitution, otherwise
+ * false.
+ */
+ public boolean getIsProhibitedSubstitution(short prohibited) {
+ return (fBlock & prohibited) != 0;
+ }
+
+ /**
+ * {prohibited substitutions}
+ *
+ * @return A bit flag corresponding to prohibited substitutions
+ */
+ public short getProhibitedSubstitutions() {
+ return fBlock;
+ }
+
+ /**
+ * Optional. Annotation.
+ */
+ public XSObjectList getAnnotations() {
+ // REVISIT: SCAPI: to implement
+ return null;
+ }
+
} // class XSComplexTypeDecl
1.21 +58 -57 xml-xerces/java/src/org/apache/xerces/impl/xs/XSConstraints.java
Index: XSConstraints.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSConstraints.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- XSConstraints.java 26 Apr 2002 22:03:42 -0000 1.20
+++ XSConstraints.java 16 May 2002 18:25:54 -0000 1.21
@@ -58,13 +58,14 @@
package org.apache.xerces.impl.xs;
import org.apache.xerces.impl.dv.XSSimpleType;
-import org.apache.xerces.impl.dv.XSUnionSimpleType;
import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
import org.apache.xerces.impl.dv.ValidatedInfo;
import org.apache.xerces.impl.XMLErrorReporter;
import org.apache.xerces.impl.xs.models.CMBuilder;
import org.apache.xerces.impl.xs.models.XSCMValidator;
import org.apache.xerces.impl.xs.util.SimpleLocator;
+import org.apache.xerces.impl.xs.psvi.XSConstants;
+import org.apache.xerces.impl.xs.psvi.XSObjectList;
import org.apache.xerces.impl.validation.ValidationContext;
import org.apache.xerces.util.SymbolHash;
import java.util.Vector;
@@ -74,7 +75,7 @@
*
* @author Sandy Gao, IBM
*
- * @version $Id: XSConstraints.java,v 1.20 2002/04/26 22:03:42 sandygao Exp $
+ * @version $Id: XSConstraints.java,v 1.21 2002/05/16 18:25:54 sandygao Exp $
*/
public class XSConstraints {
@@ -97,9 +98,9 @@
}
// if derived is simple type
- if (derived.getXSType() == XSTypeDecl.SIMPLE_TYPE) {
+ if (derived.getTypeCategory() == XSTypeDecl.SIMPLE_TYPE) {
// if base is complex type
- if (base.getXSType() == XSTypeDecl.COMPLEX_TYPE) {
+ if (base.getTypeCategory() == XSTypeDecl.COMPLEX_TYPE) {
// if base is anyType, change base to anySimpleType,
// otherwise, not valid
if (base == SchemaGrammar.fAnyType)
@@ -127,7 +128,7 @@
}
// if base is complex type
- if (base.getXSType() == XSTypeDecl.COMPLEX_TYPE) {
+ if (base.getTypeCategory() == XSTypeDecl.COMPLEX_TYPE) {
// if base is anyType, change base to anySimpleType,
// otherwise, not valid
if (base == SchemaGrammar.fAnyType)
@@ -162,8 +163,8 @@
// 2 All of the following must be true:
// 2.1 restriction is not in the subset, or in the {final} of its own {base type definition};
- if ((block & SchemaSymbols.RESTRICTION) != 0 ||
- (derived.getBaseType().getFinalSet() & SchemaSymbols.RESTRICTION) != 0) {
+ if ((block & XSConstants.DERIVATION_RESTRICTION) != 0 ||
+ (derived.getBaseType().getFinal() & XSConstants.DERIVATION_RESTRICTION) != 0) {
return false;
}
@@ -188,10 +189,10 @@
// 2.2.4 B's {variety} is union and D is validly derived from a type definition in B's {member type definitions} given the subset, as defined by this constraint.
if (base.getVariety() == XSSimpleType.VARIETY_UNION) {
- XSSimpleType[] subUnionMemberDV = ((XSUnionSimpleType)base).getMemberTypes();
- int subUnionSize = subUnionMemberDV.length ;
+ XSObjectList subUnionMemberDV = base.getMemberTypes();
+ int subUnionSize = subUnionMemberDV.getListLength();
for (int i=0; i<subUnionSize; i++) {
- base = subUnionMemberDV[i];
+ base = (XSSimpleType)subUnionMemberDV.getItem(i);
if (checkSimpleDerivation(derived, base, block))
return true;
}
@@ -229,13 +230,13 @@
// 2.3.2 The appropriate case among the following must be true:
// 2.3.2.1 If D's {base type definition} is complex, then it must be validly derived from B given the subset as defined by this constraint.
- if (directBase.getXSType() == XSTypeDecl.COMPLEX_TYPE)
+ if (directBase.getTypeCategory() == XSTypeDecl.COMPLEX_TYPE)
return checkComplexDerivation((XSComplexTypeDecl)directBase, base, block);
// 2.3.2.2 If D's {base type definition} is simple, then it must be validly derived from B given the subset as defined in Type Derivation OK (Simple) (3.14.6).
- if (directBase.getXSType() == XSTypeDecl.SIMPLE_TYPE) {
+ if (directBase.getTypeCategory() == XSTypeDecl.SIMPLE_TYPE) {
// if base is complex type
- if (base.getXSType() == XSTypeDecl.COMPLEX_TYPE) {
+ if (base.getTypeCategory() == XSTypeDecl.COMPLEX_TYPE) {
// if base is anyType, change base to anySimpleType,
// otherwise, not valid
if (base == SchemaGrammar.fAnyType)
@@ -262,7 +263,7 @@
// e-props-correct
// For a string to be a valid default with respect to a type definition the appropriate case among the following must be true:
// 1 If the type definition is a simple type definition, then the string must be valid with respect to that definition as defined by String Valid (3.14.4).
- if (type.getXSType() == XSTypeDecl.SIMPLE_TYPE) {
+ if (type.getTypeCategory() == XSTypeDecl.SIMPLE_TYPE) {
dv = (XSSimpleType)type;
}
@@ -349,9 +350,9 @@
SimpleLocator [] rgLocators = grammars[g].getRGLocators();
for(int i=0; i<redefinedGroups.length; ) {
XSGroupDecl derivedGrp = redefinedGroups[i++];
- XSModelGroup derivedMG = derivedGrp.fModelGroup;
+ XSModelGroupImpl derivedMG = derivedGrp.fModelGroup;
XSGroupDecl baseGrp = redefinedGroups[i++];
- XSModelGroup baseMG = baseGrp.fModelGroup;
+ XSModelGroupImpl baseMG = baseGrp.fModelGroup;
if(baseMG == null) {
if(derivedMG != null) { // can't be a restriction!
reportSchemaError(errorReporter, rgLocators[i/2-1],
@@ -420,7 +421,7 @@
// 2. Particle Derivation
if (types[j].fBaseType != null &&
types[j].fBaseType != SchemaGrammar.fAnyType &&
- types[j].fDerivedBy == SchemaSymbols.RESTRICTION &&
+ types[j].fDerivedBy == XSConstants.DERIVATION_RESTRICTION &&
types[j].fParticle !=null &&
(types[j].fBaseType instanceof XSComplexTypeDecl) &&
((XSComplexTypeDecl)(types[j].fBaseType)).fParticle != null) {
@@ -502,7 +503,7 @@
XSElementDecl elem = (XSElementDecl)(particle.fValue);
findElemInTable(type, elem, elemDeclHash);
- if (elem.isGlobal()) {
+ if (elem.fScope == XSConstants.SCOPE_GLOBAL) {
// Check for subsitution groups.
XSElementDecl[] subGroup = sgHandler.getSubstitutionGroup(elem);
for (int i = 0; i < subGroup.length; i++) {
@@ -512,7 +513,7 @@
return;
}
- XSModelGroup group = (XSModelGroup)particle.fValue;
+ XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
for (int i = 0; i < group.fParticleCount; i++)
checkElementDeclsConsistent(type, group.fParticles[i], elemDeclHash, sgHandler);
}
@@ -586,7 +587,7 @@
// Handle pointless groups for the derived particle
//
if (dType == XSParticleDecl.PARTICLE_MODELGROUP) {
- dType = ((XSModelGroup)dParticle.fValue).fCompositor;
+ dType = ((XSModelGroupImpl)dParticle.fValue).fCompositor;
// Find a group, starting with this particle, with more than 1 child. There
// may be none, and the particle of interest trivially becomes an element or
@@ -597,7 +598,7 @@
dParticle = dtmp;
dType = dParticle.fType;
if (dType == XSParticleDecl.PARTICLE_MODELGROUP)
- dType = ((XSModelGroup)dParticle.fValue).fCompositor;
+ dType = ((XSModelGroupImpl)dParticle.fValue).fCompositor;
}
// Fill in a vector with the children of the particle, removing any
@@ -614,7 +615,7 @@
if (dSGHandler != null && dType == XSParticleDecl.PARTICLE_ELEMENT) {
XSElementDecl dElement = (XSElementDecl)dParticle.fValue;
- if (dElement.isGlobal()) {
+ if (dElement.fScope == XSConstants.SCOPE_GLOBAL) {
// 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
@@ -622,7 +623,7 @@
if (subGroup.length >0 ) {
// Now, set the type to be CHOICE. The "group" will have the same
// occurrence information as the original particle.
- dType = XSModelGroup.MODELGROUP_CHOICE;
+ dType = XSModelGroupImpl.MODELGROUP_CHOICE;
dMinEffectiveTotalRange = dMinOccurs;
dMaxEffectiveTotalRange = dMaxOccurs;
@@ -645,7 +646,7 @@
// Handle pointless groups for the base particle
//
if (bType == XSParticleDecl.PARTICLE_MODELGROUP) {
- bType = ((XSModelGroup)bParticle.fValue).fCompositor;
+ bType = ((XSModelGroupImpl)bParticle.fValue).fCompositor;
// Find a group, starting with this particle, with more than 1 child. There
// may be none, and the particle of interest trivially becomes an element or
@@ -656,7 +657,7 @@
bParticle = btmp;
bType = bParticle.fType;
if (bType == XSParticleDecl.PARTICLE_MODELGROUP)
- bType = ((XSModelGroup)bParticle.fValue).fCompositor;
+ bType = ((XSModelGroupImpl)bParticle.fValue).fCompositor;
}
// Fill in a vector with the children of the particle, removing any
@@ -670,14 +671,14 @@
if (bSGHandler != null && bType == XSParticleDecl.PARTICLE_ELEMENT) {
XSElementDecl bElement = (XSElementDecl)bParticle.fValue;
- if (bElement.isGlobal()) {
+ if (bElement.fScope == XSConstants.SCOPE_GLOBAL) {
// 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);
if (bsubGroup.length >0 ) {
// Now, set the type to be CHOICE
- bType = XSModelGroup.MODELGROUP_CHOICE;
+ bType = XSModelGroupImpl.MODELGROUP_CHOICE;
bChildren = new Vector(bsubGroup.length+1);
for (int i = 0; i < bsubGroup.length; i++) {
@@ -717,7 +718,7 @@
}
// Elt:All RecurseAsIfGroup
- case XSModelGroup.MODELGROUP_CHOICE:
+ case XSModelGroupImpl.MODELGROUP_CHOICE:
{
// Treat the element as if it were in a group of the same type
// as the base Particle
@@ -728,8 +729,8 @@
bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
return;
}
- case XSModelGroup.MODELGROUP_SEQUENCE:
- case XSModelGroup.MODELGROUP_ALL:
+ case XSModelGroupImpl.MODELGROUP_SEQUENCE:
+ case XSModelGroupImpl.MODELGROUP_ALL:
{
// Treat the element as if it were in a group of the same type
// as the base Particle
@@ -761,9 +762,9 @@
return;
}
- case XSModelGroup.MODELGROUP_CHOICE:
- case XSModelGroup.MODELGROUP_SEQUENCE:
- case XSModelGroup.MODELGROUP_ALL:
+ case XSModelGroupImpl.MODELGROUP_CHOICE:
+ case XSModelGroupImpl.MODELGROUP_SEQUENCE:
+ case XSModelGroupImpl.MODELGROUP_ALL:
case XSParticleDecl.PARTICLE_ELEMENT:
{
throw new XMLSchemaException("cos-particle-restrict.2",
@@ -778,7 +779,7 @@
}
}
- case XSModelGroup.MODELGROUP_ALL:
+ case XSModelGroupImpl.MODELGROUP_ALL:
{
switch (bType) {
@@ -799,15 +800,15 @@
return;
}
- case XSModelGroup.MODELGROUP_ALL:
+ case XSModelGroupImpl.MODELGROUP_ALL:
{
checkRecurse(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
return;
}
- case XSModelGroup.MODELGROUP_CHOICE:
- case XSModelGroup.MODELGROUP_SEQUENCE:
+ case XSModelGroupImpl.MODELGROUP_CHOICE:
+ case XSModelGroupImpl.MODELGROUP_SEQUENCE:
case XSParticleDecl.PARTICLE_ELEMENT:
{
throw new XMLSchemaException("cos-particle-restrict.2",
@@ -822,7 +823,7 @@
}
}
- case XSModelGroup.MODELGROUP_CHOICE:
+ case XSModelGroupImpl.MODELGROUP_CHOICE:
{
switch (bType) {
@@ -842,15 +843,15 @@
return;
}
- case XSModelGroup.MODELGROUP_CHOICE:
+ case XSModelGroupImpl.MODELGROUP_CHOICE:
{
checkRecurseLax(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
return;
}
- case XSModelGroup.MODELGROUP_ALL:
- case XSModelGroup.MODELGROUP_SEQUENCE:
+ case XSModelGroupImpl.MODELGROUP_ALL:
+ case XSModelGroupImpl.MODELGROUP_SEQUENCE:
case XSParticleDecl.PARTICLE_ELEMENT:
{
throw new XMLSchemaException("cos-particle-restrict.2",
@@ -866,7 +867,7 @@
}
- case XSModelGroup.MODELGROUP_SEQUENCE:
+ case XSModelGroupImpl.MODELGROUP_SEQUENCE:
{
switch (bType) {
@@ -886,21 +887,21 @@
return;
}
- case XSModelGroup.MODELGROUP_ALL:
+ case XSModelGroupImpl.MODELGROUP_ALL:
{
checkRecurseUnordered(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
return;
}
- case XSModelGroup.MODELGROUP_SEQUENCE:
+ case XSModelGroupImpl.MODELGROUP_SEQUENCE:
{
checkRecurse(dChildren, dMinOccurs, dMaxOccurs, dSGHandler,
bChildren, bMinOccurs, bMaxOccurs, bSGHandler);
return;
}
- case XSModelGroup.MODELGROUP_CHOICE:
+ case XSModelGroupImpl.MODELGROUP_CHOICE:
{
int min1 = dMinOccurs * dChildren.size();
int max1 = (dMaxOccurs == SchemaSymbols.OCCURRENCE_UNBOUNDED)?
@@ -943,8 +944,8 @@
return p;
if (p.fMinOccurs==1 && p.fMaxOccurs==1 &&
- p.fValue!=null && ((XSModelGroup)p.fValue).fParticleCount == 1)
- return getNonUnaryGroup(((XSModelGroup)p.fValue).fParticles[0]);
+ p.fValue!=null && ((XSModelGroupImpl)p.fValue).fParticleCount == 1)
+ return getNonUnaryGroup(((XSModelGroupImpl)p.fValue).fParticles[0]);
else
return p;
}
@@ -959,7 +960,7 @@
Vector children = new Vector();
- XSModelGroup group = (XSModelGroup)p.fValue;
+ XSModelGroupImpl group = (XSModelGroupImpl)p.fValue;
for (int i = 0; i < group.fParticleCount; i++)
gatherChildren(group.fCompositor, group.fParticles[i], children);
@@ -973,7 +974,7 @@
int max = p.fMaxOccurs;
int type = p.fType;
if (type == XSParticleDecl.PARTICLE_MODELGROUP)
- type = ((XSModelGroup)p.fValue).fCompositor;
+ type = ((XSModelGroupImpl)p.fValue).fCompositor;
if (type == XSParticleDecl.PARTICLE_EMPTY)
return;
@@ -988,7 +989,7 @@
children.addElement(p);
}
else if (parentType == type) {
- XSModelGroup group = (XSModelGroup)p.fValue;
+ XSModelGroupImpl group = (XSModelGroupImpl)p.fValue;
for (int i = 0; i < group.fParticleCount; i++)
gatherChildren(type, group.fParticles[i], children);
}
@@ -1016,7 +1017,7 @@
//
// Check nillable
//
- if (! (bElement.isNillable() || !dElement.isNillable())) {
+ if (! (bElement.getIsNillable() || !dElement.getIsNillable())) {
throw new XMLSchemaException("rcase-NameAndTypeOK.2",
new Object[]{dElement.fName});
}
@@ -1032,16 +1033,16 @@
//
// Check for consistent fixed values
//
- if (bElement.getConstraintType() == XSElementDecl.FIXED_VALUE) {
+ if (bElement.getConstraintType() == XSConstants.VC_FIXED) {
// derived one has to have a fixed value
- if (dElement.getConstraintType() != XSElementDecl.FIXED_VALUE) {
+ if (dElement.getConstraintType() != XSConstants.VC_FIXED) {
throw new XMLSchemaException("rcase-NameAndTypeOK.4",
new Object[]{dElement.fName});
}
// get simple type
XSSimpleType dv = null;
- if (dElement.fType.getXSType() == XSTypeDecl.SIMPLE_TYPE)
+ if (dElement.fType.getTypeCategory() == XSTypeDecl.SIMPLE_TYPE)
dv = (XSSimpleType)dElement.fType;
else if (((XSComplexTypeDecl)dElement.fType).fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE)
dv = ((XSComplexTypeDecl)dElement.fType).fXSSimpleType;
@@ -1065,7 +1066,7 @@
int blockSet1 = dElement.fBlock;
int blockSet2 = bElement.fBlock;
if (((blockSet1 & blockSet2)!=blockSet2) ||
- (blockSet1==SchemaSymbols.EMPTY_SET && blockSet2!=SchemaSymbols.EMPTY_SET))
+ (blockSet1==XSConstants.DERIVATION_NONE && blockSet2!=XSConstants.DERIVATION_NONE))
throw new XMLSchemaException("rcase-NameAndTypeOK.6",
new Object[]{dElement.fName});
@@ -1074,7 +1075,7 @@
// Check that the derived element's type is derived from the base's.
//
if (!checkTypeDerivationOk(dElement.fType, bElement.fType,
- (short)(SchemaSymbols.EXTENSION|SchemaSymbols.LIST|SchemaSymbols.UNION))) {
+ (short)(XSConstants.DERIVATION_EXTENSION|XSConstants.DERIVATION_LIST|XSConstants.DERIVATION_UNION))) {
throw new XMLSchemaException("rcase-NameAndTypeOK.7",
new Object[]{dElement.fName});
}
@@ -1390,7 +1391,7 @@
// if the intersection of the two wildcard is not empty list
XSWildcardDecl intersect = wildcard1.performIntersectionWith(wildcard2, wildcard1.fProcessContents);
if (intersect == null ||
- intersect.fType != XSWildcardDecl.WILDCARD_LIST ||
+ intersect.fType != XSWildcardDecl.NSCONSTRAINT_LIST ||
intersect.fNamespaceList.length != 0) {
return true;
}
1.6 +13 -13 xml-xerces/java/src/org/apache/xerces/impl/xs/XSDeclarationPool.java
Index: XSDeclarationPool.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSDeclarationPool.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XSDeclarationPool.java 26 Apr 2002 22:03:42 -0000 1.5
+++ XSDeclarationPool.java 16 May 2002 18:25:54 -0000 1.6
@@ -67,7 +67,7 @@
* Note: The cashing mechanism is not implemented yet.
*
* @author Elena Litani, IBM
- * @version $Id: XSDeclarationPool.java,v 1.5 2002/04/26 22:03:42 sandygao Exp $
+ * @version $Id: XSDeclarationPool.java,v 1.6 2002/05/16 18:25:54 sandygao Exp $
*/
public final class XSDeclarationPool {
/** Chunk shift (8). */
@@ -91,7 +91,7 @@
private int fParticleDeclIndex = 0;
/** Particle declaration pool */
- private XSModelGroup fModelGroup[][] = new XSModelGroup[INITIAL_CHUNK_COUNT][];
+ private XSModelGroupImpl fModelGroup[][] = new XSModelGroupImpl[INITIAL_CHUNK_COUNT][];
private int fModelGroupIndex = 0;
/** Attribute declaration pool */
@@ -107,7 +107,7 @@
private int fSTDeclIndex = 0;
/** AttributeUse declaration pool */
- private XSAttributeUse fAttributeUse[][] = new XSAttributeUse[INITIAL_CHUNK_COUNT][];
+ private XSAttributeUseImpl fAttributeUse[][] = new XSAttributeUseImpl[INITIAL_CHUNK_COUNT][];
private int fAttributeUseIndex = 0;
public final XSElementDecl getElementDecl(){
@@ -137,12 +137,12 @@
}
- public final XSAttributeUse getAttributeUse(){
+ public final XSAttributeUseImpl getAttributeUse(){
int chunk = fAttributeUseIndex >> CHUNK_SHIFT;
int index = fAttributeUseIndex & CHUNK_MASK;
ensureAttributeUseCapacity(chunk);
if (fAttributeUse[chunk][index] == null) {
- fAttributeUse[chunk][index] = new XSAttributeUse();
+ fAttributeUse[chunk][index] = new XSAttributeUseImpl();
} else {
fAttributeUse[chunk][index].reset();
}
@@ -192,12 +192,12 @@
return fParticleDecl[chunk][index];
}
- public final XSModelGroup getModelGroup(){
+ public final XSModelGroupImpl getModelGroup(){
int chunk = fModelGroupIndex >> CHUNK_SHIFT;
int index = fModelGroupIndex & CHUNK_MASK;
ensureModelGroupCapacity(chunk);
if (fModelGroup[chunk][index] == null) {
- fModelGroup[chunk][index] = new XSModelGroup();
+ fModelGroup[chunk][index] = new XSModelGroupImpl();
} else {
fModelGroup[chunk][index].reset();
}
@@ -246,7 +246,7 @@
return false;
}
- fModelGroup[chunk] = new XSModelGroup[CHUNK_SIZE];
+ fModelGroup[chunk] = new XSModelGroupImpl[CHUNK_SIZE];
return true;
}
@@ -256,8 +256,8 @@
return newarray;
}
- private static XSModelGroup[][] resize(XSModelGroup array[][], int newsize) {
- XSModelGroup newarray[][] = new XSModelGroup[newsize][];
+ private static XSModelGroupImpl[][] resize(XSModelGroupImpl array[][], int newsize) {
+ XSModelGroupImpl newarray[][] = new XSModelGroupImpl[newsize][];
System.arraycopy(array, 0, newarray, 0, array.length);
return newarray;
}
@@ -286,12 +286,12 @@
return false;
}
- fAttributeUse[chunk] = new XSAttributeUse[CHUNK_SIZE];
+ fAttributeUse[chunk] = new XSAttributeUseImpl[CHUNK_SIZE];
return true;
}
- private static XSAttributeUse[][] resize(XSAttributeUse array[][], int newsize) {
- XSAttributeUse newarray[][] = new XSAttributeUse[newsize][];
+ private static XSAttributeUseImpl[][] resize(XSAttributeUseImpl array[][], int newsize) {
+ XSAttributeUseImpl newarray[][] = new XSAttributeUseImpl[newsize][];
System.arraycopy(array, 0, newarray, 0, array.length);
return newarray;
}
1.9 +165 -27 xml-xerces/java/src/org/apache/xerces/impl/xs/XSElementDecl.java
Index: XSElementDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSElementDecl.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XSElementDecl.java 7 May 2002 15:54:27 -0000 1.8
+++ XSElementDecl.java 16 May 2002 18:25:54 -0000 1.9
@@ -57,6 +57,8 @@
package org.apache.xerces.impl.xs;
+import org.apache.xerces.impl.xs.psvi.*;
+import org.apache.xerces.impl.xs.util.XSNamedMapImpl;
import org.apache.xerces.impl.xs.identity.IdentityConstraint;
import org.apache.xerces.impl.dv.ValidatedInfo;
@@ -66,14 +68,9 @@
*
* @author Elena Litani, IBM
* @author Sandy Gao, IBM
- * @version $Id: XSElementDecl.java,v 1.8 2002/05/07 15:54:27 sandygao Exp $
+ * @version $Id: XSElementDecl.java,v 1.9 2002/05/16 18:25:54 sandygao Exp $
*/
-public class XSElementDecl {
-
- // types of value constraint
- public final static short NO_CONSTRAINT = 0;
- public final static short DEFAULT_VALUE = 1;
- public final static short FIXED_VALUE = 2;
+public class XSElementDecl implements XSElementDeclaration {
// scopes
public final static short SCOPE_ABSENT = 0;
@@ -88,14 +85,13 @@
public XSTypeDecl fType = null;
// misc flag of the element: nillable/abstract/fixed
short fMiscFlags = 0;
- // scope
- short fScope = SCOPE_ABSENT;
+ public short fScope = XSConstants.SCOPE_ABSENT;
// enclosing complex type, when the scope is local
XSComplexTypeDecl fEnclosingCT = null;
// block set (disallowed substitutions) of the element
- public short fBlock = SchemaSymbols.EMPTY_SET;
+ public short fBlock = XSConstants.DERIVATION_NONE;
// final set (substitution group exclusions) of the element
- public short fFinal = SchemaSymbols.EMPTY_SET;
+ public short fFinal = XSConstants.DERIVATION_NONE;
// value constraint value
public ValidatedInfo fDefault = null;
// the substitution group affiliation of the element
@@ -110,20 +106,6 @@
private static final short ABSTRACT = 8;
// methods to get/set misc flag
-
- public short getConstraintType() {
- return (short)(fMiscFlags & CONSTRAINT_MASK);
- }
- public boolean isNillable() {
- return ((fMiscFlags & NILLABLE) != 0);
- }
- public boolean isAbstract() {
- return ((fMiscFlags & ABSTRACT) != 0);
- }
- public boolean isGlobal() {
- return fScope == SCOPE_GLOBAL;
- }
-
public void setConstraintType(short constraintType) {
// first clear the bits
fMiscFlags ^= (fMiscFlags & CONSTRAINT_MASK);
@@ -211,8 +193,8 @@
fTargetNamespace = null;
fType = null;
fMiscFlags = 0;
- fBlock = SchemaSymbols.EMPTY_SET;
- fFinal = SchemaSymbols.EMPTY_SET;
+ fBlock = XSConstants.DERIVATION_NONE;
+ fFinal = XSConstants.DERIVATION_NONE;
fDefault = null;
fSubGroup = null;
// reset identity constraints
@@ -222,4 +204,160 @@
fIDCPos = 0;
}
+
+ /**
+ * Get the type of the object, i.e ELEMENT_DECLARATION.
+ */
+ public short getType() {
+ return XSConstants.ELEMENT_DECLARATION;
+ }
+
+ /**
+ * The <code>name</code> of this <code>XSObject</code> depending on the
+ * <code>XSObject</code> type.
+ */
+ public String getName() {
+ return fName;
+ }
+
+ /**
+ * The namespace URI of this node, or <code>null</code> if it is
+ * unspecified. defines how a namespace URI is attached to schema
+ * components.
+ */
+ public String getNamespace() {
+ return fTargetNamespace;
+ }
+
+ /**
+ * Either a simple type definition or a complex type definition.
+ */
+ public XSTypeDefinition getTypeDefinition() {
+ return fType;
+ }
+
+ /**
+ * Optional. Either global or a complex type definition (
+ * <code>ctDefinition</code>). This property is absent in the case of
+ * declarations within named model groups: their scope will be
+ * determined when they are used in the construction of complex type
+ * definitions.
+ */
+ public short getScope() {
+ return fScope;
+ }
+
+ /**
+ * Locally scoped declarations are available for use only within the
+ * complex type definition identified by the <code>scope</code>
+ * property.
+ */
+ public XSComplexTypeDefinition getEnclosingCTDefinition() {
+ return fEnclosingCT;
+ }
+
+ /**
+ * A value constraint: one of default, fixed.
+ */
+ public short getConstraintType() {
+ return (short)(fMiscFlags & CONSTRAINT_MASK);
+ }
+
+ /**
+ * A value constraint: The actual value (with respect to the {type
+ * definition})
+ */
+ public String getConstraintValue() {
+ // REVISIT: SCAPI: what's the proper representation
+ return getConstraintType() == XSConstants.VC_NONE ?
+ null :
+ fDefault.normalizedValue;
+ }
+
+ /**
+ * If {nillable} is true, then an element may also be valid if it carries
+ * the namespace qualified attribute with [local name] nil from
+ * namespace http://www.w3.org/2001/XMLSchema-instance and value true
+ * (see xsi:nil (2.6.2)) even if it has no text or element content
+ * despite a {content type} which would otherwise require content.
+ */
+ public boolean getIsNillable() {
+ return ((fMiscFlags & NILLABLE) != 0);
+ }
+
+ /**
+ * {identity-constraint definitions} A set of constraint definitions.
+ */
+ public XSNamedMap getIdentityConstraints() {
+ return new XSNamedMapImpl(fIDConstraints, fIDCPos);
+ }
+
+ /**
+ * {substitution group affiliation} Optional. A top-level element
+ * definition.
+ */
+ public XSElementDeclaration getSubstitutionGroupAffiliation() {
+ return fSubGroup;
+ }
+
+ /**
+ * Convenience method. Check if <code>exclusion</code> is a substitution
+ * group exclusion for this element declaration.
+ * @param exclusion Extension, restriction or none. Represents final
+ * set for the element.
+ * @return True if <code>exclusion</code> is a part of the substitution
+ * group exclusion subset.
+ */
+ public boolean getIsSubstitutionGroupExclusion(short exclusion) {
+ return (fFinal & exclusion) != 0;
+ }
+
+ /**
+ * Specifies if this declaration can be nominated as
+ * the {substitution group affiliation} of other
+ * element declarations having the same {type definition}
+ * or types derived therefrom.
+ *
+ * @return A bit flag representing {extension, restriction} or NONE.
+ */
+ public short getSubstitutionGroupExclusions() {
+ return fFinal;
+ }
+
+ /**
+ * Convenience method. Check if <code>disallowed</code> is a disallowed
+ * substitution for this element declaration.
+ * @param disallowed Substitution, extension, restriction or none.
+ * Represents a block set for the element.
+ * @return True if <code>disallowed</code> is a part of the substitution
+ * group exclusion subset.
+ */
+ public boolean getIsDisallowedSubstition(short disallowed) {
+ return (fBlock & disallowed) != 0;
+ }
+
+ /**
+ * The supplied values for {disallowed substitutions}
+ *
+ * @return A bit flag representing {substitution, extension, restriction} or NONE.
+ */
+ public short getDisallowedSubstitutions() {
+ return fBlock;
+ }
+
+ /**
+ * {abstract} A boolean.
+ */
+ public boolean getIsAbstract() {
+ return ((fMiscFlags & ABSTRACT) != 0);
+ }
+
+ /**
+ * Optional. Annotation.
+ */
+ public XSAnnotation getAnnotation() {
+ // REVISIT: SCAPI: to implement
+ return null;
+ }
+
} // class XMLElementDecl
1.4 +5 -5 xml-xerces/java/src/org/apache/xerces/impl/xs/XSGrammarBucket.java
Index: XSGrammarBucket.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSGrammarBucket.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XSGrammarBucket.java 4 Apr 2002 18:49:45 -0000 1.3
+++ XSGrammarBucket.java 16 May 2002 18:25:54 -0000 1.4
@@ -64,7 +64,7 @@
/**
* A class used to hold the internal schema grammar set for the current instance
* @author Sandy Gao, IBM
- * @version $Id: XSGrammarBucket.java,v 1.3 2002/04/04 18:49:45 sandygao Exp $
+ * @version $Id: XSGrammarBucket.java,v 1.4 2002/05/16 18:25:54 sandygao Exp $
*/
public class XSGrammarBucket {
@@ -73,8 +73,8 @@
/**
* Hashtable that maps between Namespace and a Grammar
*/
- private Hashtable fGrammarRegistry = new Hashtable();
- private SchemaGrammar fNoNSGrammar = null;
+ Hashtable fGrammarRegistry = new Hashtable();
+ SchemaGrammar fNoNSGrammar = null;
/**
* Get the schema grammar for the specified namespace
@@ -138,8 +138,8 @@
// check whether the bucket has one with the same tns
sg2 = getGrammar(sg1.fTargetNamespace);
if (sg2 == null) {
- // we need to add grammars imported by sg2 too
- gs = sg2.getImportedGrammars();
+ // we need to add grammars imported by sg1 too
+ gs = sg1.getImportedGrammars();
// for all grammars imported by sg2, but not in the vector
// we add them to the vector
for (int j = gs.size() - 1; j >= 0; j--) {
1.5 +44 -3 xml-xerces/java/src/org/apache/xerces/impl/xs/XSGroupDecl.java
Index: XSGroupDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSGroupDecl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XSGroupDecl.java 26 Apr 2002 22:03:42 -0000 1.4
+++ XSGroupDecl.java 16 May 2002 18:25:54 -0000 1.5
@@ -57,20 +57,61 @@
package org.apache.xerces.impl.xs;
+import org.apache.xerces.impl.xs.psvi.*;
+
/**
* The XML representation for a group declaration
* schema component is a global <group> element information item
*
* @author Sandy Gao, IBM
- * @version $Id: XSGroupDecl.java,v 1.4 2002/04/26 22:03:42 sandygao Exp $
+ * @version $Id: XSGroupDecl.java,v 1.5 2002/05/16 18:25:54 sandygao Exp $
*/
-public class XSGroupDecl {
+public class XSGroupDecl implements XSModelGroupDefinition {
// name of the group
public String fName = null;
// target namespace of the group
public String fTargetNamespace = null;
// model group of the group
- public XSModelGroup fModelGroup = null;
+ public XSModelGroupImpl fModelGroup = null;
+
+ /**
+ * Get the type of the object, i.e ELEMENT_DECLARATION.
+ */
+ public short getType() {
+ return XSConstants.MODEL_GROUP_DEFINITION;
+ }
+
+ /**
+ * The <code>name</code> of this <code>XSObject</code> depending on the
+ * <code>XSObject</code> type.
+ */
+ public String getName() {
+ return fName;
+ }
+
+ /**
+ * The namespace URI of this node, or <code>null</code> if it is
+ * unspecified. defines how a namespace URI is attached to schema
+ * components.
+ */
+ public String getNamespace() {
+ return fTargetNamespace;
+ }
+
+ /**
+ * {model group} A model group.
+ */
+ public XSModelGroup getModelGroup() {
+ return fModelGroup;
+ }
+ /**
+ * Optional. Annotation.
+ */
+ public XSAnnotation getAnnotation() {
+ // REVISIT: SCAPI: to implement
+ return null;
+ }
+
} // class XSGroupDecl
1.3 +51 -2 xml-xerces/java/src/org/apache/xerces/impl/xs/XSNotationDecl.java
Index: XSNotationDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSNotationDecl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XSNotationDecl.java 29 Jan 2002 01:15:14 -0000 1.2
+++ XSNotationDecl.java 16 May 2002 18:25:54 -0000 1.3
@@ -57,14 +57,16 @@
package org.apache.xerces.impl.xs;
+import org.apache.xerces.impl.xs.psvi.*;
+
/**
* The XML representation for a NOTATION declaration
* schema component is a global <notation> element information item
*
* @author Rahul Srivastava, Sun Microsystems Inc.
- * @version $Id: XSNotationDecl.java,v 1.2 2002/01/29 01:15:14 lehors Exp $
+ * @version $Id: XSNotationDecl.java,v 1.3 2002/05/16 18:25:54 sandygao Exp $
*/
-public class XSNotationDecl {
+public class XSNotationDecl implements XSNotationDeclaration {
// name of the group
public String fName = null;
@@ -74,5 +76,52 @@
public String fPublicId = null;
// system id of the notation
public String fSystemId = null;
+
+ /**
+ * Get the type of the object, i.e ELEMENT_DECLARATION.
+ */
+ public short getType() {
+ return XSConstants.NOTATION_DECLARATION;
+ }
+
+ /**
+ * The <code>name</code> of this <code>XSObject</code> depending on the
+ * <code>XSObject</code> type.
+ */
+ public String getName() {
+ return fName;
+ }
+
+ /**
+ * The namespace URI of this node, or <code>null</code> if it is
+ * unspecified. defines how a namespace URI is attached to schema
+ * components.
+ */
+ public String getNamespace() {
+ return fTargetNamespace;
+ }
+
+ /**
+ * Optional if {public identifier} is present. A URI reference.
+ */
+ public String getSystemId() {
+ return fSystemId;
+ }
+
+ /**
+ * Optional if {system identifier} is present. A public identifier,
+ * as defined in [XML 1.0 (Second Edition)].
+ */
+ public String getPublicId() {
+ return fPublicId;
+ }
+
+ /**
+ * Optional. Annotation.
+ */
+ public XSAnnotation getAnnotation() {
+ // REVISIT: SCAPI: to implement
+ return null;
+ }
} // class XSNotationDecl
1.8 +61 -6 xml-xerces/java/src/org/apache/xerces/impl/xs/XSParticleDecl.java
Index: XSParticleDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSParticleDecl.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XSParticleDecl.java 26 Apr 2002 22:03:42 -0000 1.7
+++ XSParticleDecl.java 16 May 2002 18:25:54 -0000 1.8
@@ -57,14 +57,16 @@
package org.apache.xerces.impl.xs;
+import org.apache.xerces.impl.xs.psvi.*;
+
/**
* Store schema particle declaration.
*
* @author Sandy Gao, IBM
*
- * @version $Id: XSParticleDecl.java,v 1.7 2002/04/26 22:03:42 sandygao Exp $
+ * @version $Id: XSParticleDecl.java,v 1.8 2002/05/16 18:25:54 sandygao Exp $
*/
-public class XSParticleDecl {
+public class XSParticleDecl implements XSParticle {
// types of particles
public static final short PARTICLE_EMPTY = 0;
@@ -82,7 +84,7 @@
// for PARTICLE_ELEMENT : the element decl
// for PARTICLE_WILDCARD: the wildcard decl
// for PARTICLE_MODELGROUP: the model group
- public Object fValue = null;
+ public XSTerm fValue = null;
// minimum occurrence of this particle
public int fMinOccurs = 1;
@@ -115,7 +117,7 @@
if (fType == PARTICLE_ELEMENT || fType == PARTICLE_WILDCARD)
return false;
- return ((XSModelGroup)fValue).isEmpty();
+ return ((XSModelGroupImpl)fValue).isEmpty();
}
/**
@@ -127,14 +129,14 @@
*/
public int minEffectiveTotalRange() {
if (fType == PARTICLE_MODELGROUP) {
- return ((XSModelGroup)fValue).minEffectiveTotalRange() * fMinOccurs;
+ return ((XSModelGroupImpl)fValue).minEffectiveTotalRange() * fMinOccurs;
}
return fMinOccurs;
}
public int maxEffectiveTotalRange() {
if (fType == PARTICLE_MODELGROUP) {
- int max = ((XSModelGroup)fValue).maxEffectiveTotalRange();
+ int max = ((XSModelGroupImpl)fValue).maxEffectiveTotalRange();
if (max == SchemaSymbols.OCCURRENCE_UNBOUNDED)
return SchemaSymbols.OCCURRENCE_UNBOUNDED;
if (max != 0 && fMaxOccurs == SchemaSymbols.OCCURRENCE_UNBOUNDED)
@@ -194,4 +196,57 @@
fMaxOccurs = 1;
fDescription = null;
}
+
+ /**
+ * Get the type of the object, i.e ELEMENT_DECLARATION.
+ */
+ public short getType() {
+ return XSConstants.PARTICLE;
+ }
+
+ /**
+ * The <code>name</code> of this <code>XSObject</code> depending on the
+ * <code>XSObject</code> type.
+ */
+ public String getName() {
+ return null;
+ }
+
+ /**
+ * The namespace URI of this node, or <code>null</code> if it is
+ * unspecified. defines how a namespace URI is attached to schema
+ * components.
+ */
+ public String getNamespace() {
+ return null;
+ }
+
+ /**
+ * {min occurs} determines the minimum number of terms that can occur.
+ */
+ public int getMinOccurs() {
+ return fMinOccurs;
+ }
+
+ /**
+ * {max occurs} whether the maxOccurs value is unbounded.
+ */
+ public boolean getIsMaxOccursUnbounded() {
+ return fMaxOccurs == SchemaSymbols.OCCURRENCE_UNBOUNDED;
+ }
+
+ /**
+ * {max occurs} determines the maximum number of terms that can occur.
+ */
+ public int getMaxOccurs() {
+ return fMaxOccurs;
+ }
+
+ /**
+ * {term} One of a model group, a wildcard, or an element declaration.
+ */
+ public XSTerm getTerm() {
+ return fValue;
+ }
+
} // class XSParticle
1.5 +5 -13 xml-xerces/java/src/org/apache/xerces/impl/xs/XSTypeDecl.java
Index: XSTypeDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSTypeDecl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XSTypeDecl.java 21 Mar 2002 20:53:45 -0000 1.4
+++ XSTypeDecl.java 16 May 2002 18:25:54 -0000 1.5
@@ -57,29 +57,21 @@
package org.apache.xerces.impl.xs;
+import org.apache.xerces.impl.xs.psvi.XSTypeDefinition;
+
/**
* The XML representation for a type declaration
* schema component is a <simpleType> or <complexType> element information item
*
* @author Elena Litani, IBM
- * @version $Id: XSTypeDecl.java,v 1.4 2002/03/21 20:53:45 sandygao Exp $
+ * @version $Id: XSTypeDecl.java,v 1.5 2002/05/16 18:25:54 sandygao Exp $
*/
-public interface XSTypeDecl {
-
- public static final short COMPLEX_TYPE = 1;
- public static final short SIMPLE_TYPE = 2;
+public interface XSTypeDecl extends XSTypeDefinition {
- public short getXSType();
- public String getTypeName();
- public String getTargetNamespace();
- public XSTypeDecl getBaseType();
- public short getFinalSet();
- public boolean isAnonymous();
-
/**
* Experimental: return whether this type is derived from a given type.
*/
- public boolean derivedFrom(XSTypeDecl ancestor);
+ public boolean derivedFrom(XSTypeDefinition ancestor);
/**
* Experimental: return whether this type is derived from a type of
* the given namespace name and type name.
1.7 +104 -62 xml-xerces/java/src/org/apache/xerces/impl/xs/XSWildcardDecl.java
Index: XSWildcardDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSWildcardDecl.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XSWildcardDecl.java 15 Mar 2002 23:01:57 -0000 1.6
+++ XSWildcardDecl.java 16 May 2002 18:25:54 -0000 1.7
@@ -57,9 +57,10 @@
package org.apache.xerces.impl.xs;
+import org.apache.xerces.impl.xs.psvi.*;
+import org.apache.xerces.impl.xs.util.EnumerationImpl;
import org.apache.xerces.xni.QName;
-import java.util.Vector;
-
+import java.util.Enumeration;
/**
* The XML representation for a wildcard declaration
@@ -68,35 +69,19 @@
* @author Sandy Gao, IBM
* @author Rahul Srivastava, Sun Microsystems Inc.
*
- * @version $Id: XSWildcardDecl.java,v 1.6 2002/03/15 23:01:57 sandygao Exp $
+ * @version $Id: XSWildcardDecl.java,v 1.7 2002/05/16 18:25:54 sandygao Exp $
*/
-public class XSWildcardDecl {
+public class XSWildcardDecl implements XSWildcard {
public static final String ABSENT = null;
- // types of wildcard
- // namespace="##any"
- public static final short WILDCARD_ANY = 0;
- // namespace="##other"
- public static final short WILDCARD_OTHER = 1;
- // namespace= (list of (anyURI | ##targetNamespace | ##local))
- public static final short WILDCARD_LIST = 2;
-
- // types of process contents
- // processContents="strict"
- public static final short WILDCARD_STRICT = 0;
- // processContents="lax"
- public static final short WILDCARD_LAX = 1;
- // processContents="skip"
- public static final short WILDCARD_SKIP = 2;
-
// the type of wildcard: any, other, or list
- public short fType = WILDCARD_ANY;
+ public short fType = NSCONSTRAINT_ANY;
// the type of process contents: strict, lax, or skip
- public short fProcessContents = WILDCARD_STRICT;
+ public short fProcessContents = PC_STRICT;
// the namespace list:
- // for WILDCARD_LIST, it means one of the namespaces in the list
- // for WILDCARD_OTHER, it means not any of the namespaces in the list
+ // for NSCONSTRAINT_LIST, it means one of the namespaces in the list
+ // for NSCONSTRAINT_NOT, it means not any of the namespaces in the list
public String[] fNamespaceList;
// I'm trying to implement the following constraint exactly as what the
@@ -123,7 +108,7 @@
// For a value which is either a namespace name or absent to be valid with respect to a wildcard constraint (the value of a {namespace constraint}) one of the following must be true:
// 1 The constraint must be any.
- if (fType == WILDCARD_ANY)
+ if (fType == NSCONSTRAINT_ANY)
return true;
// 2 All of the following must be true:
@@ -132,7 +117,7 @@
// 2.3 The value must not be absent.
// / we store ##other as not(list), so our actual rule is
// / 2 The constraint is a pair of not and a set, and the value is not in such set.
- if (fType == WILDCARD_OTHER) {
+ if (fType == NSCONSTRAINT_NOT) {
boolean found = false;
int listNum = fNamespaceList.length;
for (int i = 0; i < listNum && !found; i++) {
@@ -145,7 +130,7 @@
}
// 3 The constraint is a set, and the value is identical to one of the members of the set.
- if (fType == WILDCARD_LIST) {
+ if (fType == NSCONSTRAINT_LIST) {
int listNum = fNamespaceList.length;
for (int i = 0; i < listNum; i++) {
if (namespace == fNamespaceList[i])
@@ -169,7 +154,7 @@
// namespace constraint (call it super) one of the following must be true:
// 1 super must be any.
- if (superWildcard.fType == WILDCARD_ANY) {
+ if (superWildcard.fType == NSCONSTRAINT_ANY) {
return true;
}
@@ -178,8 +163,8 @@
// 2.2 super must be a pair of not and the same value.
// * we can't just compare whether the namespace are the same value
// since we store other as not(list)
- if (fType == WILDCARD_OTHER) {
- if (superWildcard.fType == WILDCARD_OTHER &&
+ if (fType == NSCONSTRAINT_NOT) {
+ if (superWildcard.fType == NSCONSTRAINT_NOT &&
fNamespaceList[0] == superWildcard.fNamespaceList[0]) {
return true;
}
@@ -195,13 +180,13 @@
// either that value or absent must not be in sub's set.
// * since we store ##other as not(list), we acturally need to make sure
// that none of the namespaces in super.list is in sub.list.
- if (fType == WILDCARD_LIST) {
- if (superWildcard.fType == WILDCARD_LIST &&
+ if (fType == NSCONSTRAINT_LIST) {
+ if (superWildcard.fType == NSCONSTRAINT_LIST &&
subset2sets(fNamespaceList, superWildcard.fNamespaceList)) {
return true;
}
- if (superWildcard.fType == WILDCARD_OTHER &&
+ if (superWildcard.fType == NSCONSTRAINT_NOT &&
!elementInSet(superWildcard.fNamespaceList[0], fNamespaceList) &&
!elementInSet(ABSENT, fNamespaceList)) {
return true;
@@ -236,14 +221,14 @@
}
// 2 If either O1 or O2 is any, then any must be the value.
- else if ( (fType == WILDCARD_ANY) || (wildcard.fType == WILDCARD_ANY) ) {
- unionWildcard.fType = WILDCARD_ANY;
+ else if ( (fType == NSCONSTRAINT_ANY) || (wildcard.fType == NSCONSTRAINT_ANY) ) {
+ unionWildcard.fType = NSCONSTRAINT_ANY;
}
// 3 If both O1 and O2 are sets of (namespace names or absent), then the union of
// those sets must be the value.
- else if ( (fType == WILDCARD_LIST) && (wildcard.fType == WILDCARD_LIST) ) {
- unionWildcard.fType = WILDCARD_LIST;
+ else if ( (fType == NSCONSTRAINT_LIST) && (wildcard.fType == NSCONSTRAINT_LIST) ) {
+ unionWildcard.fType = NSCONSTRAINT_LIST;
unionWildcard.fNamespaceList = union2sets(fNamespaceList, wildcard.fNamespaceList);
}
@@ -253,8 +238,8 @@
// a pair of not and absent must be the value.
// * now we store ##other as not(list), the result should be
// not(intersection of two lists).
- else if (fType == WILDCARD_OTHER && wildcard.fType == WILDCARD_OTHER) {
- unionWildcard.fType = WILDCARD_OTHER;
+ else if (fType == NSCONSTRAINT_NOT && wildcard.fType == NSCONSTRAINT_NOT) {
+ unionWildcard.fType = NSCONSTRAINT_NOT;
unionWildcard.fNamespaceList = new String[2];
unionWildcard.fNamespaceList[0] = ABSENT;
unionWildcard.fNamespaceList[1] = ABSENT;
@@ -282,12 +267,12 @@
// +5.2.2 If the set does not include absent, then whichever of O1 or O2 is
// a pair of not and a namespace name must be the value.
// * when we have not(list), the operation is just not(otherlist-list)
- else if ( ((fType == WILDCARD_OTHER) && (wildcard.fType == WILDCARD_LIST)) ||
- ((fType == WILDCARD_LIST) && (wildcard.fType == WILDCARD_OTHER)) ) {
+ else if ( ((fType == NSCONSTRAINT_NOT) && (wildcard.fType == NSCONSTRAINT_LIST)) ||
+ ((fType == NSCONSTRAINT_LIST) && (wildcard.fType == NSCONSTRAINT_NOT)) ) {
String[] other = null;
String[] list = null;
- if (fType == WILDCARD_OTHER) {
+ if (fType == NSCONSTRAINT_NOT) {
other = fNamespaceList;
list = wildcard.fNamespaceList;
}
@@ -301,23 +286,23 @@
if (other[0] != ABSENT) {
boolean foundNS = elementInSet(other[0], list);
if (foundNS && foundAbsent) {
- unionWildcard.fType = WILDCARD_ANY;
+ unionWildcard.fType = NSCONSTRAINT_ANY;
} else if (foundNS && !foundAbsent) {
- unionWildcard.fType = WILDCARD_OTHER;
+ unionWildcard.fType = NSCONSTRAINT_NOT;
unionWildcard.fNamespaceList = new String[2];
unionWildcard.fNamespaceList[0] = ABSENT;
unionWildcard.fNamespaceList[1] = ABSENT;
} else if (!foundNS && foundAbsent) {
return null;
} else { // !foundNS && !foundAbsent
- unionWildcard.fType = WILDCARD_OTHER;
+ unionWildcard.fType = NSCONSTRAINT_NOT;
unionWildcard.fNamespaceList = other;
}
} else { // other[0] == ABSENT
if (foundAbsent) {
- unionWildcard.fType = WILDCARD_ANY;
+ unionWildcard.fType = NSCONSTRAINT_ANY;
} else { // !foundAbsent
- unionWildcard.fType = WILDCARD_OTHER;
+ unionWildcard.fType = NSCONSTRAINT_NOT;
unionWildcard.fNamespaceList = other;
}
}
@@ -350,11 +335,11 @@
}
// 2 If either O1 or O2 is any, then the other must be the value.
- else if ( (fType == WILDCARD_ANY) || (wildcard.fType == WILDCARD_ANY) ) {
+ else if ( (fType == NSCONSTRAINT_ANY) || (wildcard.fType == NSCONSTRAINT_ANY) ) {
// both cannot be ANY, if we have reached here.
XSWildcardDecl other = this;
- if (fType == WILDCARD_ANY)
+ if (fType == NSCONSTRAINT_ANY)
other = wildcard;
intersectWildcard.fType = other.fType;
@@ -369,12 +354,12 @@
// namespace name if it was in the set, then minus absent if it was in the
// set, must be the value.
// * when we have not(list), the operation is just list-otherlist
- else if ( ((fType == WILDCARD_OTHER) && (wildcard.fType == WILDCARD_LIST)) ||
- ((fType == WILDCARD_LIST) && (wildcard.fType == WILDCARD_OTHER)) ) {
+ else if ( ((fType == NSCONSTRAINT_NOT) && (wildcard.fType == NSCONSTRAINT_LIST)) ||
+ ((fType == NSCONSTRAINT_LIST) && (wildcard.fType == NSCONSTRAINT_NOT)) ) {
String[] list = null;
String[] other = null;
- if (fType == WILDCARD_OTHER) {
+ if (fType == NSCONSTRAINT_NOT) {
other = fNamespaceList;
list = wildcard.fNamespaceList;
}
@@ -391,15 +376,15 @@
intersect[newSize++] = list[i];
}
- intersectWildcard.fType = WILDCARD_LIST;
+ intersectWildcard.fType = NSCONSTRAINT_LIST;
intersectWildcard.fNamespaceList = new String[newSize];
System.arraycopy(intersect, 0, intersectWildcard.fNamespaceList, 0, newSize);
}
// 4 If both O1 and O2 are sets of (namespace names or absent), then the intersection of those
// sets must be the value.
- else if ( (fType == WILDCARD_LIST) && (wildcard.fType == WILDCARD_LIST) ) {
- intersectWildcard.fType = WILDCARD_LIST;
+ else if ( (fType == NSCONSTRAINT_LIST) && (wildcard.fType == NSCONSTRAINT_LIST) ) {
+ intersectWildcard.fType = NSCONSTRAINT_LIST;
intersectWildcard.fNamespaceList = intersect2sets(fNamespaceList, wildcard.fNamespaceList);
}
@@ -411,7 +396,7 @@
// +5.2 If one of the two is a pair of not and absent, the other must be
// the value.
// * when we have not(list), the operation is just not(onelist+otherlist)
- else if (fType == WILDCARD_OTHER && wildcard.fType == WILDCARD_OTHER) {
+ else if (fType == NSCONSTRAINT_NOT && wildcard.fType == NSCONSTRAINT_NOT) {
if (fNamespaceList[0] != ABSENT && wildcard.fNamespaceList[0] != ABSENT)
return null;
@@ -430,13 +415,13 @@
private boolean areSame(XSWildcardDecl wildcard) {
if (fType == wildcard.fType) {
// ##any, true
- if (fType == WILDCARD_ANY)
+ if (fType == NSCONSTRAINT_ANY)
return true;
// ##other, only check the negated value
// * when we support not(list), we need to check in the same way
- // as for WILDCARD_LIST.
- if (fType == WILDCARD_OTHER)
+ // as for NSCONSTRAINT_LIST.
+ if (fType == NSCONSTRAINT_NOT)
return fNamespaceList[0] == wildcard.fNamespaceList[0];
// ## list, must have the same length,
@@ -515,17 +500,17 @@
StringBuffer buffer = new StringBuffer();
buffer.append("WC[");
switch (fType) {
- case WILDCARD_ANY:
+ case NSCONSTRAINT_ANY:
buffer.append(SchemaSymbols.ATTVAL_TWOPOUNDANY);
break;
- case WILDCARD_OTHER:
+ case NSCONSTRAINT_NOT:
buffer.append(SchemaSymbols.ATTVAL_TWOPOUNDOTHER);
buffer.append(":\"");
if (fNamespaceList[0] != null)
buffer.append(fNamespaceList[0]);
buffer.append("\"");
break;
- case WILDCARD_LIST:
+ case NSCONSTRAINT_LIST:
buffer.append("\"");
if (fNamespaceList[0] != null)
buffer.append(fNamespaceList[0]);
@@ -543,6 +528,63 @@
}
return fDescription;
+ }
+
+ /**
+ * Get the type of the object, i.e ELEMENT_DECLARATION.
+ */
+ public short getType() {
+ return XSConstants.WILDCARD;
+ }
+
+ /**
+ * The <code>name</code> of this <code>XSObject</code> depending on the
+ * <code>XSObject</code> type.
+ */
+ public String getName() {
+ return null;
+ }
+
+ /**
+ * The namespace URI of this node, or <code>null</code> if it is
+ * unspecified. defines how a namespace URI is attached to schema
+ * components.
+ */
+ public String getNamespace() {
+ return null;
+ }
+
+ /**
+ * Namespace constraint: A constraint type: any, not, list.
+ */
+ public short getConstraintType() {
+ return fType;
+ }
+
+ /**
+ * Namespace constraint. For <code>constraintType</code>
+ * LIST_NSCONSTRAINT, the list contains allowed namespaces. For
+ * <code>constraintType</code> NOT_NSCONSTRAINT, the list contains
+ * disallowed namespaces.
+ */
+ public Enumeration getNSConstraintList() {
+ return new EnumerationImpl(fNamespaceList, fNamespaceList.length);
+ }
+
+ /**
+ * {process contents} One of skip, lax or strict. Valid constants values
+ * are: SKIP_PROCESS, LAX_PROCESS, STRING_PROCESS.
+ */
+ public short getProcessContents() {
+ return fProcessContents;
+ }
+
+ /**
+ * Optional. Annotation.
+ */
+ public XSAnnotation getAnnotation() {
+ // REVISIT: SCAPI: to implement
+ return null;
}
} // class XSWildcardDecl
1.1 xml-xerces/java/src/org/apache/xerces/impl/xs/XSAttributeUseImpl.java
Index: XSAttributeUseImpl.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.xerces.impl.xs;
import org.apache.xerces.impl.xs.psvi.*;
import org.apache.xerces.impl.dv.ValidatedInfo;
/**
* The XML representation for an attribute use
* schema component is a local <attribute> element information item
*
* @author Sandy Gao, IBM
* @version $Id: XSAttributeUseImpl.java,v 1.1 2002/05/16 18:25:54 sandygao Exp $
*/
public class XSAttributeUseImpl implements XSAttributeUse {
// the referred attribute decl
public XSAttributeDecl fAttrDecl = null;
// use information: SchemaSymbols.USE_OPTIONAL, REQUIRED, PROHIBITED
public short fUse = SchemaSymbols.USE_OPTIONAL;
// value constraint type: default, fixed or !specified
public short fConstraintType = XSConstants.VC_NONE;
// value constraint value
public ValidatedInfo fDefault = null;
public void reset(){
fDefault = null;
fAttrDecl = null;
fUse = SchemaSymbols.USE_OPTIONAL;
fConstraintType = XSConstants.VC_NONE;
}
/**
* Get the type of the object, i.e ELEMENT_DECLARATION.
*/
public short getType() {
return XSConstants.ATTRIBUTE_USE;
}
/**
* The <code>name</code> of this <code>XSObject</code> depending on the
* <code>XSObject</code> type.
*/
public String getName() {
return null;
}
/**
* The namespace URI of this node, or <code>null</code> if it is
* unspecified. defines how a namespace URI is attached to schema
* components.
*/
public String getNamespace() {
return null;
}
/**
* {required} determines whether this use of an attribute declaration
* requires an appropriate attribute information item to be present, or
* merely allows it.
*/
public boolean getIsRequired() {
return fUse == SchemaSymbols.USE_REQUIRED;
}
/**
* {attribute declaration} provides the attribute declaration itself,
* which will in turn determine the simple type definition used.
*/
public XSAttributeDeclaration getAttrDeclaration() {
return fAttrDecl;
}
/**
* Value Constraint: one of default, fixed.
*/
public short getConstraintType() {
return fConstraintType;
}
/**
* Value Constraint: The actual value (with respect to the {type
* definition}).
*/
public String getConstraintValue() {
// REVISIT: SCAPI: what's the proper representation
return getConstraintType() == XSConstants.VC_NONE ?
null :
fDefault.normalizedValue;
}
} // class XSAttributeUseImpl
1.1 xml-xerces/java/src/org/apache/xerces/impl/xs/XSModelGroupImpl.java
Index: XSModelGroupImpl.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.xerces.impl.xs;
import org.apache.xerces.impl.xs.psvi.*;
import org.apache.xerces.impl.xs.util.XSObjectListImpl;
/**
* Store schema model group declaration.
*
* @author Sandy Gao, IBM
*
* @version $Id: XSModelGroupImpl.java,v 1.1 2002/05/16 18:25:54 sandygao Exp $
*/
public class XSModelGroupImpl implements XSModelGroup {
// types of model groups
// REVISIT: can't use same constants as those for particles, because
// there are place where the constants are used together. For example,
// to check whether the content is an element or a sequence.
public static final short MODELGROUP_CHOICE = 101;
public static final short MODELGROUP_SEQUENCE = 102;
public static final short MODELGROUP_ALL = 103;
// compositor of the model group
public short fCompositor;
// particles
public XSParticleDecl[] fParticles = null;
public int fParticleCount = 0;
// whether this model group contains nothing
public boolean isEmpty() {
for (int i = 0; i < fParticleCount; i++) {
if (!fParticles[i].isEmpty())
return false;
}
return true;
}
/**
* 3.8.6 Effective Total Range (all and sequence) and
* Effective Total Range (choice)
* The following methods are used to return min/max range for a particle.
* They are not exactly the same as it's described in the spec, but all the
* values from the spec are retrievable by these methods.
*/
public int minEffectiveTotalRange() {
if (fCompositor == MODELGROUP_CHOICE)
return minEffectiveTotalRangeChoice();
else
return minEffectiveTotalRangeAllSeq();
}
// return the sum of all min values of the particles
private int minEffectiveTotalRangeAllSeq() {
int total = 0;
for (int i = 0; i < fParticleCount; i++)
total += fParticles[i].minEffectiveTotalRange();
return total;
}
// return the min of all min values of the particles
private int minEffectiveTotalRangeChoice() {
int min = 0, one;
if (fParticles.length > 0)
min = fParticles[0].minEffectiveTotalRange();
for (int i = 1; i < fParticleCount; i++) {
one = fParticles[i].minEffectiveTotalRange();
if (one < min)
min = one;
}
return min;
}
public int maxEffectiveTotalRange() {
if (fCompositor == MODELGROUP_CHOICE)
return maxEffectiveTotalRangeChoice();
else
return maxEffectiveTotalRangeAllSeq();
}
// if one of the max value of the particles is unbounded, return unbounded;
// otherwise return the sum of all max values
private int maxEffectiveTotalRangeAllSeq() {
int total = 0, one;
for (int i = 0; i < fParticleCount; i++) {
one = fParticles[i].maxEffectiveTotalRange();
if (one == SchemaSymbols.OCCURRENCE_UNBOUNDED)
return SchemaSymbols.OCCURRENCE_UNBOUNDED;
total += one;
}
return total;
}
// if one of the max value of the particles is unbounded, return unbounded;
// otherwise return the max of all max values
private int maxEffectiveTotalRangeChoice() {
int max = 0, one;
if (fParticles.length > 0) {
max = fParticles[0].minEffectiveTotalRange();
if (max == SchemaSymbols.OCCURRENCE_UNBOUNDED)
return SchemaSymbols.OCCURRENCE_UNBOUNDED;
}
for (int i = 1; i < fParticleCount; i++) {
one = fParticles[i].maxEffectiveTotalRange();
if (one == SchemaSymbols.OCCURRENCE_UNBOUNDED)
return SchemaSymbols.OCCURRENCE_UNBOUNDED;
if (one > max)
max = one;
}
return max;
}
/**
* get the string description of this particle
*/
private String fDescription = null;
public String toString() {
if (fDescription == null) {
StringBuffer buffer = new StringBuffer();
if (fCompositor == MODELGROUP_ALL)
buffer.append("all(");
else
buffer.append('(');
if (fParticles.length > 0)
buffer.append(fParticles[0].toString());
for (int i = 1; i < fParticleCount; i++) {
if (fCompositor == MODELGROUP_CHOICE)
buffer.append('|');
else
buffer.append(',');
buffer.append(fParticles[i].toString());
}
buffer.append(')');
fDescription = buffer.toString();
}
return fDescription;
}
public void reset(){
fCompositor = MODELGROUP_SEQUENCE;
fParticles = null;
fParticleCount = 0;
fDescription = null;
}
/**
* Get the type of the object, i.e ELEMENT_DECLARATION.
*/
public short getType() {
return XSConstants.MODEL_GROUP;
}
/**
* The <code>name</code> of this <code>XSObject</code> depending on the
* <code>XSObject</code> type.
*/
public String getName() {
return null;
}
/**
* The namespace URI of this node, or <code>null</code> if it is
* unspecified. defines how a namespace URI is attached to schema
* components.
*/
public String getNamespace() {
return null;
}
/**
* {compositor} One of all, choice or sequence. The valid constants values
* are: ALL, CHOICE, SEQUENCE.
*/
public short getCompositor() {
if (fCompositor == MODELGROUP_CHOICE)
return XSModelGroup.COMPOSITOR_CHOICE;
else if (fCompositor == MODELGROUP_SEQUENCE)
return XSModelGroup.COMPOSITOR_SEQUENCE;
else
return XSModelGroup.COMPOSITOR_ALL;
}
/**
* {particles} A list of particles
*/
public XSObjectList getParticles() {
return new XSObjectListImpl(fParticles, fParticleCount);
}
/**
* Optional. Annotation.
*/
public XSAnnotation getAnnotation() {
// REVISIT: SCAPI: to implement
return null;
}
} // class XSParticle
1.1 xml-xerces/java/src/org/apache/xerces/impl/xs/XSModelImpl.java
Index: XSModelImpl.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.xerces.impl.xs;
import org.apache.xerces.impl.xs.psvi.*;
import org.apache.xerces.util.SymbolHash;
import org.apache.xerces.impl.xs.util.EnumerationImpl;
import org.apache.xerces.impl.xs.util.XSNamedMapImpl;
import org.apache.xerces.impl.xs.util.XSNamedMap4Types;
import java.util.Vector;
import java.util.Enumeration;
/**
* Implements XSModel: a read-only interface that represents an XML Schema,
* which could be components from different namespaces.
*
* @author Sandy Gao, IBM
*
* @version $Id: XSModelImpl.java,v 1.1 2002/05/16 18:25:54 sandygao Exp $
*/
public class XSModelImpl implements XSModel {
// the max index / the max value of XSObject type
private static final short MAX_COMP_IDX = XSTypeDefinition.SIMPLE_TYPE;
private static final boolean[] GLOBAL_COMP = {false, // null
true, // attribute
true, // element
true, // type
false, // attribute use
true, // attribute group
true, // group
false, // model group
false, // particle
false, // wildcard
false, // idc
true, // notation
false, // annotation
true, // complex type
true // simple type
};
// number of grammars/namespaces stored here
private int fGrammarCount;
// all target namespaces
private String[] fNamespaces;
// all schema grammar objects (for each namespace)
private SchemaGrammar[] fGrammarList;
// a map from namespace to schema grammar
private SymbolHash fGrammarMap;
// store a certain kind of components from all namespaces
private XSNamedMap[] fGlobalComponents;
// store a certain kind of components from one namespace
private XSNamedMap[][] fNSComponents;
// temporary array
private SymbolHash[] fTables;
/**
* Construct an XSModelImpl, by storing some grammars and grammars imported
* by them to this object.
*
* @param grammars the array of schema grammars
*/
public XSModelImpl(SchemaGrammar[] grammars) {
// copy namespaces/grammars from the array to our arrays
int len = grammars.length;
fNamespaces = new String[Math.max(len, 5)];
fGrammarList = new SchemaGrammar[Math.max(len, 5)];
for (int i = 0; i < len; i++) {
fNamespaces[i] = grammars[i].getTargetNamespace();
fGrammarList[i] = grammars[i];
}
SchemaGrammar sg1, sg2;
Vector gs;
int i, j, k;
// and recursively get all imported grammars, add them to our arrays
for (i = 0; i < len; i++) {
// get the grammar
sg1 = fGrammarList[i];
gs = sg1.getImportedGrammars();
// for each imported grammar
for (j = gs == null ? -1 : gs.size() - 1; j >= 0; j--) {
sg2 = (SchemaGrammar)gs.elementAt(j);
// check whether this grammar is already in the list
for (k = 0; k < len; k++) {
if (sg2 == fGrammarList[k])
break;
}
// if it's not, add it to the list
if (k == len) {
// ensure the capacity of the arrays
if (len == fGrammarList.length) {
String[] newSA = new String[len*2];
System.arraycopy(fNamespaces, 0, newSA, 0, len);
fNamespaces = newSA;
SchemaGrammar[] newGA = new SchemaGrammar[len*2];
System.arraycopy(fGrammarList, 0, newGA, 0, len);
fGrammarList = newGA;
}
fNamespaces[len] = sg2.getTargetNamespace();
fGrammarList[len] = sg2;
len++;
}
}
}
// establish the mapping from namespace to grammars
fGrammarMap = new SymbolHash(len*2);
for (i = 0; i < len; i++) {
fGrammarMap.put(fNamespaces[i], fGrammarList[i]);
}
fGrammarCount = len;
fGlobalComponents = new XSNamedMap[MAX_COMP_IDX+1];
fNSComponents = new XSNamedMap[len][MAX_COMP_IDX+1];
fTables = new SymbolHash[fGrammarCount];
}
/**
* Convenience method. Returns a list of all namespaces that belong to
* this schema.
* @return A list of all namespaces that belong to this schema or
* <code>null</code> if all components don't have a targetNamespace.
*/
public Enumeration getNamespaces() {
return new EnumerationImpl(fNamespaces, fGrammarCount);
}
/**
* Returns a list of top-level components, i.e. element declarations,
* attribute declarations, etc.
* @param objectType The type of the declaration, i.e.
* ELEMENT_DECLARATION, ATTRIBUTE_DECLARATION, etc.
* @return A list of top-level definition of the specified type in
* <code>objectType</code> or <code>null</code>.
*/
public synchronized XSNamedMap getComponents(short objectType) {
if (objectType <= 0 || objectType > MAX_COMP_IDX ||
!GLOBAL_COMP[objectType]) {
return null;
}
// get all hashtables from all namespaces for this type of components
if (fGlobalComponents[objectType] == null) {
for (int i = 0; i < fGrammarCount; i++) {
switch (objectType) {
case XSConstants.TYPE_DEFINITION:
case XSTypeDefinition.COMPLEX_TYPE:
case XSTypeDefinition.SIMPLE_TYPE:
fTables[i] = fGrammarList[i].fGlobalTypeDecls;
break;
case XSConstants.ATTRIBUTE_DECLARATION:
fTables[i] = fGrammarList[i].fGlobalAttrDecls;
break;
case XSConstants.ELEMENT_DECLARATION:
fTables[i] = fGrammarList[i].fGlobalElemDecls;
break;
case XSConstants.ATTRIBUTE_GROUP:
fTables[i] = fGrammarList[i].fGlobalAttrGrpDecls;
break;
case XSConstants.MODEL_GROUP_DEFINITION:
fTables[i] = fGrammarList[i].fGlobalGroupDecls;
break;
case XSConstants.NOTATION_DECLARATION:
fTables[i] = fGrammarList[i].fGlobalNotationDecls;
break;
}
}
// for complex/simple types, create a special implementation,
// which take specific types out of the hash table
if (objectType == XSTypeDefinition.COMPLEX_TYPE ||
objectType == XSTypeDefinition.SIMPLE_TYPE) {
fGlobalComponents[objectType] = new XSNamedMap4Types(fNamespaces, fTables, fGrammarCount, objectType);
}
else {
fGlobalComponents[objectType] = new XSNamedMapImpl(fNamespaces, fTables, fGrammarCount);
}
}
return fGlobalComponents[objectType];
}
/**
* Convenience method. Returns a list of top-level component declarations
* that are defined within the specified namespace, i.e. element
* declarations, attribute declarations, etc.
* @param objectType The type of the declaration, i.e.
* ELEMENT_DECLARATION, ATTRIBUTE_DECLARATION, etc.
* @param namespace The namespace to which declaration belong or
* <code>null</code> (for components with no targetNamespace).
* @return A list of top-level definition of the specified type in
* <code>objectType</code> and defined in the specified
* <code>namespace</code> or <code>null</code>.
*/
public synchronized XSNamedMap getComponentsByNamespace(short objectType,
String namespace) {
if (objectType <= 0 || objectType > MAX_COMP_IDX ||
!GLOBAL_COMP[objectType]) {
return null;
}
// try to find the grammar
int i = 0;
for (; i < fGrammarCount; i++) {
if (fNamespaces[i] == namespace)
break;
}
if (i == fGrammarCount)
return null;
// get the hashtable for this type of components
if (fNSComponents[i][objectType] == null) {
SymbolHash table = null;
switch (objectType) {
case XSConstants.TYPE_DEFINITION:
case XSTypeDefinition.COMPLEX_TYPE:
case XSTypeDefinition.SIMPLE_TYPE:
table = fGrammarList[i].fGlobalTypeDecls;
break;
case XSConstants.ATTRIBUTE_DECLARATION:
table = fGrammarList[i].fGlobalAttrDecls;
break;
case XSConstants.ELEMENT_DECLARATION:
table = fGrammarList[i].fGlobalElemDecls;
break;
case XSConstants.ATTRIBUTE_GROUP:
table = fGrammarList[i].fGlobalAttrGrpDecls;
break;
case XSConstants.MODEL_GROUP_DEFINITION:
table = fGrammarList[i].fGlobalGroupDecls;
break;
case XSConstants.NOTATION_DECLARATION:
table = fGrammarList[i].fGlobalNotationDecls;
break;
}
// for complex/simple types, create a special implementation,
// which take specific types out of the hash table
if (objectType == XSTypeDefinition.COMPLEX_TYPE ||
objectType == XSTypeDefinition.SIMPLE_TYPE) {
fNSComponents[i][objectType] = new XSNamedMap4Types(namespace, table, objectType);
}
else {
fNSComponents[i][objectType] = new XSNamedMapImpl(namespace, table);
}
}
return fNSComponents[i][objectType];
}
/**
* Convenience method. Returns a top-level simple or complex type
* definition.
* @param name The name of the definition.
* @param namespace The namespace of the definition, otherwise null.
* @return An <code>XSTypeDefinition</code> or null if such definition
* does not exist.
*/
public XSTypeDefinition getTypeDefinition(String name,
String namespace) {
SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(namespace);
if (sg == null)
return null;
return (XSTypeDefinition)sg.fGlobalTypeDecls.get(name);
}
/**
* Convenience method. Returns a top-level attribute declaration.
* @param name The name of the declaration.
* @param namespace The namespace of the definition, otherwise null.
* @return A top-level attribute declaration or null if such declaration
* does not exist.
*/
public XSAttributeDeclaration getAttributeDecl(String name,
String namespace) {
SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(namespace);
if (sg == null)
return null;
return (XSAttributeDeclaration)sg.fGlobalAttrDecls.get(name);
}
/**
* Convenience method. Returns a top-level element declaration.
* @param name The name of the declaration.
* @param namespace The namespace of the definition, otherwise null.
* @return A top-level element declaration or null if such declaration
* does not exist.
*/
public XSElementDeclaration getElementDecl(String name,
String namespace) {
SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(namespace);
if (sg == null)
return null;
return (XSElementDeclaration)sg.fGlobalElemDecls.get(name);
}
/**
* Convenience method. Returns a top-level attribute group definition.
* @param name The name of the definition.
* @param namespace The namespace of the definition, otherwise null.
* @return A top-level attribute group definition or null if such
* definition does not exist.
*/
public XSAttributeGroupDefinition getAttributeGroup(String name,
String namespace) {
SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(namespace);
if (sg == null)
return null;
return (XSAttributeGroupDefinition)sg.fGlobalAttrGrpDecls.get(name);
}
/**
* Convenience method. Returns a top-level model group definition.
*
* @param name The name of the definition.
* @param namespace The namespace of the definition, otherwise null.
* @return A top-level model group definition definition or null if such
* definition does not exist.
*/
public XSModelGroupDefinition getModelGroupDefinition(String name,
String namespace) {
SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(namespace);
if (sg == null)
return null;
return (XSModelGroupDefinition)sg.fGlobalGroupDecls.get(name);
}
/**
* Convenience method. Returns a top-level notation declaration.
*
* @param name The name of the declaration.
* @param namespace The namespace of the definition, otherwise null.
* @return A top-level notation declaration or null if such declaration
* does not exist.
*/
public XSNotationDeclaration getNotationDecl(String name,
String namespace) {
SchemaGrammar sg = (SchemaGrammar)fGrammarMap.get(namespace);
if (sg == null)
return null;
return (XSNotationDeclaration)sg.fGlobalNotationDecls.get(name);
}
/**
* {annotations} A set of annotations.
*/
public XSObjectList getAnnotations() {
// REVISIT: SCAPI: to implement
return null;
}
} // class XSModelImpl
1.4 +76 -21 xml-xerces/java/src/org/apache/xerces/impl/xs/identity/IdentityConstraint.java
Index: IdentityConstraint.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/identity/IdentityConstraint.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- IdentityConstraint.java 15 May 2002 03:43:16 -0000 1.3
+++ IdentityConstraint.java 16 May 2002 18:25:55 -0000 1.4
@@ -57,26 +57,17 @@
package org.apache.xerces.impl.xs.identity;
+import org.apache.xerces.impl.xs.psvi.*;
+import org.apache.xerces.impl.xs.util.EnumerationImpl;
+import java.util.Enumeration;
+
/**
* Base class of Schema identity constraint.
*
* @author Andy Clark, IBM
- * @version $Id: IdentityConstraint.java,v 1.3 2002/05/15 03:43:16 sandygao Exp $
+ * @version $Id: IdentityConstraint.java,v 1.4 2002/05/16 18:25:55 sandygao Exp $
*/
-public abstract class IdentityConstraint {
-
- //
- // Constants
- //
-
- /** Type: unique. */
- public static final short UNIQUE = 0;
-
- /** Type: key. */
- public static final short KEY = 1;
-
- /** Type: key reference. */
- public static final short KEYREF = 2;
+public abstract class IdentityConstraint implements XSIDConstraintDefinition {
//
// Data
@@ -85,6 +76,9 @@
/** type */
protected short type;
+ /** target namespace */
+ protected String fNamespace;
+
/** Identity constraint name. */
protected String fIdentityConstraintName;
@@ -105,7 +99,8 @@
//
/** Default constructor. */
- protected IdentityConstraint(String identityConstraintName, String elemName) {
+ protected IdentityConstraint(String namespace, String identityConstraintName, String elemName) {
+ fNamespace = namespace;
fIdentityConstraintName = identityConstraintName;
fElementName = elemName;
} // <init>(String,String)
@@ -114,11 +109,6 @@
// Public methods
//
- /** Returns the identity constraint type. */
- public short getType() {
- return type;
- } // getType(): short
-
/** Returns the identity constraint name. */
public String getIdentityConstraintName() {
return fIdentityConstraintName;
@@ -197,4 +187,69 @@
return newArray;
}
+ /**
+ * Get the type of the object, i.e ELEMENT_DECLARATION.
+ */
+ public short getType() {
+ return XSConstants.IDENTITY_CONSTRAINT;
+ }
+
+ /**
+ * The <code>name</code> of this <code>XSObject</code> depending on the
+ * <code>XSObject</code> type.
+ */
+ public String getName() {
+ return fIdentityConstraintName;
+ }
+
+ /**
+ * The namespace URI of this node, or <code>null</code> if it is
+ * unspecified. defines how a namespace URI is attached to schema
+ * components.
+ */
+ public String getNamespace() {
+ return fNamespace;
+ }
+
+ /**
+ * {identity-constraint category} One of key, keyref or unique.
+ */
+ public short getCategory() {
+ return type;
+ }
+
+ /**
+ * {selector} A restricted XPath ([XPath]) expression
+ */
+ public String getSelectorStr() {
+ return fSelector.toString();
+ }
+
+ /**
+ * {fields} A non-empty list of restricted XPath ([XPath]) expressions.
+ */
+ public Enumeration getFieldStrs() {
+ String[] strs = new String[fFieldCount];
+ for (int i = 0; i < fFieldCount; i++)
+ strs[i] = fFields[i].toString();
+ return new EnumerationImpl(strs, fFieldCount);
+ }
+
+ /**
+ * {referenced key} Required if {identity-constraint category} is keyref,
+ * forbidden otherwise. An identity-constraint definition with
+ * {identity-constraint category} equal to key or unique.
+ */
+ public XSIDConstraintDefinition getRefKey() {
+ return null;
+ }
+
+ /**
+ * Optional. Annotation.
+ */
+ public XSAnnotation getAnnotation() {
+ // REVISIT: SCAPI: to implement
+ return null;
+ }
+
} // class IdentityConstraint
1.3 +16 -4 xml-xerces/java/src/org/apache/xerces/impl/xs/identity/KeyRef.java
Index: KeyRef.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/identity/KeyRef.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- KeyRef.java 29 Jan 2002 01:15:15 -0000 1.2
+++ KeyRef.java 16 May 2002 18:25:55 -0000 1.3
@@ -57,11 +57,13 @@
package org.apache.xerces.impl.xs.identity;
+import org.apache.xerces.impl.xs.psvi.XSIDConstraintDefinition;
+
/**
* Schema key reference identity constraint.
*
* @author Andy Clark, IBM
- * @version $Id: KeyRef.java,v 1.2 2002/01/29 01:15:15 lehors Exp $
+ * @version $Id: KeyRef.java,v 1.3 2002/05/16 18:25:55 sandygao Exp $
*/
public class KeyRef
extends IdentityConstraint {
@@ -78,10 +80,11 @@
//
/** Constructs a keyref with the specified name. */
- public KeyRef(String identityConstraintName, String elemName, UniqueOrKey key) {
- super(identityConstraintName, elemName);
+ public KeyRef(String namespace, String identityConstraintName,
+ String elemName, UniqueOrKey key) {
+ super(namespace, identityConstraintName, elemName);
fKey = key;
- type = KEYREF;
+ type = IC_KEYREF;
} // <init>(String,String,String)
//
@@ -92,5 +95,14 @@
public UniqueOrKey getKey() {
return fKey;
} // getKey(): int
+
+ /**
+ * {referenced key} Required if {identity-constraint category} is keyref,
+ * forbidden otherwise. An identity-constraint definition with
+ * {identity-constraint category} equal to key or unique.
+ */
+ public XSIDConstraintDefinition getRefKey() {
+ return fKey;
+ }
} // class KeyRef
1.3 +4 -10 xml-xerces/java/src/org/apache/xerces/impl/xs/identity/UniqueOrKey.java
Index: UniqueOrKey.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/identity/UniqueOrKey.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- UniqueOrKey.java 29 Jan 2002 01:15:15 -0000 1.2
+++ UniqueOrKey.java 16 May 2002 18:25:55 -0000 1.3
@@ -64,25 +64,19 @@
* has both. A short int is used to distinguish which this object is.
*
* @author Andy Clark, IBM
- * @version $Id: UniqueOrKey.java,v 1.2 2002/01/29 01:15:15 lehors Exp $
+ * @version $Id: UniqueOrKey.java,v 1.3 2002/05/16 18:25:55 sandygao Exp $
*/
public class UniqueOrKey
extends IdentityConstraint {
- // CONSTANTS
- public static short UNIQUE_TYPE = 1;
- public static short KEY_TYPE = 2;
-
- // DATA
- public short type;
-
//
// Constructors
//
/** Constructs a unique or a key identity constraint. */
- public UniqueOrKey(String identityConstraintName, String elemName, short type) {
- super(identityConstraintName, elemName);
+ public UniqueOrKey(String namespace, String identityConstraintName,
+ String elemName, short type) {
+ super(namespace, identityConstraintName, elemName);
this.type = type;
} // <init>(String,String)
1.4 +6 -6 xml-xerces/java/src/org/apache/xerces/impl/xs/identity/XPathMatcher.java
Index: XPathMatcher.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/identity/XPathMatcher.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XPathMatcher.java 29 Jan 2002 01:15:15 -0000 1.3
+++ XPathMatcher.java 16 May 2002 18:25:55 -0000 1.4
@@ -58,7 +58,7 @@
package org.apache.xerces.impl.xs.identity;
import org.apache.xerces.impl.xs.XSAttributeDecl;
-import org.apache.xerces.impl.xs.XSAttributeUse;
+import org.apache.xerces.impl.xs.XSAttributeUseImpl;
import org.apache.xerces.impl.xs.XSAttributeGroupDecl;
import org.apache.xerces.impl.xs.XSElementDecl;
import org.apache.xerces.impl.xs.XSTypeDecl;
@@ -80,7 +80,7 @@
*
* @author Andy Clark, IBM
*
- * @version $Id: XPathMatcher.java,v 1.3 2002/01/29 01:15:15 lehors Exp $
+ * @version $Id: XPathMatcher.java,v 1.4 2002/05/16 18:25:55 sandygao Exp $
*/
public class XPathMatcher {
@@ -414,7 +414,7 @@
if (elementDecl != null) {
XSTypeDecl type = elementDecl.fType;
if (type != null) {
- if (type.getXSType() == XSTypeDecl.COMPLEX_TYPE) {
+ if (type.getTypeCategory() == XSTypeDecl.COMPLEX_TYPE) {
XSComplexTypeDecl ctype = (XSComplexTypeDecl)type;
attrGrp = ctype.fAttrGrp;
}
@@ -438,7 +438,7 @@
XSSimpleType aValidator = null;
if (attrGrp != null) {
- XSAttributeUse tempAttUse = attrGrp.getAttributeUse(aname.uri, aname.localpart);
+ XSAttributeUseImpl tempAttUse = attrGrp.getAttributeUse(aname.uri, aname.localpart);
if (tempAttUse != null) {
XSAttributeDecl tempAttDecl = tempAttUse.fAttrDecl;
aValidator = tempAttDecl.fType;
@@ -531,7 +531,7 @@
if (eDecl!=null) {
XSTypeDecl type = eDecl.fType;
if (type != null) {
- if (type.getXSType() == XSTypeDecl.COMPLEX_TYPE) {
+ if (type.getTypeCategory() == XSTypeDecl.COMPLEX_TYPE) {
XSComplexTypeDecl ctype = (XSComplexTypeDecl)type;
val = ctype.fXSSimpleType;
}
@@ -542,7 +542,7 @@
}
if(eDecl != null) {
- matched(fMatchedString, val, (eDecl.isNillable()));
+ matched(fMatchedString, val, (eDecl.getIsNillable()));
} else
matched(fMatchedString, val, false);
1.9 +11 -11 xml-xerces/java/src/org/apache/xerces/impl/xs/models/CMBuilder.java
Index: CMBuilder.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/models/CMBuilder.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- CMBuilder.java 26 Apr 2002 22:03:42 -0000 1.8
+++ CMBuilder.java 16 May 2002 18:25:55 -0000 1.9
@@ -63,7 +63,7 @@
import org.apache.xerces.impl.xs.XSDeclarationPool;
import org.apache.xerces.impl.xs.XSComplexTypeDecl;
import org.apache.xerces.impl.xs.XSParticleDecl;
-import org.apache.xerces.impl.xs.XSModelGroup;
+import org.apache.xerces.impl.xs.XSModelGroupImpl;
import org.apache.xerces.impl.xs.XSElementDecl;
import org.apache.xerces.impl.xs.models.*;
@@ -73,7 +73,7 @@
* @author Elena Litani, IBM
* @author Sandy Gao, IBM
*
- * @version $Id: CMBuilder.java,v 1.8 2002/04/26 22:03:42 sandygao Exp $
+ * @version $Id: CMBuilder.java,v 1.9 2002/05/16 18:25:55 sandygao Exp $
*/
public class CMBuilder {
@@ -123,7 +123,7 @@
// we create an "all" content model, otherwise a DFA content model
XSCMValidator cmValidator = null;
if (particle.fType == XSParticleDecl.PARTICLE_MODELGROUP &&
- ((XSModelGroup)particle.fValue).fCompositor == XSModelGroup.MODELGROUP_ALL) {
+ ((XSModelGroupImpl)particle.fValue).fCompositor == XSModelGroupImpl.MODELGROUP_ALL) {
cmValidator = createAllCM(particle);
}
else {
@@ -147,7 +147,7 @@
XSAllCM allContent = new XSAllCM(particle.fMinOccurs == 0);
// get the model group, and add all children of it to the content model
- XSModelGroup group = (XSModelGroup)particle.fValue;
+ XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
for (int i = 0; i < group.fParticleCount; i++) {
// for all non-empty particles
if (group.fParticles[i].fType != XSParticleDecl.PARTICLE_EMPTY &&
@@ -197,7 +197,7 @@
}
else if (type == XSParticleDecl.PARTICLE_MODELGROUP) {
// (task 1,3) convert model groups to binary trees
- XSModelGroup group = (XSModelGroup)particle.fValue;
+ XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
CMNode temp = null;
for (int i = 0; i < group.fParticleCount; i++) {
// first convert each child to a CM tree
@@ -253,7 +253,7 @@
// (task 4) we need to call copyNode here, so that we append
// an entire new copy of the node (a subtree). this is to ensure
// all leaf nodes have distinct position
- nodeRet = new XSCMBinOp(XSModelGroup.MODELGROUP_SEQUENCE,
+ nodeRet = new XSCMBinOp(XSModelGroupImpl.MODELGROUP_SEQUENCE,
copyNode(node), nodeRet);
}
}
@@ -264,7 +264,7 @@
if (minOccurs > 0) {
nodeRet = node;
for (int i=0; i<minOccurs-1; i++) {
- nodeRet = new XSCMBinOp(XSModelGroup.MODELGROUP_SEQUENCE,
+ nodeRet = new XSCMBinOp(XSModelGroupImpl.MODELGROUP_SEQUENCE,
nodeRet, copyNode(node));
}
}
@@ -274,11 +274,11 @@
nodeRet = node;
}
else {
- nodeRet = new XSCMBinOp(XSModelGroup.MODELGROUP_SEQUENCE,
+ nodeRet = new XSCMBinOp(XSModelGroupImpl.MODELGROUP_SEQUENCE,
nodeRet, copyNode(node));
}
for (int i=minOccurs; i<maxOccurs-1; i++) {
- nodeRet = new XSCMBinOp(XSModelGroup.MODELGROUP_SEQUENCE,
+ nodeRet = new XSCMBinOp(XSModelGroupImpl.MODELGROUP_SEQUENCE,
nodeRet, node);
}
}
@@ -291,8 +291,8 @@
private CMNode copyNode(CMNode node) {
int type = node.type();
// for choice or sequence, copy the two subtrees, and combine them
- if (type == XSModelGroup.MODELGROUP_CHOICE ||
- type == XSModelGroup.MODELGROUP_SEQUENCE) {
+ if (type == XSModelGroupImpl.MODELGROUP_CHOICE ||
+ type == XSModelGroupImpl.MODELGROUP_SEQUENCE) {
XSCMBinOp bin = (XSCMBinOp)node;
node = new XSCMBinOp(type, copyNode(bin.getLeft()),
copyNode(bin.getRight()));
1.4 +9 -9 xml-xerces/java/src/org/apache/xerces/impl/xs/models/XSCMBinOp.java
Index: XSCMBinOp.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/models/XSCMBinOp.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XSCMBinOp.java 26 Apr 2002 22:03:42 -0000 1.3
+++ XSCMBinOp.java 16 May 2002 18:25:55 -0000 1.4
@@ -60,7 +60,7 @@
import org.apache.xerces.impl.dtd.models.CMNode;
import org.apache.xerces.impl.dtd.models.CMStateSet;
import org.apache.xerces.impl.xs.XSParticleDecl;
-import org.apache.xerces.impl.xs.XSModelGroup;
+import org.apache.xerces.impl.xs.XSModelGroupImpl;
/**
*
@@ -78,8 +78,8 @@
super(type);
// Insure that its one of the types we require
- if ((type() != XSModelGroup.MODELGROUP_CHOICE)
- && (type() != XSModelGroup.MODELGROUP_SEQUENCE)) {
+ if ((type() != XSModelGroupImpl.MODELGROUP_CHOICE)
+ && (type() != XSModelGroupImpl.MODELGROUP_SEQUENCE)) {
throw new RuntimeException("ImplementationMessages.VAL_BST");
}
@@ -110,9 +110,9 @@
// this node is nullable. If its a concatenation, then both of
// them have to be nullable.
//
- if (type() == XSModelGroup.MODELGROUP_CHOICE)
+ if (type() == XSModelGroupImpl.MODELGROUP_CHOICE)
return (fLeftChild.isNullable() || fRightChild.isNullable());
- else if (type() == XSModelGroup.MODELGROUP_SEQUENCE)
+ else if (type() == XSModelGroupImpl.MODELGROUP_SEQUENCE)
return (fLeftChild.isNullable() && fRightChild.isNullable());
else
throw new RuntimeException("ImplementationMessages.VAL_BST");
@@ -123,12 +123,12 @@
// Protected, inherited methods
// -------------------------------------------------------------------
protected void calcFirstPos(CMStateSet toSet) {
- if (type() == XSModelGroup.MODELGROUP_CHOICE) {
+ if (type() == XSModelGroupImpl.MODELGROUP_CHOICE) {
// Its the the union of the first positions of our children.
toSet.setTo(fLeftChild.firstPos());
toSet.union(fRightChild.firstPos());
}
- else if (type() == XSModelGroup.MODELGROUP_SEQUENCE) {
+ else if (type() == XSModelGroupImpl.MODELGROUP_SEQUENCE) {
//
// If our left child is nullable, then its the union of our
// children's first positions. Else is our left child's first
@@ -144,12 +144,12 @@
}
protected void calcLastPos(CMStateSet toSet) {
- if (type() == XSModelGroup.MODELGROUP_CHOICE) {
+ if (type() == XSModelGroupImpl.MODELGROUP_CHOICE) {
// Its the the union of the first positions of our children.
toSet.setTo(fLeftChild.lastPos());
toSet.union(fRightChild.lastPos());
}
- else if (type() == XSModelGroup.MODELGROUP_SEQUENCE) {
+ else if (type() == XSModelGroupImpl.MODELGROUP_SEQUENCE) {
//
// If our right child is nullable, then its the union of our
// children's last positions. Else is our right child's last
1.6 +12 -12 xml-xerces/java/src/org/apache/xerces/impl/xs/models/XSDFACM.java
Index: XSDFACM.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/models/XSDFACM.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XSDFACM.java 26 Apr 2002 22:03:42 -0000 1.5
+++ XSDFACM.java 16 May 2002 18:25:55 -0000 1.6
@@ -64,7 +64,7 @@
import org.apache.xerces.impl.xs.SubstitutionGroupHandler;
import org.apache.xerces.impl.xs.XSElementDecl;
import org.apache.xerces.impl.xs.XSParticleDecl;
-import org.apache.xerces.impl.xs.XSModelGroup;
+import org.apache.xerces.impl.xs.XSModelGroupImpl;
import org.apache.xerces.impl.xs.XSWildcardDecl;
import org.apache.xerces.impl.xs.XMLSchemaException;
import org.apache.xerces.impl.xs.XSConstraints;
@@ -76,7 +76,7 @@
* it then uses in its validation algorithm.
*
* @author Neil Graham, IBM
- * @version $Id: XSDFACM.java,v 1.5 2002/04/26 22:03:42 sandygao Exp $
+ * @version $Id: XSDFACM.java,v 1.6 2002/05/16 18:25:55 sandygao Exp $
*/
public class XSDFACM
implements XSCMValidator {
@@ -418,7 +418,7 @@
fEOCPos = fLeafCount;
XSCMLeaf nodeEOC = new XSCMLeaf(XSParticleDecl.PARTICLE_ELEMENT, null, -1, fLeafCount++);
fHeadNode = new XSCMBinOp(
- XSModelGroup.MODELGROUP_SEQUENCE,
+ XSModelGroupImpl.MODELGROUP_SEQUENCE,
syntaxTree,
nodeEOC
);
@@ -722,12 +722,12 @@
*/
private void calcFollowList(CMNode nodeCur) {
// Recurse as required
- if (nodeCur.type() == XSModelGroup.MODELGROUP_CHOICE) {
+ if (nodeCur.type() == XSModelGroupImpl.MODELGROUP_CHOICE) {
// Recurse only
calcFollowList(((XSCMBinOp)nodeCur).getLeft());
calcFollowList(((XSCMBinOp)nodeCur).getRight());
}
- else if (nodeCur.type() == XSModelGroup.MODELGROUP_SEQUENCE) {
+ else if (nodeCur.type() == XSModelGroupImpl.MODELGROUP_SEQUENCE) {
// Recurse first
calcFollowList(((XSCMBinOp)nodeCur).getLeft());
calcFollowList(((XSCMBinOp)nodeCur).getRight());
@@ -796,9 +796,9 @@
switch(type ) {
- case XSModelGroup.MODELGROUP_CHOICE:
- case XSModelGroup.MODELGROUP_SEQUENCE: {
- if (type == XSModelGroup.MODELGROUP_CHOICE)
+ case XSModelGroupImpl.MODELGROUP_CHOICE:
+ case XSModelGroupImpl.MODELGROUP_SEQUENCE: {
+ if (type == XSModelGroupImpl.MODELGROUP_CHOICE)
System.out.print("Choice Node ");
else
System.out.print("Seq Node ");
@@ -894,8 +894,8 @@
fLeafList[pos] = leaf;
fLeafListType[pos] = XSParticleDecl.PARTICLE_WILDCARD;
}
- else if ((nodeCur.type() == XSModelGroup.MODELGROUP_CHOICE) ||
- (nodeCur.type() == XSModelGroup.MODELGROUP_SEQUENCE)) {
+ else if ((nodeCur.type() == XSModelGroupImpl.MODELGROUP_CHOICE) ||
+ (nodeCur.type() == XSModelGroupImpl.MODELGROUP_SEQUENCE)) {
postTreeBuildInit(((XSCMBinOp)nodeCur).getLeft());
postTreeBuildInit(((XSCMBinOp)nodeCur).getRight());
}
@@ -965,8 +965,8 @@
for (int i = 0; i < fElemMapSize; i++) {
if (fElemMapType[i] == XSParticleDecl.PARTICLE_WILDCARD) {
XSWildcardDecl wildcard = (XSWildcardDecl)fElemMap[i];
- if (wildcard.fType == XSWildcardDecl.WILDCARD_LIST ||
- wildcard.fType == XSWildcardDecl.WILDCARD_OTHER) {
+ if (wildcard.fType == XSWildcardDecl.NSCONSTRAINT_LIST ||
+ wildcard.fType == XSWildcardDecl.NSCONSTRAINT_NOT) {
return true;
}
}
1.2 +3 -3 xml-xerces/java/src/org/apache/xerces/impl/xs/psvi/XSTypeDefinition.java
Index: XSTypeDefinition.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/psvi/XSTypeDefinition.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XSTypeDefinition.java 13 May 2002 21:31:34 -0000 1.1
+++ XSTypeDefinition.java 16 May 2002 18:25:55 -0000 1.2
@@ -61,18 +61,18 @@
* This interface represents a complex or simple type definition.
*
* @author Elena Litani, IBM
- * @version $Id: XSTypeDefinition.java,v 1.1 2002/05/13 21:31:34 sandygao Exp $
+ * @version $Id: XSTypeDefinition.java,v 1.2 2002/05/16 18:25:55 sandygao Exp $
*/
public interface XSTypeDefinition extends XSObject {
/**
* This constant value signifies a complex type.
*/
- public static final short COMPLEX_TYPE = 101;
+ public static final short COMPLEX_TYPE = XSConstants.ANNOTATION+1;
/**
* This constant value signifies a simple type.
*/
- public static final short SIMPLE_TYPE = 102;
+ public static final short SIMPLE_TYPE = XSConstants.ANNOTATION+2;
/**
* Return whether this type definition is a simple type or complex type.
1.12 +30 -29 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java
Index: XSAttributeChecker.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- XSAttributeChecker.java 15 Mar 2002 23:01:57 -0000 1.11
+++ XSAttributeChecker.java 16 May 2002 18:25:55 -0000 1.12
@@ -76,6 +76,7 @@
import org.apache.xerces.util.SymbolTable;
import org.apache.xerces.impl.xs.util.XInt;
import org.apache.xerces.impl.xs.util.XIntPool;
+import org.apache.xerces.impl.xs.psvi.XSConstants;
import org.apache.xerces.xni.QName;
/**
@@ -98,7 +99,7 @@
* - use symbol table instead of many hashtables
*
* @author Sandy Gao, IBM
- * @version $Id: XSAttributeChecker.java,v 1.11 2002/03/15 23:01:57 sandygao Exp $
+ * @version $Id: XSAttributeChecker.java,v 1.12 2002/05/16 18:25:55 sandygao Exp $
*/
public class XSAttributeChecker {
@@ -156,16 +157,16 @@
// constants to return
private static final XInt INT_QUALIFIED = fXIntPool.getXInt(SchemaSymbols.FORM_QUALIFIED);
private static final XInt INT_UNQUALIFIED = fXIntPool.getXInt(SchemaSymbols.FORM_UNQUALIFIED);
- private static final XInt INT_EMPTY_SET = fXIntPool.getXInt(SchemaSymbols.EMPTY_SET);
- private static final XInt INT_ANY_STRICT = fXIntPool.getXInt(SchemaSymbols.ANY_STRICT);
- private static final XInt INT_ANY_LAX = fXIntPool.getXInt(SchemaSymbols.ANY_LAX);
- private static final XInt INT_ANY_SKIP = fXIntPool.getXInt(SchemaSymbols.ANY_SKIP);
+ private static final XInt INT_EMPTY_SET = fXIntPool.getXInt(XSConstants.DERIVATION_NONE);
+ private static final XInt INT_ANY_STRICT = fXIntPool.getXInt(XSWildcardDecl.PC_STRICT);
+ private static final XInt INT_ANY_LAX = fXIntPool.getXInt(XSWildcardDecl.PC_LAX);
+ private static final XInt INT_ANY_SKIP = fXIntPool.getXInt(XSWildcardDecl.PC_SKIP);
private static final XInt INT_USE_OPTIONAL = fXIntPool.getXInt(SchemaSymbols.USE_OPTIONAL);
private static final XInt INT_USE_REQUIRED = fXIntPool.getXInt(SchemaSymbols.USE_REQUIRED);
private static final XInt INT_USE_PROHIBITED = fXIntPool.getXInt(SchemaSymbols.USE_PROHIBITED);
- private static final XInt INT_WS_PRESERVE = fXIntPool.getXInt(SchemaSymbols.WS_PRESERVE);
- private static final XInt INT_WS_REPLACE = fXIntPool.getXInt(SchemaSymbols.WS_REPLACE);
- private static final XInt INT_WS_COLLAPSE = fXIntPool.getXInt(SchemaSymbols.WS_COLLAPSE);
+ private static final XInt INT_WS_PRESERVE = fXIntPool.getXInt(XSSimpleType.WS_PRESERVE);
+ private static final XInt INT_WS_REPLACE = fXIntPool.getXInt(XSSimpleType.WS_REPLACE);
+ private static final XInt INT_WS_COLLAPSE = fXIntPool.getXInt(XSSimpleType.WS_COLLAPSE);
private static final XInt INT_UNBOUNDED = fXIntPool.getXInt(SchemaSymbols.OCCURRENCE_UNBOUNDED);
// default wildcard to return
@@ -1234,9 +1235,9 @@
// block = (#all | List of (substitution | extension | restriction | list | union))
choice = 0;
if (value.equals (SchemaSymbols.ATTVAL_POUNDALL)) {
- choice = SchemaSymbols.SUBSTITUTION|SchemaSymbols.EXTENSION|
- SchemaSymbols.RESTRICTION|SchemaSymbols.LIST|
- SchemaSymbols.UNION;
+ choice = XSConstants.DERIVATION_SUBSTITUTION|XSConstants.DERIVATION_EXTENSION|
+ XSConstants.DERIVATION_RESTRICTION|XSConstants.DERIVATION_LIST|
+ XSConstants.DERIVATION_UNION;
}
else {
StringTokenizer t = new StringTokenizer (value, " ");
@@ -1244,19 +1245,19 @@
String token = t.nextToken ();
if (token.equals (SchemaSymbols.ATTVAL_SUBSTITUTION)) {
- choice |= SchemaSymbols.SUBSTITUTION;
+ choice |= XSConstants.DERIVATION_SUBSTITUTION;
}
else if (token.equals (SchemaSymbols.ATTVAL_EXTENSION)) {
- choice |= SchemaSymbols.EXTENSION;
+ choice |= XSConstants.DERIVATION_EXTENSION;
}
else if (token.equals (SchemaSymbols.ATTVAL_RESTRICTION)) {
- choice |= SchemaSymbols.RESTRICTION;
+ choice |= XSConstants.DERIVATION_RESTRICTION;
}
else if (token.equals (SchemaSymbols.ATTVAL_LIST)) {
- choice |= SchemaSymbols.LIST;
+ choice |= XSConstants.DERIVATION_LIST;
}
else if (token.equals (SchemaSymbols.ATTVAL_UNION)) {
- choice |= SchemaSymbols.RESTRICTION;
+ choice |= XSConstants.DERIVATION_RESTRICTION;
}
else {
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3", new Object[]{value, "(#all | List of (substitution | extension | restriction | list | union))"});
@@ -1282,9 +1283,9 @@
// finalDefault="extension restriction".
// if finalDefault="#all", final on any simple type would be
// "extension restriction list union".
- choice = SchemaSymbols.SUBSTITUTION|SchemaSymbols.EXTENSION|
- SchemaSymbols.RESTRICTION|SchemaSymbols.LIST|
- SchemaSymbols.UNION;
+ choice = XSConstants.DERIVATION_SUBSTITUTION|XSConstants.DERIVATION_EXTENSION|
+ XSConstants.DERIVATION_RESTRICTION|XSConstants.DERIVATION_LIST|
+ XSConstants.DERIVATION_UNION;
}
else {
StringTokenizer t = new StringTokenizer (value, " ");
@@ -1292,10 +1293,10 @@
String token = t.nextToken ();
if (token.equals (SchemaSymbols.ATTVAL_EXTENSION)) {
- choice |= SchemaSymbols.EXTENSION;
+ choice |= XSConstants.DERIVATION_EXTENSION;
}
else if (token.equals (SchemaSymbols.ATTVAL_RESTRICTION)) {
- choice |= SchemaSymbols.RESTRICTION;
+ choice |= XSConstants.DERIVATION_RESTRICTION;
}
else {
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3", new Object[]{value, "(#all | List of (extension | restriction))"});
@@ -1314,18 +1315,18 @@
// everything: substitution/externsion/restriction/list/union.
// would this be a problem?
// same reason as above DT_BLOCK1/DT_FINAL
- choice = SchemaSymbols.SUBSTITUTION|SchemaSymbols.EXTENSION|
- SchemaSymbols.RESTRICTION|SchemaSymbols.LIST|
- SchemaSymbols.UNION;
+ choice = XSConstants.DERIVATION_SUBSTITUTION|XSConstants.DERIVATION_EXTENSION|
+ XSConstants.DERIVATION_RESTRICTION|XSConstants.DERIVATION_LIST|
+ XSConstants.DERIVATION_UNION;
}
else if (value.equals (SchemaSymbols.ATTVAL_LIST)) {
- choice = SchemaSymbols.LIST;
+ choice = XSConstants.DERIVATION_LIST;
}
else if (value.equals (SchemaSymbols.ATTVAL_UNION)) {
- choice = SchemaSymbols.UNION;
+ choice = XSConstants.DERIVATION_UNION;
}
else if (value.equals (SchemaSymbols.ATTVAL_RESTRICTION)) {
- choice = SchemaSymbols.RESTRICTION;
+ choice = XSConstants.DERIVATION_RESTRICTION;
}
else {
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.3", new Object[]{value, "(#all | (list | union | restriction))"});
@@ -1400,14 +1401,14 @@
} else if (value.equals(SchemaSymbols.ATTVAL_TWOPOUNDOTHER)) {
// ##other
wildcard = fTempWC;
- wildcard.fType = XSWildcardDecl.WILDCARD_OTHER;
+ wildcard.fType = XSWildcardDecl.NSCONSTRAINT_NOT;
wildcard.fNamespaceList = new String[2];
wildcard.fNamespaceList[0] = schemaDoc.fTargetNamespace;
wildcard.fNamespaceList[1] = null;
} else {
// list
wildcard = fTempWC;
- wildcard.fType = XSWildcardDecl.WILDCARD_LIST;
+ wildcard.fType = XSWildcardDecl.NSCONSTRAINT_LIST;
// tokenize
StringTokenizer tokens = new StringTokenizer(value);
1.10 +7 -7 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAbstractParticleTraverser.java
Index: XSDAbstractParticleTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAbstractParticleTraverser.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- XSDAbstractParticleTraverser.java 7 May 2002 15:54:27 -0000 1.9
+++ XSDAbstractParticleTraverser.java 16 May 2002 18:25:55 -0000 1.10
@@ -60,7 +60,7 @@
import org.apache.xerces.impl.xs.SchemaGrammar;
import org.apache.xerces.impl.xs.SchemaSymbols;
import org.apache.xerces.impl.xs.XSParticleDecl;
-import org.apache.xerces.impl.xs.XSModelGroup;
+import org.apache.xerces.impl.xs.XSModelGroupImpl;
import org.apache.xerces.impl.xs.XSComplexTypeDecl;
import org.apache.xerces.util.DOMUtil;
import org.apache.xerces.impl.xs.util.XInt;
@@ -69,7 +69,7 @@
/**
* @author Elena Litani, IBM
* @author Sandy Gao, IBM
- * @version $Id: XSDAbstractParticleTraverser.java,v 1.9 2002/05/07 15:54:27 sandygao Exp $
+ * @version $Id: XSDAbstractParticleTraverser.java,v 1.10 2002/05/16 18:25:55 sandygao Exp $
*/
abstract class XSDAbstractParticleTraverser extends XSDAbstractTraverser {
@@ -140,8 +140,8 @@
XInt maxAtt = (XInt)attrValues[XSAttributeChecker.ATTIDX_MAXOCCURS];
Long defaultVals = (Long)attrValues[XSAttributeChecker.ATTIDX_FROMDEFAULT];
- XSModelGroup group = new XSModelGroup();
- group.fCompositor = XSModelGroup.MODELGROUP_ALL;
+ XSModelGroupImpl group = new XSModelGroupImpl();
+ group.fCompositor = XSModelGroupImpl.MODELGROUP_ALL;
group.fParticleCount = fPArray.getParticleCount();
group.fParticles = fPArray.popContext();
particle = new XSParticleDecl();
@@ -300,8 +300,8 @@
XInt maxAtt = (XInt)attrValues[XSAttributeChecker.ATTIDX_MAXOCCURS];
Long defaultVals = (Long)attrValues[XSAttributeChecker.ATTIDX_FROMDEFAULT];
- XSModelGroup group = new XSModelGroup();
- group.fCompositor = choice ? XSModelGroup.MODELGROUP_CHOICE : XSModelGroup.MODELGROUP_SEQUENCE;
+ XSModelGroupImpl group = new XSModelGroupImpl();
+ group.fCompositor = choice ? XSModelGroupImpl.MODELGROUP_CHOICE : XSModelGroupImpl.MODELGROUP_SEQUENCE;
group.fParticleCount = fPArray.getParticleCount();
group.fParticles = fPArray.popContext();
particle = new XSParticleDecl();
@@ -328,7 +328,7 @@
protected boolean hasAllContent(XSParticleDecl particle) {
// If the content is not empty, is the top node ALL?
if (particle != null && particle.fType == XSParticleDecl.PARTICLE_MODELGROUP) {
- return ((XSModelGroup)particle.fValue).fCompositor == XSModelGroup.MODELGROUP_ALL;
+ return ((XSModelGroupImpl)particle.fValue).fCompositor == XSModelGroupImpl.MODELGROUP_ALL;
}
return false;
1.17 +22 -23 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
Index: XSDAbstractTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- XSDAbstractTraverser.java 7 May 2002 15:54:27 -0000 1.16
+++ XSDAbstractTraverser.java 16 May 2002 18:25:55 -0000 1.17
@@ -59,9 +59,6 @@
import org.apache.xerces.impl.xs.util.XInt;
import org.apache.xerces.impl.dv.XSSimpleType;
-import org.apache.xerces.impl.dv.XSAtomicSimpleType;
-import org.apache.xerces.impl.dv.XSListSimpleType;
-import org.apache.xerces.impl.dv.XSUnionSimpleType;
import org.apache.xerces.impl.dv.XSFacets;
import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
import org.apache.xerces.impl.xs.SchemaGrammar;
@@ -69,11 +66,12 @@
import org.apache.xerces.impl.xs.XSMessageFormatter;
import org.apache.xerces.impl.xs.XSNotationDecl;
import org.apache.xerces.impl.xs.XSAttributeGroupDecl;
-import org.apache.xerces.impl.xs.XSAttributeUse;
+import org.apache.xerces.impl.xs.XSAttributeUseImpl;
import org.apache.xerces.impl.xs.XSWildcardDecl;
import org.apache.xerces.impl.xs.XSTypeDecl;
import org.apache.xerces.impl.xs.XSComplexTypeDecl;
import org.apache.xerces.impl.xs.XSParticleDecl;
+import org.apache.xerces.impl.xs.psvi.XSObjectList;
import org.apache.xerces.xni.QName;
import org.apache.xerces.util.SymbolTable;
import org.apache.xerces.util.NamespaceSupport;
@@ -93,7 +91,7 @@
* @author Rahul Srivastava, Sun Microsystems Inc.
* @author Neeraj Bajaj, Sun Microsystems Inc.
*
- * @version $Id: XSDAbstractTraverser.java,v 1.16 2002/05/07 15:54:27 sandygao Exp $
+ * @version $Id: XSDAbstractTraverser.java,v 1.17 2002/05/16 18:25:55 sandygao Exp $
*/
abstract class XSDAbstractTraverser {
@@ -203,7 +201,7 @@
// for NOTATION types, need to check whether there is a notation
// declared with the same name as the enumeration value.
if (baseValidator.getVariety() == XSSimpleType.VARIETY_ATOMIC &&
- ((XSAtomicSimpleType)baseValidator).getPrimitiveKind() == XSAtomicSimpleType.PRIMITIVE_NOTATION) {
+ baseValidator.getPrimitiveKind() == XSSimpleType.PRIMITIVE_NOTATION) {
// need to use the namespace context returned from checkAttributes
schemaDoc.fValidationContext.setNamespaceSupport(nsDecls);
try{
@@ -377,17 +375,17 @@
// return whether QName/NOTATION is part of the given type
private boolean containsQName(XSSimpleType type) {
if (type.getVariety() == XSSimpleType.VARIETY_ATOMIC) {
- short primitive = ((XSAtomicSimpleType)type).getPrimitiveKind();
- return (primitive == XSAtomicSimpleType.PRIMITIVE_QNAME ||
- primitive == XSAtomicSimpleType.PRIMITIVE_NOTATION);
+ short primitive = type.getPrimitiveKind();
+ return (primitive == XSSimpleType.PRIMITIVE_QNAME ||
+ primitive == XSSimpleType.PRIMITIVE_NOTATION);
}
else if (type.getVariety() == XSSimpleType.VARIETY_LIST) {
- return containsQName(((XSListSimpleType)type).getItemType());
+ return containsQName((XSSimpleType)type.getItemType());
}
else if (type.getVariety() == XSSimpleType.VARIETY_UNION) {
- XSSimpleType[] members = ((XSUnionSimpleType)type).getMemberTypes();
- for (int i = 0; i < members.length; i++) {
- if (containsQName(members[i]))
+ XSObjectList members = type.getMemberTypes();
+ for (int i = 0; i < members.getListLength(); i++) {
+ if (containsQName((XSSimpleType)members.getItem(i)))
return true;
}
}
@@ -405,7 +403,7 @@
Element child=null;
XSAttributeGroupDecl tempAttrGrp = null;
- XSAttributeUse tempAttrUse = null;
+ XSAttributeUseImpl tempAttrUse = null;
String childName;
for (child=firstAttr; child!=null; child=DOMUtil.getNextSiblingElement(child)) {
@@ -433,16 +431,17 @@
tempAttrGrp = fSchemaHandler.fAttributeGroupTraverser.traverseLocal(
child, schemaDoc, grammar);
if(tempAttrGrp == null ) break;
- XSAttributeUse[] attrUseS = tempAttrGrp.getAttributeUses();
- XSAttributeUse existingAttrUse = null;
- int attrCount = (attrUseS !=null)?attrUseS.length:0;
+ XSObjectList attrUseS = tempAttrGrp.getAttributeUses();
+ XSAttributeUseImpl existingAttrUse = null, oneAttrUse;
+ int attrCount = attrUseS.getListLength();
for (int i=0; i<attrCount; i++) {
- existingAttrUse = attrGrp.getAttributeUse(attrUseS[i].fAttrDecl.fTargetNamespace,
- attrUseS[i].fAttrDecl.fName);
+ oneAttrUse = (XSAttributeUseImpl)attrUseS.getItem(i);
+ existingAttrUse = attrGrp.getAttributeUse(oneAttrUse.fAttrDecl.fTargetNamespace,
+ oneAttrUse.fAttrDecl.fName);
if (existingAttrUse == null) {
- String idName = attrGrp.addAttributeUse(attrUseS[i]);
+ String idName = attrGrp.addAttributeUse(oneAttrUse);
if (idName != null) {
- reportSchemaError("cvc-complex-type.5.3", new Object[]{attrUseS[i].fAttrDecl.fName, idName}, child);
+ reportSchemaError("cvc-complex-type.5.3", new Object[]{oneAttrUse.fAttrDecl.fName, idName}, child);
}
}
else {
@@ -503,9 +502,9 @@
* the type is NOTATION without enumeration facet
*/
void checkNotationType(String refName, XSTypeDecl typeDecl, Element elem) {
- if (typeDecl.getXSType() == typeDecl.SIMPLE_TYPE &&
+ if (typeDecl.getTypeCategory() == typeDecl.SIMPLE_TYPE &&
((XSSimpleType)typeDecl).getVariety() == XSSimpleType.VARIETY_ATOMIC &&
- ((XSAtomicSimpleType)typeDecl).getPrimitiveKind() == XSAtomicSimpleType.PRIMITIVE_NOTATION) {
+ ((XSSimpleType)typeDecl).getPrimitiveKind() == XSSimpleType.PRIMITIVE_NOTATION) {
if ((((XSSimpleType)typeDecl).getDefinedFacets() & XSSimpleType.FACET_ENUMERATION) == 0) {
reportSchemaError("enumeration-required-notation", new Object[]{refName}, elem);
}
1.15 +21 -20 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java
Index: XSDAttributeTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- XSDAttributeTraverser.java 7 May 2002 15:54:27 -0000 1.14
+++ XSDAttributeTraverser.java 16 May 2002 18:25:55 -0000 1.15
@@ -65,7 +65,7 @@
import org.apache.xerces.impl.xs.SchemaGrammar;
import org.apache.xerces.impl.xs.SchemaSymbols;
import org.apache.xerces.impl.xs.XSAttributeDecl;
-import org.apache.xerces.impl.xs.XSAttributeUse;
+import org.apache.xerces.impl.xs.XSAttributeUseImpl;
import org.apache.xerces.impl.xs.XSElementDecl;
import org.apache.xerces.impl.xs.XSTypeDecl;
import org.apache.xerces.impl.xs.XSComplexTypeDecl;
@@ -73,6 +73,7 @@
import org.apache.xerces.util.DOMUtil;
import org.apache.xerces.util.SymbolTable;
import org.apache.xerces.impl.xs.util.XInt;
+import org.apache.xerces.impl.xs.psvi.XSConstants;
import org.apache.xerces.impl.validation.ValidationState;
import org.w3c.dom.Element;
@@ -94,7 +95,7 @@
*
* @author Sandy Gao, IBM
* @author Neeraj Bajaj, Sun Microsystems, inc.
- * @version $Id: XSDAttributeTraverser.java,v 1.14 2002/05/07 15:54:27 sandygao Exp $
+ * @version $Id: XSDAttributeTraverser.java,v 1.15 2002/05/16 18:25:55 sandygao Exp $
*/
class XSDAttributeTraverser extends XSDAbstractTraverser {
@@ -103,10 +104,10 @@
super(handler, gAttrCheck);
}
- protected XSAttributeUse traverseLocal(Element attrDecl,
- XSDocumentInfo schemaDoc,
- SchemaGrammar grammar,
- XSComplexTypeDecl enclosingCT) {
+ protected XSAttributeUseImpl traverseLocal(Element attrDecl,
+ XSDocumentInfo schemaDoc,
+ SchemaGrammar grammar,
+ XSComplexTypeDecl enclosingCT) {
// General Attribute Checking
Object[] attrValues = fAttrChecker.checkAttributes(attrDecl, false, schemaDoc);
@@ -142,21 +143,21 @@
}
// get 'value constraint'
- short consType = XSAttributeDecl.NO_CONSTRAINT;
+ short consType = XSConstants.VC_NONE;
if (defaultAtt != null) {
- consType = XSAttributeDecl.DEFAULT_VALUE;
+ consType = XSConstants.VC_DEFAULT;
} else if (fixedAtt != null) {
- consType = XSAttributeDecl.FIXED_VALUE;
+ consType = XSConstants.VC_FIXED;
defaultAtt = fixedAtt;
fixedAtt = null;
}
- XSAttributeUse attrUse = null;
+ XSAttributeUseImpl attrUse = null;
if (attribute != null) {
if (fSchemaHandler.fDeclPool !=null) {
attrUse = fSchemaHandler.fDeclPool.getAttributeUse();
} else {
- attrUse = new XSAttributeUse();
+ attrUse = new XSAttributeUseImpl();
}
attrUse.fAttrDecl = attribute;
attrUse.fUse = useAtt.shortValue();
@@ -176,7 +177,7 @@
}
// 2 If default and use are both present, use must have the actual value optional.
- if (consType == XSAttributeDecl.DEFAULT_VALUE &&
+ if (consType == XSConstants.VC_DEFAULT &&
useAtt != null && useAtt.intValue() != SchemaSymbols.USE_OPTIONAL) {
reportSchemaError("src-attribute.2", new Object[]{nameAtt}, attrDecl);
}
@@ -198,9 +199,9 @@
// check 3.5.6 constraint
// Attribute Use Correct
// 2 If the {attribute declaration} has a fixed {value constraint}, then if the attribute use itself has a {value constraint}, it must also be fixed and its value must match that of the {attribute declaration}'s {value constraint}.
- if (attrUse.fAttrDecl.getConstraintType() == XSAttributeDecl.FIXED_VALUE &&
- attrUse.fConstraintType != XSAttributeDecl.NO_CONSTRAINT) {
- if (attrUse.fConstraintType != XSAttributeDecl.FIXED_VALUE ||
+ if (attrUse.fAttrDecl.getConstraintType() == XSConstants.VC_FIXED &&
+ attrUse.fConstraintType != XSConstants.VC_NONE) {
+ if (attrUse.fConstraintType != XSConstants.VC_FIXED ||
!attrUse.fAttrDecl.fType.isEqual(attrUse.fAttrDecl.fDefault.actualValue,
attrUse.fDefault.actualValue)) {
reportSchemaError ("au-props-correct.2", new Object[]{nameAtt}, attrDecl);
@@ -284,13 +285,13 @@
if (fixedAtt != null) {
attribute.fDefault = new ValidatedInfo();
attribute.fDefault.normalizedValue = fixedAtt;
- attribute.setConstraintType(XSElementDecl.FIXED_VALUE);
+ attribute.setConstraintType(XSConstants.VC_FIXED);
} else if (defaultAtt != null) {
attribute.fDefault = new ValidatedInfo();
attribute.fDefault.normalizedValue = defaultAtt;
- attribute.setConstraintType(XSElementDecl.DEFAULT_VALUE);
+ attribute.setConstraintType(XSConstants.VC_DEFAULT);
} else {
- attribute.setConstraintType(XSElementDecl.NO_CONSTRAINT);
+ attribute.setConstraintType(XSConstants.VC_NONE);
}
}
@@ -319,7 +320,7 @@
// Handler type attribute
if (attrType == null && typeAtt != null) {
XSTypeDecl type = (XSTypeDecl)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.TYPEDECL_TYPE, typeAtt, attrDecl);
- if (type != null && type.getXSType() == XSTypeDecl.SIMPLE_TYPE)
+ if (type != null && type.getTypeCategory() == XSTypeDecl.SIMPLE_TYPE)
attrType = (XSSimpleType)type;
else
reportSchemaError("src-resolve", new Object[]{typeAtt.rawname, "simpleType definition"}, attrDecl);
@@ -429,7 +430,7 @@
}
// return whether the constraint value is valid for the given type
- boolean checkDefaultValid(XSAttributeUse attrUse) {
+ boolean checkDefaultValid(XSAttributeUseImpl attrUse) {
boolean ret = true;
1.20 +32 -29 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java
Index: XSDComplexTypeTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- XSDComplexTypeTraverser.java 7 May 2002 15:54:27 -0000 1.19
+++ XSDComplexTypeTraverser.java 16 May 2002 18:25:55 -0000 1.20
@@ -66,13 +66,15 @@
import org.apache.xerces.impl.xs.XSComplexTypeDecl;
import org.apache.xerces.impl.xs.XSTypeDecl;
import org.apache.xerces.impl.xs.XSAttributeGroupDecl;
-import org.apache.xerces.impl.xs.XSAttributeUse;
+import org.apache.xerces.impl.xs.XSAttributeUseImpl;
import org.apache.xerces.impl.xs.XSWildcardDecl;
import org.apache.xerces.impl.xs.XSParticleDecl;
-import org.apache.xerces.impl.xs.XSModelGroup;
+import org.apache.xerces.impl.xs.XSModelGroupImpl;
import org.apache.xerces.util.DOMUtil;
import org.apache.xerces.impl.xs.util.XInt;
import org.apache.xerces.impl.xs.util.XIntPool;
+import org.apache.xerces.impl.xs.psvi.XSConstants;
+import org.apache.xerces.impl.xs.psvi.XSObjectList;
import org.apache.xerces.xni.QName;
import org.w3c.dom.Element;
import java.util.Hashtable;
@@ -92,7 +94,7 @@
* ((group | all | choice | sequence)?,
* ((attribute | attributeGroup)*, anyAttribute?))))
* </complexType>
- * @version $Id: XSDComplexTypeTraverser.java,v 1.19 2002/05/07 15:54:27 sandygao Exp $
+ * @version $Id: XSDComplexTypeTraverser.java,v 1.20 2002/05/16 18:25:55 sandygao Exp $
*/
class XSDComplexTypeTraverser extends XSDAbstractParticleTraverser {
@@ -330,9 +332,9 @@
// -----------------------------------------------------------------------
String simpleContentName = DOMUtil.getLocalName(simpleContent);
if (simpleContentName.equals(SchemaSymbols.ELT_RESTRICTION))
- typeInfo.fDerivedBy = SchemaSymbols.RESTRICTION;
+ typeInfo.fDerivedBy = XSConstants.DERIVATION_RESTRICTION;
else if (simpleContentName.equals(SchemaSymbols.ELT_EXTENSION))
- typeInfo.fDerivedBy = SchemaSymbols.EXTENSION;
+ typeInfo.fDerivedBy = XSConstants.DERIVATION_EXTENSION;
else {
throw new ComplexTypeRecoverableError("src-ct.0.1",
new Object[]{typeInfo.fName,simpleContentName},
@@ -373,7 +375,7 @@
int baseFinalSet = 0;
// If the base type is complex, it must have simpleContent
- if ((type.getXSType() == XSTypeDecl.COMPLEX_TYPE)) {
+ if ((type.getTypeCategory() == XSTypeDecl.COMPLEX_TYPE)) {
baseComplexType = (XSComplexTypeDecl)type;
if (baseComplexType.fContentType != XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
@@ -385,18 +387,18 @@
}
else {
baseValidator = (XSSimpleType)type;
- if (typeInfo.fDerivedBy == SchemaSymbols.RESTRICTION) {
+ if (typeInfo.fDerivedBy == XSConstants.DERIVATION_RESTRICTION) {
throw new ComplexTypeRecoverableError("src-ct.2",
new Object[]{typeInfo.fName}, simpleContent);
}
- baseFinalSet=baseValidator.getFinalSet();
+ baseFinalSet=baseValidator.getFinal();
}
// -----------------------------------------------------------------------
// Check that the base permits the derivation
// -----------------------------------------------------------------------
if ((baseFinalSet & typeInfo.fDerivedBy)!=0) {
- String errorKey = (typeInfo.fDerivedBy==SchemaSymbols.EXTENSION) ?
+ String errorKey = (typeInfo.fDerivedBy==XSConstants.DERIVATION_EXTENSION) ?
"cos-ct-extends.1.1" : "derivation-ok-restriction.1";
throw new ComplexTypeRecoverableError(errorKey,
new Object[]{typeInfo.fName}, simpleContent);
@@ -425,7 +427,7 @@
// -----------------------------------------------------------------------
// Process a RESTRICTION
// -----------------------------------------------------------------------
- if (typeInfo.fDerivedBy == SchemaSymbols.RESTRICTION) {
+ if (typeInfo.fDerivedBy == XSConstants.DERIVATION_RESTRICTION) {
// -----------------------------------------------------------------------
// There may be a simple type definition in the restriction element
@@ -443,7 +445,7 @@
//according to derivation-ok-restriction 5.1.1
if (!XSConstraints.checkSimpleDerivationOk(dv, baseValidator,
- baseValidator.getFinalSet())) {
+ baseValidator.getFinal())) {
throw new ComplexTypeRecoverableError("derivation-ok-restriction.5.1.1",
new Object[]{typeName},
simpleContent);
@@ -588,9 +590,9 @@
// -----------------------------------------------------------------------
String complexContentName = DOMUtil.getLocalName(complexContent);
if (complexContentName.equals(SchemaSymbols.ELT_RESTRICTION))
- typeInfo.fDerivedBy = SchemaSymbols.RESTRICTION;
+ typeInfo.fDerivedBy = XSConstants.DERIVATION_RESTRICTION;
else if (complexContentName.equals(SchemaSymbols.ELT_EXTENSION))
- typeInfo.fDerivedBy = SchemaSymbols.EXTENSION;
+ typeInfo.fDerivedBy = XSConstants.DERIVATION_EXTENSION;
else {
throw new ComplexTypeRecoverableError("src-ct.0.1",
new Object[]{typeName, complexContentName}, complexContent);
@@ -635,7 +637,7 @@
// Check that the base permits the derivation
// -----------------------------------------------------------------------
if ((baseType.fFinal & typeInfo.fDerivedBy)!=0) {
- String errorKey = (typeInfo.fDerivedBy==SchemaSymbols.EXTENSION) ?
+ String errorKey = (typeInfo.fDerivedBy==XSConstants.DERIVATION_EXTENSION) ?
"cos-ct-extends.1.1" : "derivation-ok-restriction.1";
throw new ComplexTypeRecoverableError(errorKey,
new Object[]{typeInfo.fName}, complexContent);
@@ -669,7 +671,7 @@
// Compose the final content and attribute uses
// -----------------------------------------------------------------------
XSParticleDecl baseContent = baseType.fParticle;
- if (typeInfo.fDerivedBy==SchemaSymbols.RESTRICTION) {
+ if (typeInfo.fDerivedBy==XSConstants.DERIVATION_RESTRICTION) {
// This is an RESTRICTION
@@ -724,15 +726,15 @@
else {
// if the content of either type is an "all" model group, error.
if (typeInfo.fParticle.fType == XSParticleDecl.PARTICLE_MODELGROUP &&
- ((XSModelGroup)typeInfo.fParticle.fValue).fCompositor == XSModelGroup.MODELGROUP_ALL ||
+ ((XSModelGroupImpl)typeInfo.fParticle.fValue).fCompositor == XSModelGroupImpl.MODELGROUP_ALL ||
baseType.fParticle.fType == XSParticleDecl.PARTICLE_MODELGROUP &&
- ((XSModelGroup)baseType.fParticle.fValue).fCompositor == XSModelGroup.MODELGROUP_ALL) {
+ ((XSModelGroupImpl)baseType.fParticle.fValue).fCompositor == XSModelGroupImpl.MODELGROUP_ALL) {
throw new ComplexTypeRecoverableError("cos-all-limited.1.2",
null, complexContent);
}
// the "sequence" model group to contain both particles
- XSModelGroup group = new XSModelGroup();
- group.fCompositor = XSModelGroup.MODELGROUP_SEQUENCE;
+ XSModelGroupImpl group = new XSModelGroupImpl();
+ group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
group.fParticleCount = 2;
group.fParticles = new XSParticleDecl[2];
group.fParticles[0] = baseType.fParticle;
@@ -772,18 +774,19 @@
Element elem)
throws ComplexTypeRecoverableError {
- XSAttributeUse[] attrUseS = fromAttrGrp.getAttributeUses();
- XSAttributeUse existingAttrUse, duplicateAttrUse = null;
- int attrCount = (attrUseS!=null)?attrUseS.length:0;
+ XSObjectList attrUseS = fromAttrGrp.getAttributeUses();
+ XSAttributeUseImpl existingAttrUse, duplicateAttrUse = null, oneAttrUse;
+ int attrCount = attrUseS.getListLength();
for (int i=0; i<attrCount; i++) {
- existingAttrUse = toAttrGrp.getAttributeUse(attrUseS[i].fAttrDecl.fTargetNamespace,
- attrUseS[i].fAttrDecl.fName);
+ oneAttrUse = (XSAttributeUseImpl)attrUseS.getItem(i);
+ existingAttrUse = toAttrGrp.getAttributeUse(oneAttrUse.fAttrDecl.fTargetNamespace,
+ oneAttrUse.fAttrDecl.fName);
if (existingAttrUse == null) {
- String idName = toAttrGrp.addAttributeUse(attrUseS[i]);
+ String idName = toAttrGrp.addAttributeUse(oneAttrUse);
if (idName != null) {
throw new ComplexTypeRecoverableError("ct-props-correct.5",
- new Object[]{typeName, idName, attrUseS[i].fAttrDecl.fName},
+ new Object[]{typeName, idName, oneAttrUse.fAttrDecl.fName},
elem);
}
}
@@ -962,14 +965,14 @@
private static synchronized XSParticleDecl getErrorContent() {
if (fErrorContent==null) {
fErrorWildcard = new XSWildcardDecl();
- fErrorWildcard.fProcessContents = XSWildcardDecl.WILDCARD_SKIP;
+ fErrorWildcard.fProcessContents = XSWildcardDecl.PC_SKIP;
XSParticleDecl particle = new XSParticleDecl();
particle.fType = XSParticleDecl.PARTICLE_WILDCARD;
particle.fValue = fErrorWildcard;
particle.fMinOccurs = 0;
particle.fMaxOccurs = SchemaSymbols.OCCURRENCE_UNBOUNDED;
- XSModelGroup group = new XSModelGroup();
- group.fCompositor = XSModelGroup.MODELGROUP_SEQUENCE;
+ XSModelGroupImpl group = new XSModelGroupImpl();
+ group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
group.fParticleCount = 1;
group.fParticles = new XSParticleDecl[1];
group.fParticles[0] = particle;
1.17 +8 -7 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java
Index: XSDElementTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- XSDElementTraverser.java 7 May 2002 15:54:27 -0000 1.16
+++ XSDElementTraverser.java 16 May 2002 18:25:55 -0000 1.17
@@ -70,6 +70,7 @@
import org.apache.xerces.util.DOMUtil;
import org.apache.xerces.impl.xs.util.XInt;
import org.apache.xerces.impl.xs.util.XIntPool;
+import org.apache.xerces.impl.xs.psvi.XSConstants;
import org.apache.xerces.util.SymbolTable;
import org.apache.xerces.xni.QName;
import org.w3c.dom.Element;
@@ -97,7 +98,7 @@
*
* @author Sandy Gao, IBM
*
- * @version $Id: XSDElementTraverser.java,v 1.16 2002/05/07 15:54:27 sandygao Exp $
+ * @version $Id: XSDElementTraverser.java,v 1.17 2002/05/16 18:25:55 sandygao Exp $
*/
class XSDElementTraverser extends XSDAbstractTraverser {
@@ -301,13 +302,13 @@
if (fixedAtt != null) {
element.fDefault = new ValidatedInfo();
element.fDefault.normalizedValue = fixedAtt;
- element.setConstraintType(XSElementDecl.FIXED_VALUE);
+ element.setConstraintType(XSConstants.VC_FIXED);
} else if (defaultAtt != null) {
element.fDefault = new ValidatedInfo();
element.fDefault.normalizedValue = defaultAtt;
- element.setConstraintType(XSElementDecl.DEFAULT_VALUE);
+ element.setConstraintType(XSConstants.VC_DEFAULT);
} else {
- element.setConstraintType(XSElementDecl.NO_CONSTRAINT);
+ element.setConstraintType(XSConstants.VC_NONE);
}
// get 'substitutionGroup affiliation'
@@ -444,7 +445,7 @@
XSConstraints.ElementDefaultValidImmediate(element.fType, element.fDefault.normalizedValue, fValidationState, element.fDefault);
if (element.fDefault.actualValue == null) {
reportSchemaError ("e-props-correct.2", new Object[]{nameAtt, element.fDefault.normalizedValue}, elmDecl);
- element.setConstraintType(XSElementDecl.NO_CONSTRAINT);
+ element.setConstraintType(XSConstants.VC_NONE);
}
}
@@ -457,9 +458,9 @@
// 4 If the {type definition} or {type definition}'s {content type} is or is derived from ID then there must not be a {value constraint}.
if (element.fDefault != null) {
- if ((elementType.getXSType() == XSTypeDecl.SIMPLE_TYPE &&
+ if ((elementType.getTypeCategory() == XSTypeDecl.SIMPLE_TYPE &&
((XSSimpleType)elementType).isIDType()) ||
- (elementType.getXSType() == XSTypeDecl.COMPLEX_TYPE &&
+ (elementType.getTypeCategory() == XSTypeDecl.COMPLEX_TYPE &&
((XSComplexTypeDecl)elementType).containsTypeID())) {
reportSchemaError ("e-props-correct.4", new Object[]{element.fName}, elmDecl);
}
1.13 +3 -3 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDGroupTraverser.java
Index: XSDGroupTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDGroupTraverser.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- XSDGroupTraverser.java 7 May 2002 15:54:27 -0000 1.12
+++ XSDGroupTraverser.java 16 May 2002 18:25:55 -0000 1.13
@@ -59,7 +59,7 @@
import org.apache.xerces.impl.xs.SchemaGrammar;
import org.apache.xerces.impl.xs.SchemaSymbols;
import org.apache.xerces.impl.xs.XSParticleDecl;
-import org.apache.xerces.impl.xs.XSModelGroup;
+import org.apache.xerces.impl.xs.XSModelGroupImpl;
import org.apache.xerces.impl.xs.XSGroupDecl;
import org.apache.xerces.impl.xs.XSMessageFormatter;
import org.apache.xerces.util.DOMUtil;
@@ -78,7 +78,7 @@
* @author Rahul Srivastava, Sun Microsystems Inc.
* @author Elena Litani, IBM
* @author Lisa Martin, IBM
- * @version $Id: XSDGroupTraverser.java,v 1.12 2002/05/07 15:54:27 sandygao Exp $
+ * @version $Id: XSDGroupTraverser.java,v 1.13 2002/05/16 18:25:55 sandygao Exp $
*/
class XSDGroupTraverser extends XSDAbstractParticleTraverser {
@@ -202,7 +202,7 @@
group.fName = strNameAttr;
group.fTargetNamespace = schemaDoc.fTargetNamespace;
if (particle != null)
- group.fModelGroup = (XSModelGroup)particle.fValue;
+ group.fModelGroup = (XSModelGroupImpl)particle.fValue;
grammar.addGlobalGroupDecl(group);
}
}
1.42 +2 -2 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java
Index: XSDHandler.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- XSDHandler.java 7 May 2002 15:54:27 -0000 1.41
+++ XSDHandler.java 16 May 2002 18:25:55 -0000 1.42
@@ -119,7 +119,7 @@
*
* @author Neil Graham, IBM
* @author Pavani Mukthipudi, Sun Microsystems
- * @version $Id: XSDHandler.java,v 1.41 2002/05/07 15:54:27 sandygao Exp $
+ * @version $Id: XSDHandler.java,v 1.42 2002/05/16 18:25:55 sandygao Exp $
*/
public class XSDHandler {
@@ -488,7 +488,7 @@
}
// and return.
- return fGrammarBucket.getGrammar(schemaNamespace);
+ return fGrammarBucket.getGrammar(fRoot.fTargetNamespace);
} // end parseSchema
/**
1.5 +4 -4 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDKeyrefTraverser.java
Index: XSDKeyrefTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDKeyrefTraverser.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XSDKeyrefTraverser.java 15 Feb 2002 22:08:48 -0000 1.4
+++ XSDKeyrefTraverser.java 16 May 2002 18:25:55 -0000 1.5
@@ -70,7 +70,7 @@
* This class contains code that is used to traverse <keyref>s.
*
* @author Neil Graham, IBM
- * @version $Id: XSDKeyrefTraverser.java,v 1.4 2002/02/15 22:08:48 sandygao Exp $
+ * @version $Id: XSDKeyrefTraverser.java,v 1.5 2002/05/16 18:25:55 sandygao Exp $
*/
class XSDKeyrefTraverser extends XSDAbstractIDConstraintTraverser {
@@ -106,8 +106,8 @@
// if ret == null, we've already reported an error in getGlobalDecl
// we report an error only when ret != null, and the return type keyref
if (ret != null) {
- if (ret.getType() == IdentityConstraint.KEY ||
- ret.getType() == IdentityConstraint.UNIQUE) {
+ if (ret.getCategory() == IdentityConstraint.IC_KEY ||
+ ret.getCategory() == IdentityConstraint.IC_UNIQUE) {
key = (UniqueOrKey)ret;
} else {
reportSchemaError("src-resolve", new Object[]{kName.rawname, "identity constraint key/unique"}, krElem);
@@ -119,7 +119,7 @@
return;
}
- KeyRef keyRef = new KeyRef(krName, element.fName, key);
+ KeyRef keyRef = new KeyRef(schemaDoc.fTargetNamespace, krName, element.fName, key);
// add to element decl
traverseIdentityConstraint(keyRef, krElem, schemaDoc, attrValues);
1.17 +30 -28 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java
Index: XSDSimpleTypeTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- XSDSimpleTypeTraverser.java 12 Apr 2002 17:12:28 -0000 1.16
+++ XSDSimpleTypeTraverser.java 16 May 2002 18:25:55 -0000 1.17
@@ -59,12 +59,13 @@
import org.apache.xerces.impl.dv.SchemaDVFactory;
import org.apache.xerces.impl.dv.XSSimpleType;
-import org.apache.xerces.impl.dv.XSUnionSimpleType;
import org.apache.xerces.impl.dv.InvalidDatatypeFacetException;
import org.apache.xerces.impl.dv.XSFacets;
import org.apache.xerces.impl.xs.SchemaGrammar;
import org.apache.xerces.impl.xs.SchemaSymbols;
import org.apache.xerces.impl.xs.XSTypeDecl;
+import org.apache.xerces.impl.xs.psvi.XSConstants;
+import org.apache.xerces.impl.xs.psvi.XSObjectList;
import org.apache.xerces.impl.dv.xs.SchemaDVFactoryImpl;
import org.apache.xerces.util.DOMUtil;
@@ -118,7 +119,7 @@
* @author Neeraj Bajaj, Sun Microsystems, Inc.
* @author Sandy Gao, IBM
*
- * @version $Id: XSDSimpleTypeTraverser.java,v 1.16 2002/04/12 17:12:28 sandygao Exp $
+ * @version $Id: XSDSimpleTypeTraverser.java,v 1.17 2002/05/16 18:25:55 sandygao Exp $
*/
class XSDSimpleTypeTraverser extends XSDAbstractTraverser {
@@ -193,28 +194,28 @@
// (list|restriction|union)
if (child == null) {
reportSchemaError("s4s-elt-must-match", new Object[]{SchemaSymbols.ELT_SIMPLETYPE, "(annotation?, (restriction | list | union))"}, simpleTypeDecl);
- return errorType(name, schemaDoc.fTargetNamespace, SchemaSymbols.RESTRICTION);
+ return errorType(name, schemaDoc.fTargetNamespace, XSConstants.DERIVATION_RESTRICTION);
}
// derivation type: restriction/list/union
String varietyProperty = DOMUtil.getLocalName(child);
- short refType = SchemaSymbols.RESTRICTION;
+ short refType = XSConstants.DERIVATION_RESTRICTION;
boolean restriction = false, list = false, union = false;
if (varietyProperty.equals(SchemaSymbols.ELT_RESTRICTION)) {
- refType = SchemaSymbols.RESTRICTION;
+ refType = XSConstants.DERIVATION_RESTRICTION;
restriction = true;
}
else if (varietyProperty.equals(SchemaSymbols.ELT_LIST)) {
- refType = SchemaSymbols.LIST;
+ refType = XSConstants.DERIVATION_LIST;
list = true;
}
else if (varietyProperty.equals(SchemaSymbols.ELT_UNION)) {
- refType = SchemaSymbols.UNION;
+ refType = XSConstants.DERIVATION_UNION;
union = true;
}
else {
reportSchemaError("s4s-elt-must-match", new Object[]{SchemaSymbols.ELT_SIMPLETYPE, "(annotation?, (restriction | list | union))"}, simpleTypeDecl);
- return errorType(name, schemaDoc.fTargetNamespace, SchemaSymbols.RESTRICTION);
+ return errorType(name, schemaDoc.fTargetNamespace, XSConstants.DERIVATION_RESTRICTION);
}
// nothing should follow this element
@@ -250,7 +251,8 @@
// get types from "memberTypes" attribute
Vector dTValidators = null;
- XSSimpleType dv = null, dvs[];
+ XSSimpleType dv = null;
+ XSObjectList dvs;
if (union && memberTypes != null && memberTypes.size() > 0) {
int size = memberTypes.size();
dTValidators = new Vector(size, 2);
@@ -258,13 +260,13 @@
for (int i = 0; i < size; i++) {
// get the type decl
dv = findDTValidator(child, (QName)memberTypes.elementAt(i),
- SchemaSymbols.UNION, schemaDoc);
+ XSConstants.DERIVATION_UNION, schemaDoc);
if (dv != null) {
// if it's a union, expand it
if (dv.getVariety() == XSSimpleType.VARIETY_UNION) {
- dvs = ((XSUnionSimpleType)dv).getMemberTypes();
- for (int j = 0; j < dvs.length; j++)
- dTValidators.addElement(dvs[j]);
+ dvs = dv.getMemberTypes();
+ for (int j = 0; j < dvs.getListLength(); j++)
+ dTValidators.addElement(dvs.getItem(j));
} else {
dTValidators.addElement(dv);
}
@@ -301,9 +303,9 @@
if (dv != null) {
// if it's a union, expand it
if (dv.getVariety() == XSSimpleType.VARIETY_UNION) {
- dvs = ((XSUnionSimpleType)dv).getMemberTypes();
- for (int j = 0; j < dvs.length; j++)
- dTValidators.addElement(dvs[j]);
+ dvs = dv.getMemberTypes();
+ for (int j = 0; j < dvs.getListLength(); j++)
+ dTValidators.addElement(dvs.getItem(j));
} else {
dTValidators.addElement(dv);
}
@@ -406,20 +408,20 @@
XSTypeDecl baseType = (XSTypeDecl)fSchemaHandler.getGlobalDecl(schemaDoc, fSchemaHandler.TYPEDECL_TYPE, baseTypeStr, elm);
if (baseType != null) {
// if it's a complex type, or if its restriction of anySimpleType
- if (baseType.getXSType() != XSTypeDecl.SIMPLE_TYPE ||
+ if (baseType.getTypeCategory() != XSTypeDecl.SIMPLE_TYPE ||
baseType == SchemaGrammar.fAnySimpleType &&
- baseRefContext == SchemaSymbols.RESTRICTION) {
+ baseRefContext == XSConstants.DERIVATION_RESTRICTION) {
reportSchemaError("st-props-correct.4.1", new Object[]{baseTypeStr.rawname}, elm);
return SchemaGrammar.fAnySimpleType;
}
- if ((baseType.getFinalSet() & baseRefContext) != 0) {
- if (baseRefContext == SchemaSymbols.RESTRICTION) {
+ if ((baseType.getFinal() & baseRefContext) != 0) {
+ if (baseRefContext == XSConstants.DERIVATION_RESTRICTION) {
reportSchemaError("st-props-correct.3", new Object[]{baseTypeStr.rawname}, elm);
}
- else if (baseRefContext == SchemaSymbols.LIST) {
+ else if (baseRefContext == XSConstants.DERIVATION_LIST) {
reportSchemaError("st-props-correct.4.2.1", new Object[]{baseTypeStr.rawname}, elm);
}
- else if (baseRefContext == SchemaSymbols.UNION) {
+ else if (baseRefContext == XSConstants.DERIVATION_UNION) {
reportSchemaError("st-props-correct.4.2.2", new Object[]{baseTypeStr.rawname}, elm);
}
}
@@ -434,9 +436,9 @@
return true;
if (validator.getVariety() == XSSimpleType.VARIETY_UNION) {
- XSSimpleType[] temp = ((XSUnionSimpleType)validator).getMemberTypes();
- for (int i = 0; i < temp.length; i++) {
- if (temp[i].getVariety() == XSSimpleType.VARIETY_LIST) {
+ XSObjectList temp = validator.getMemberTypes();
+ for (int i = 0; i < temp.getListLength(); i++) {
+ if (((XSSimpleType)temp.getItem(i)).getVariety() == XSSimpleType.VARIETY_LIST) {
return true;
}
}
@@ -447,13 +449,13 @@
private XSSimpleType errorType(String name, String namespace, short refType) {
switch (refType) {
- case SchemaSymbols.RESTRICTION:
+ case XSConstants.DERIVATION_RESTRICTION:
return schemaFactory.createTypeRestriction(name, namespace, (short)0,
SchemaGrammar.fAnySimpleType);
- case SchemaSymbols.LIST:
+ case XSConstants.DERIVATION_LIST:
return schemaFactory.createTypeList(name, namespace, (short)0,
SchemaGrammar.fAnySimpleType);
- case SchemaSymbols.UNION:
+ case XSConstants.DERIVATION_UNION:
return schemaFactory.createTypeUnion(name, namespace, (short)0,
new XSSimpleType[]{SchemaGrammar.fAnySimpleType});
}
1.5 +3 -3 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDUniqueOrKeyTraverser.java
Index: XSDUniqueOrKeyTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDUniqueOrKeyTraverser.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XSDUniqueOrKeyTraverser.java 15 Feb 2002 22:08:48 -0000 1.4
+++ XSDUniqueOrKeyTraverser.java 16 May 2002 18:25:55 -0000 1.5
@@ -70,7 +70,7 @@
* <unique>s.
*
* @author Neil Graham, IBM
- * @version $Id: XSDUniqueOrKeyTraverser.java,v 1.4 2002/02/15 22:08:48 sandygao Exp $
+ * @version $Id: XSDUniqueOrKeyTraverser.java,v 1.5 2002/05/16 18:25:55 sandygao Exp $
*/
class XSDUniqueOrKeyTraverser extends XSDAbstractIDConstraintTraverser {
@@ -98,9 +98,9 @@
UniqueOrKey uniqueOrKey = null;
if(DOMUtil.getLocalName(uElem).equals(SchemaSymbols.ELT_UNIQUE)) {
- uniqueOrKey = new UniqueOrKey(uName, element.fName, IdentityConstraint.UNIQUE);
+ uniqueOrKey = new UniqueOrKey(schemaDoc.fTargetNamespace, uName, element.fName, IdentityConstraint.IC_UNIQUE);
} else {
- uniqueOrKey = new UniqueOrKey(uName, element.fName, IdentityConstraint.KEY);
+ uniqueOrKey = new UniqueOrKey(schemaDoc.fTargetNamespace, uName, element.fName, IdentityConstraint.IC_KEY);
}
// it's XSDElementTraverser's job to ensure that there's no
// duplication (or if there is that restriction is involved
1.1 xml-xerces/java/src/org/apache/xerces/impl/xs/util/EnumerationImpl.java
Index: EnumerationImpl.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.xerces.impl.xs.util;
/**
* Contains a list of Objects.
*
* @author Sandy Gao, IBM
*
* @version $Id: EnumerationImpl.java,v 1.1 2002/05/16 18:25:56 sandygao Exp $
*/
public class EnumerationImpl implements java.util.Enumeration {
// The array to hold all data
private Object[] fArray = null;
// Number of elements in this enumeration
private int fLength = 0;
// The current position
private int fCurPos = 0;
/**
* Construct an enumeration implementation
*
* @param array the data array
* @param length the number of elements
*/
public EnumerationImpl(Object[] array, int length) {
fArray = array;
fLength = length;
}
/**
* Tests if this enumeration contains more elements.
*
* @return <code>true</code> if and only if this enumeration object
* contains at least one more element to provide;
* <code>false</code> otherwise.
*/
public boolean hasMoreElements() {
return fCurPos < fLength;
}
/**
* Returns the next element of this enumeration if this enumeration
* object has at least one more element to provide.
*
* @return the next element of this enumeration.
* @exception NoSuchElementException if no more elements exist.
*/
public Object nextElement() {
if (hasMoreElements()) {
return fArray[fCurPos++];
}
throw new java.util.NoSuchElementException();
}
} // class XSParticle
1.1 xml-xerces/java/src/org/apache/xerces/impl/xs/util/XSNamedMap4Types.java
Index: XSNamedMap4Types.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.xerces.impl.xs.util;
import org.apache.xerces.util.SymbolHash;
import org.apache.xerces.xni.QName;
import org.apache.xerces.impl.xs.psvi.*;
/**
* Containts the map between qnames and XSObject's.
*
* @author Sandy Gao, IBM
*
* @version $Id: XSNamedMap4Types.java,v 1.1 2002/05/16 18:25:56 sandygao Exp $
*/
public class XSNamedMap4Types extends XSNamedMapImpl {
// the type of component stored here: complex or simple type
short fType;
/**
* Construct an XSNamedMap implmentation for one namespace
*
* @param namespace the namespace to which the components belong
* @param map the map from local names to components
* @param type the type of components
*/
public XSNamedMap4Types(String namespace, SymbolHash map, short type) {
super(namespace, map);
fType = type;
}
/**
* Construct an XSNamedMap implmentation for a list of namespaces
*
* @param namespaces the namespaces to which the components belong
* @param maps the maps from local names to components
* @param num the number of namespaces
* @param type the type of components
*/
public XSNamedMap4Types(String[] namespaces, SymbolHash[] maps, int num, short type) {
super(namespaces, maps, num);
fType = type;
}
/**
* The number of <code>XSObjects</code> in the <code>XSObjectList</code>. The
* range of valid child node indices is 0 to <code>length-1</code>
* inclusive.
*/
public synchronized int getMapLength() {
if (fLength == -1) {
// first get the number of components for all types
int length = 0;
for (int i = 0; i < fNSNum; i++)
length += fMaps[i].getLength();
// then copy all types to an temporary array
int pos = 0;
XSObject[] array = new XSObject[length];
for (int i = 0; i < fNSNum; i++) {
pos += fMaps[i].getValues(array, pos);
}
// then copy either simple or complex types to fArray,
// depending on which kind is required
fLength = 0;
fArray = new XSObject[length];
XSTypeDefinition type;
for (int i = 0; i < length; i++) {
type = (XSTypeDefinition)array[i];
if (type.getTypeCategory() == fType) {
fArray[fLength++] = type;
}
}
}
return fLength;
}
/**
* Retrieves an <code>XSObject</code> specified by local name and namespace
* URI.
* @param namespace The namespace URI of the <code>XSObject</code> to
* retrieve.
* @param localName The local name of the <code>XSObject</code> to retrieve.
* @return A <code>XSObject</code> (of any type) with the specified local
* name and namespace URI, or <code>null</code> if they do not
* identify any <code>XSObject</code> in this map.
*/
public XSObject getNSItem(String namespace, String localName) {
namespace = namespace.intern();
for (int i = 0; i < fNSNum; i++) {
if (namespace == fNamespaces[i]) {
XSTypeDefinition type = (XSTypeDefinition)fMaps[i].get(localName);
// only return it if it mataches the required type
if (type.getTypeCategory() == fType)
return type;
return null;
}
}
return null;
}
/**
* Returns the <code>index</code>th item in the map. The index starts at
* 0. If <code>index</code> is greater than or equal to the number of
* nodes in the list, this returns <code>null</code>.
* @param index The position in the map from which the item is to be
* retrieved.
* @return The <code>XSObject</code> at the <code>index</code>th position
* in the <code>XSNamedMap</code>, or <code>null</code> if that is
* not a valid index.
*/
public synchronized XSObject getItem(int index) {
if (fArray == null) {
getMapLength();
}
if (index < 0 || index >= fLength)
return null;
return fArray[index];
}
} // class XSNamedMapImpl
1.1 xml-xerces/java/src/org/apache/xerces/impl/xs/util/XSNamedMapImpl.java
Index: XSNamedMapImpl.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.xerces.impl.xs.util;
import org.apache.xerces.util.SymbolHash;
import org.apache.xerces.xni.QName;
import org.apache.xerces.impl.xs.psvi.*;
/**
* Containts the map between qnames and XSObject's.
*
* @author Sandy Gao, IBM
*
* @version $Id: XSNamedMapImpl.java,v 1.1 2002/05/16 18:25:56 sandygao Exp $
*/
public class XSNamedMapImpl implements XSNamedMap {
// components of these namespaces are stored in this map
String[] fNamespaces;
// number of namespaces
int fNSNum;
// each entry contains components in one namespace
SymbolHash[] fMaps;
// store all components from all namespace.
// used when this map is accessed as a list.
XSObject[] fArray = null;
// store the number of componetns.
// used when this map is accessed as a list.
int fLength = -1;
// temprory QName object
QName fName = new QName();
/**
* Construct an XSNamedMap implmentation for one namespace
*
* @param namespace the namespace to which the components belong
* @param map the map from local names to components
*/
public XSNamedMapImpl(String namespace, SymbolHash map) {
fNamespaces = new String[] {namespace};
fMaps = new SymbolHash[] {map};
fNSNum = 1;
}
/**
* Construct an XSNamedMap implmentation for a list of namespaces
*
* @param namespaces the namespaces to which the components belong
* @param maps the maps from local names to components
* @param num the number of namespaces
*/
public XSNamedMapImpl(String[] namespaces, SymbolHash[] maps, int num) {
fNamespaces = namespaces;
fMaps = maps;
fNSNum = num;
}
/**
* Construct an XSNamedMap implmentation one namespace from an array
*
* @param array containing all components
* @param length number of components
*/
public XSNamedMapImpl(XSObject[] array, int length) {
if (length == 0) {
fNSNum = 0;
fLength = 0;
return;
}
// because all components are from the same target namesapce,
// get the namespace from the first one.
fNamespaces = new String[]{array[0].getNamespace()};
fMaps = null;
fNSNum = 1;
// copy elements to the Vector
fArray = array;
fLength = length;
}
/**
* The number of <code>XSObjects</code> in the <code>XSObjectList</code>. The
* range of valid child node indices is 0 to <code>length-1</code>
* inclusive.
*/
public synchronized int getMapLength() {
if (fLength == -1) {
fLength = 0;
for (int i = 0; i < fNSNum; i++)
fLength += fMaps[i].getLength();
}
return fLength;
}
/**
* Retrieves an <code>XSObject</code> specified by local name and namespace
* URI.
* @param namespace The namespace URI of the <code>XSObject</code> to
* retrieve.
* @param localName The local name of the <code>XSObject</code> to retrieve.
* @return A <code>XSObject</code> (of any type) with the specified local
* name and namespace URI, or <code>null</code> if they do not
* identify any <code>XSObject</code> in this map.
*/
public XSObject getNSItem(String namespace, String localName) {
namespace = namespace.intern();
for (int i = 0; i < fNSNum; i++) {
if (namespace == fNamespaces[i]) {
// when this map is created from SymbolHash's
// get the component from SymbolHash
if (fMaps != null)
return (XSObject)fMaps[i].get(localName);
// Otherwise (it's created from an array)
// go through the array to find a matcing name
XSObject ret;
for (int j = 0; j < fLength; j++) {
ret = fArray[j];
if (ret.getName().equals(localName))
return ret;
}
return null;
}
}
return null;
}
/**
* Returns the <code>index</code>th item in the map. The index starts at
* 0. If <code>index</code> is greater than or equal to the number of
* nodes in the list, this returns <code>null</code>.
* @param index The position in the map from which the item is to be
* retrieved.
* @return The <code>XSObject</code> at the <code>index</code>th position
* in the <code>XSNamedMap</code>, or <code>null</code> if that is
* not a valid index.
*/
public synchronized XSObject getItem(int index) {
if (fArray == null) {
// calculate the total number of elements
getMapLength();
fArray = new XSObject[fLength];
int pos = 0;
// get components from all SymbolHash's
for (int i = 0; i < fNSNum; i++) {
pos += fMaps[i].getValues(fArray, pos);
}
}
if (index < 0 || index >= fLength)
return null;
return fArray[index];
}
} // class XSNamedMapImpl
1.1 xml-xerces/java/src/org/apache/xerces/impl/xs/util/XSObjectListImpl.java
Index: XSObjectListImpl.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.xerces.impl.xs.util;
import org.apache.xerces.impl.xs.psvi.XSObject;
import org.apache.xerces.impl.xs.psvi.XSObjectList;
/**
* Containts a list of XSObject's.
*
* @author Sandy Gao, IBM
*
* @version $Id: XSObjectListImpl.java,v 1.1 2002/05/16 18:25:56 sandygao Exp $
*/
public class XSObjectListImpl implements XSObjectList {
// The array to hold all data
private XSObject[] fArray = null;
// Number of elements in this list
private int fLength = 0;
/**
* Construct an XSObjectList implementation
*
* @param array the data array
* @param length the number of elements
*/
public XSObjectListImpl(XSObject[] array, int length) {
fArray = array;
fLength = length;
}
/**
* The number of <code>XSObjects</code> in the list. The range of valid
* child node indices is 0 to <code>length-1</code> inclusive.
*/
public int getListLength() {
return fLength;
}
/**
* Returns the <code>index</code>th item in the collection. The index
* starts at 0. If <code>index</code> is greater than or equal to the
* number of nodes in the list, this returns <code>null</code>.
* @param index index into the collection.
* @return The XSObject at the <code>index</code>th position in the
* <code>XSObjectList</code>, or <code>null</code> if that is not a
* valid index.
*/
public XSObject getItem(int index) {
if (index < 0 || index >= fLength)
return null;
return fArray[index];
}
} // class XSParticle
1.5 +102 -118 xml-xerces/java/src/org/apache/xerces/util/SymbolHash.java
Index: SymbolHash.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/util/SymbolHash.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SymbolHash.java 29 Jan 2002 01:15:18 -0000 1.4
+++ SymbolHash.java 16 May 2002 18:25:56 -0000 1.5
@@ -58,6 +58,7 @@
package org.apache.xerces.util;
import org.apache.xerces.xni.QName;
+import java.util.Vector;
/**
* This class is an unsynchronized hash table primary used for String
@@ -66,7 +67,7 @@
* The hash code uses the same algorithm as SymbolTable class.
*
* @author Elena Litani
- * @version $Id: SymbolHash.java,v 1.4 2002/01/29 01:15:18 lehors Exp $
+ * @version $Id: SymbolHash.java,v 1.5 2002/05/16 18:25:56 sandygao Exp $
*/
public class SymbolHash {
@@ -84,17 +85,23 @@
/** Buckets. */
protected Entry[] fBuckets;
+ /** Number of elements. */
+ protected int fNum = 0;
//
// Constructors
//
- /** Constructs a key table. */
+ /** Constructs a key table with the default size. */
public SymbolHash() {
fBuckets = new Entry[fTableSize];
}
-
+ /**
+ * Constructs a key table with a given size.
+ *
+ * @param size the size of the key table.
+ */
public SymbolHash(int size) {
fTableSize = size;
fBuckets = new Entry[fTableSize];
@@ -105,122 +112,103 @@
//
/**
- * Adds the specified key to the key table and returns a
- * reference to the unique key. If the key already exists,
- * the previous key reference is returned instead, in order
- * guarantee that key references remain unique.
+ * Adds the key/value mapping to the key table. If the key already exists,
+ * the previous value associated with this key is overwritten by the new
+ * value.
*
- * @param key The new key.
+ * @param key
+ * @param value
*/
- public String put (String key, Object value ) {
-
- int bucket = hash(key) % fTableSize;
- Entry entry = search (key, bucket);
-
- if (entry !=null) {
- return entry.key;
+ public void put(Object key, Object value) {
+ int bucket = (key.hashCode() & 0x7FFFFFFF) % fTableSize;
+ Entry entry = search(key, bucket);
+
+ // replace old value
+ if (entry != null) {
+ entry.value = value;
}
// create new entry
- entry = new Entry(key, value, fBuckets[bucket]);
- fBuckets[bucket] = entry;
- return key;
-
- }
+ else {
+ entry = new Entry(key, value, fBuckets[bucket]);
+ fBuckets[bucket] = entry;
+ fNum++;
+ }
+ }
/**
- * Adds the specified key to the key table and returns a
- * reference to the unique key. If the key already exists,
- * the previous key reference is returned instead, in order
- * guarantee that key references remain unique.
+ * Get the value associated with the given key.
*
- * @param qName The QName which is the key
- * @param value
+ * @param key
+ * @return
*/
- public String put(QName qName, Object value) {
-
- String key = (qName.uri == null)?qName.localpart:qName.uri.concat(qName.localpart);
-
- // search for identical key
- int bucket = hash(key) % fTableSize;
- Entry entry = search (key, bucket);
-
- if (entry !=null) {
- return entry.key;
- }
- // add new entry
- entry = new Entry(key, value,fBuckets[bucket]);
- fBuckets[bucket] = entry;
- return entry.key;
-
- }
-
- public Object get (String key){
-
- int bucket = hash(key) % fTableSize;
- Entry entry = search (key, bucket);
- if (entry !=null) {
+ public Object get(Object key) {
+ int bucket = (key.hashCode() & 0x7FFFFFFF) % fTableSize;
+ Entry entry = search(key, bucket);
+ if (entry != null) {
return entry.value;
}
return null;
}
- // this tries to save a bit of GC'ing by at least keeping the fBuckets array around.
+ /**
+ * Get the number of key/value pairs stored in this table.
+ *
+ * @return
+ */
+ public int getLength() {
+ return fNum;
+ }
+
+ /**
+ * Add all values to the given array. The array must have enough entry.
+ *
+ * @param elements the array to store the elements
+ * @param from where to start store element in the array
+ * @return number of elements copied to the array
+ */
+ public int getValues(Object[] elements, int from) {
+ for (int i=0, j=0; i<fTableSize && j<fNum; i++) {
+ for (Entry entry = fBuckets[i]; entry != null; entry = entry.next) {
+ elements[from+j] = entry.value;
+ j++;
+ }
+ }
+ return fNum;
+ }
+
+ /**
+ * Make a clone of this object.
+ */
+ public SymbolHash makeClone() {
+ SymbolHash newTable = new SymbolHash(fTableSize);
+ newTable.fNum = fNum;
+ for (int i = 0; i < fTableSize; i++) {
+ if (fBuckets[i] != null)
+ newTable.fBuckets[i] = fBuckets[i].makeClone();
+ }
+ return newTable;
+ }
+
+ /**
+ * Remove all key/value assocaition. This tries to save a bit of GC'ing
+ * by at least keeping the fBuckets array around.
+ */
public void clear() {
for (int i=0; i<fTableSize; i++) {
- fBuckets[i] = new Entry();
+ fBuckets[i] = null;
}
+ fNum = 0;
} // clear(): void
- public Object get (QName qName){
-
- String key = qName.uri.concat(qName.localpart);
-
- int bucket = hash(key) % fTableSize;
- Entry entry = search (key, bucket);
-
- if (entry !=null) {
- return entry.value;
- }
- return null;
- }
-
- protected Entry search (String key, int bucket){
+ protected Entry search(Object key, int bucket) {
// search for identical key
- int length = key.length();
- OUTER: for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
- if (entry.characters != null && length == entry.characters.length) {
- for (int i = 0; i < length; i++) {
- if (key.charAt(i) != entry.characters[i]) {
- continue OUTER;
- }
- }
+ for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
+ if (key.equals(entry.key))
return entry;
- }
}
return null;
}
- /**
- * Returns a hashcode value for the specified key. The value
- * returned by this method must be identical to the value returned
- * by the <code>hash(char[],int,int)</code> method when called
- * with the character array that comprises the key string.
- *
- * @param key The key to hash.
- */
- public int hash(String key) {
-
- int code = 0;
- int length = key.length();
- for (int i = 0; i < length; i++) {
- code = code * 37 + key.charAt(i);
- }
- return code & 0x7FFFFFF;
-
- } // hash(String):int
-
-
-
-
+
//
// Classes
//
@@ -230,36 +218,32 @@
* in a linked list.
*/
protected static final class Entry {
- /**
- * key is a name or QName
- */
- public String key;
-
- public Object value;
-
- /**
- * key characters. This information is duplicated here for
- * comparison performance.
- */
- public char[] characters;
-
+ // key/value
+ public Object key;
+ public Object value;
/** The next entry. */
public Entry next;
-
public Entry() {
key = null;
value = null;
- characters = null;
next = null;
}
- public Entry(String key, Object value, Entry next) {
- this.key = key;
- this.value = value;
- this.next = next;
- characters = new char[key.length()];
- key.getChars(0, characters.length, characters, 0);
- }
+
+ public Entry(Object key, Object value, Entry next) {
+ this.key = key;
+ this.value = value;
+ this.next = next;
+ }
+
+ public Entry makeClone() {
+ Entry entry = new Entry();
+ entry.key = key;
+ entry.value = value;
+ if (next != null)
+ entry.next = next.makeClone();
+ return entry;
+ }
} // entry
} // class SymbolHash
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org