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 2001/10/17 23:46:10 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes AnySimpleType.java
sandygao 01/10/17 14:46:10
Modified: java/src/org/apache/xerces/impl/msg
XMLSchemaMessages.properties
java/src/org/apache/xerces/impl/v2 SchemaGrammar.java
SchemaValidator.java SubstitutionGroupHandler.java
XSAllCM.java XSConstraints.java
XSDAbstractParticleTraverser.java
XSDAbstractTraverser.java
XSDAttributeTraverser.java
XSDComplexTypeTraverser.java
XSDElementTraverser.java XSDFACM.java
XSDHandler.java XSDSimpleTypeTraverser.java
XSElementDecl.java XSParticleDecl.java
XSSimpleCM.java XSTypeDecl.java XSWildcardDecl.java
java/src/org/apache/xerces/impl/v2/datatypes
AnySimpleType.java
Log:
1. fixed various bugs;
2. provided a solid substitution support for validation;
3. made anyType and anySimpleType static;
4. make XSParticleDecl.toString() return a shorter message;
Revision Changes Path
1.15 +15 -19 xml-xerces/java/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
Index: XMLSchemaMessages.properties
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- XMLSchemaMessages.properties 2001/10/16 15:11:37 1.14
+++ XMLSchemaMessages.properties 2001/10/17 21:46:09 1.15
@@ -75,8 +75,6 @@
General = schema error: {0}.
-
-
#validation (3.X.4)
cvc-assess-attr = cvc-assess-attr: error.
@@ -84,7 +82,7 @@
cvc-attribute.1 = cvc-attribute.1: error.
cvc-attribute.2 = cvc-attribute.2: error.
cvc-attribute.3 = cvc-attribute.3: The value ''{2}'' of attribute ''{1}'' on element ''{0}'' is not valid with repect to its type.
- cvc-attribute.4 = cvc-attribute.4: The value ''{2}'' of attribute ''{1}'' on element ''{0}'' is not valid with repect to its fixed {value constraint}.
+ cvc-attribute.4 = cvc-attribute.4: The value ''{2}'' of attribute ''{1}'' on element ''{0}'' is not valid with repect to its fixed '{'value constraint'}'.
cvc-au = cvc-au: error.
cvc-complex-type.1 = cvc-complex-type.1: error.
cvc-complex-type.2.1 = cvc-complex-type.2.1: Element ''{0}'' must have no character or element information item [children], becaues the type's content type is empty.
@@ -105,14 +103,14 @@
cvc-datatype-valid.1.2.3 = cvc-datatype-valid.1.2.3: error.
cvc-datatype-valid.2 = cvc-datatype-valid.2: error.
cvc-elt.1 = cvc-elt.1: Cannot find the declaration of element ''{0}''.
- cvc-elt.2 = cvc-elt.2: {abstract} of the element declaration of ''{0}'' must be false.
- cvc-elt.3.1 = cvc-elt.3.1: Attribute ''{1}'' must not apprear on element ''{0}'', because {nillable} is false.
+ cvc-elt.2 = cvc-elt.2: '{'abstract'}' of the element declaration of ''{0}'' must be false.
+ cvc-elt.3.1 = cvc-elt.3.1: Attribute ''{1}'' must not apprear on element ''{0}'', because '{'nillable'}' is false.
cvc-elt.3.2.1 = cvc-elt.3.2.1: Element ''{0}'' must have no character or element information [children], because ''{1}'' is specified.
- cvc-elt.3.2.2 = cvc-elt.3.2.2: There must be no fixed {value constraint} for element ''{0}'', because ''{1}'' is specified.
+ cvc-elt.3.2.2 = cvc-elt.3.2.2: There must be no fixed '{'value constraint'}' for element ''{0}'', because ''{1}'' is specified.
cvc-elt.4.1 = cvc-elt.4.1: The value ''{2}'' of attribute ''{1}'' is not a valid QName on element ''{0}''.
cvc-elt.4.2 = cvc-elt.4.2: Cannot resolve ''{1}'' to a type definition for element ''{0}''.
cvc-elt.4.3 = cvc-elt.4.3: Type ''{1}'' is not validly derived from the type definition of element ''{0}''.
- cvc-elt.5.1.1 = cvc-elt.5.1.1: {value constraint} ''{2}'' of element ''{0}'' is not a valid default for type ''{1}''.
+ cvc-elt.5.1.1 = cvc-elt.5.1.1: '{'value constraint'}' ''{2}'' of element ''{0}'' is not a valid default for type ''{1}''.
cvc-elt.5.1.2 = cvc-elt.5.1.2: error.
cvc-elt.5.2.2.1 = cvc-elt.5.2.2.1: Element ''{0}'' must have no element information item [children].
cvc-elt.5.2.2.2.1 = cvc-elt.5.2.2.2.1: The value ''{1}'' of element ''{0}'' does not match the fixed value constrinat value ''{2}''.
@@ -155,7 +153,6 @@
s4s-elt-schema-ns = s4s-elt-schema-ns: The namespace of element ''{0}'' must be from the schema namespace.
s4s-elt-invalid = s4s-elt-invalid: Element ''{0}'' is not a valid element in schema document.
s4s-elt-must-match = s4s-elt-must-match: The content of ''{0}'' must match {1}.
-
#schema valid (3.X.3)
@@ -169,7 +166,7 @@
src-attribute.4 = src-attribute.4: Attribute ''{0}'' have both a type attribute and a annoymous simpleType child..
src-attribute.5 = src-attribute.5: error.
src-attribute_group = src-attribute_group: error.
- src-ct = src-ct: Complex Type Definition Representation Error for type ''{0}''.
+ src-ct = src-ct: Complex Type Definition Representation Error for type ''{0}''.
src-element.1 = src-element.1: ''default'' and ''fixed'' must not both be present in element declaration ''{0}''.
src-element.2.1 = src-element.2.1: : One of ''ref'' or ''name'' must be present in a local element declaration.
src-element.2.2 = src-element.2.2: The content must match (annotation?) for the element reference ''{0}''.
@@ -190,7 +187,6 @@
src-redefine.5 = src-redefine.5: <simpleType> or <complexType> children of <redefine> elements must have <extension> or <restriction> descendants referring to themselves.
src-redefine = src-redefine: A <redefine> element cannot contain a child of type ''{0}''.
src-redefine.6.1.1 = src-redefine.6.1.1: if a group child of a <redefine> element contains an group ref'ing itself, it must have exactly 1; this one has ''{0}''.
-
src-redefine.6.1.2 = src-redefine.6.1.2: the group ''{0}'' which contains a reference to a group being redefined must have minOccurs = maxOccurs = 1.
src-redefine.7.1 = src-redefine.7.1: if an attributeGroup child of a <redefine> element contains an attributeGroup ref'ing itself, it must have exactly 1; this one has ''{0}''.
src-resolve = src-resolve: error.
@@ -207,7 +203,7 @@
an-props-correct = an-props-correct: error.
a-props-correct.1 = a-props-correct.1: error.
a-props-correct.2 = a-props-correct.2: Invalid value constraint value ''{1}'' in attribute ''{0}''..
- a-props-correct.3 = a-props-correct.3: There must not be a {value constraint} on attribute ''{0}'', because its {type definition} is or is derived from ID.
+ a-props-correct.3 = a-props-correct.3: There must not be a '{'value constraint'}' on attribute ''{0}'', because its '{'type definition'}' is or is derived from ID.
au-props-correct = au-props-correct: error.
c-fields-xpaths = c-fields-xpaths: error.
cos-all-limited = cos-all-limited: error.
@@ -233,7 +229,7 @@
cos-valid-default.1 = cos-valid-default.1: error.
cos-valid-default.2.1 = cos-valid-default.2.1: Element ''{0}'' has a value constraint and must have a mixed or simple content model.
cos-valid-default.2.2.1 = cos-valid-default.2.2.1: error.
- cos-valid-default.2.2.2 = cos-valid-default.2.2.2: For element ''{0}'', the {content type} is mixed, then the {content type}''s particle must be emptiable.
+ cos-valid-default.2.2.2 = cos-valid-default.2.2.2: For element ''{0}'', the '{'content type'}' is mixed, then the '{'content type'}'''s particle must be emptiable.
c-props-correct = c-props-correct: error.
c-selector-xpath = c-selector-xpath: error.
ct-props-correct = ct-props-correct: error.
@@ -242,8 +238,8 @@
enumeration-valid-restriction = enumeration-valid-restriction: error.
e-props-correct.1 = e-props-correct.1: error.
e-props-correct.2 = e-props-correct.2: Invalid value constraint value ''{1}'' in element ''{0}''.
- e-props-correct.3 = e-props-correct.3: The {type definition} of element ''{0}'' must be validly derived from the {type definition} of the substitutionHead ''{1}''.
- e-props-correct.4 = e-props-correct.4: There must not be a {value constraint} on element ''{0}'', because its {type definition} or {type definition}''s {content type} is or is derived from ID.
+ e-props-correct.3 = e-props-correct.3: The '{'type definition'}' of element ''{0}'' must be validly derived from the '{'type definition'}' of the substitutionHead ''{1}''.
+ e-props-correct.4 = e-props-correct.4: There must not be a '{'value constraint'}' on element ''{0}'', because its '{'type definition'}' or '{'type definition'}'''s '{'content type'}' is or is derived from ID.
fractionDigits-totalDigits = fractionDigits-totalDigits: error.
length-minLength-maxLength = length-minLength-maxLength: error.
length-valid-restriction = length-valid-restriction: error.
@@ -262,9 +258,9 @@
minInclusive-valid-restriction = minInclusive-valid-restriction: error.
minLength-less-than-equal-to-maxLength = minLength-less-than-equal-to-maxLength: error.
minLength-valid-restriction = minLength-valid-restriction: error.
- no-xmlns = no-xmlns: : The {name} of an attribute declaration must not match ''xmlns''.
- no-xsi = no-xsi: : The {target namespace} of an attribute declaration must not match ''{0}''.
- n-props-correct.2.1 = n-props-correct.2.1: {min occurs} = ''{1}'' must not be greater than {max occurs} = ''{2}'' for ''{0}''.
+ no-xmlns = no-xmlns: : The '{'name'}' of an attribute declaration must not match ''xmlns''.
+ no-xsi = no-xsi: : The '{'target namespace'}' of an attribute declaration must not match ''{0}''.
+ n-props-correct.2.1 = n-props-correct.2.1: '{'min occurs'}' = ''{1}'' must not be greater than '{'max occurs'}' = ''{2}'' for ''{0}''.
p-props-correct = p-props-correct: error.
range-ok = range-ok: error.
rcase-MapAndSum = rcase-MapAndSum: error.
@@ -286,11 +282,11 @@
# SimpleTypes
ListUnionRestrictionError = List | Union | Restriction content is invalid for type ''{0}''
InvalidSTContent = Invalid content for the simpleType ''{0}''
-
+
UnknownBaseDatatype = Unknown base type ''{0}'' for type ''{1}''
RestrictionBaseFinal = the base type ''{0}'' does not allow itself to be used as the base for a restriction and/or as a type in a list and/or union
-
+
# Datatypes
DatatypeFacetError = Invalid facet: ''{0}''
WhitespaceFacetError = whiteSpace value ''{0}'' for this type must be collapse.
1.27 +57 -38 xml-xerces/java/src/org/apache/xerces/impl/v2/SchemaGrammar.java
Index: SchemaGrammar.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/SchemaGrammar.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- SchemaGrammar.java 2001/10/16 15:11:37 1.26
+++ SchemaGrammar.java 2001/10/17 21:46:09 1.27
@@ -71,7 +71,7 @@
* @author Sandy Gao, IBM
* @author Elena Litani, IBM
*
- * @version $Id: SchemaGrammar.java,v 1.26 2001/10/16 15:11:37 elena Exp $
+ * @version $Id: SchemaGrammar.java,v 1.27 2001/10/17 21:46:09 sandygao Exp $
*/
public class SchemaGrammar {
@@ -144,33 +144,37 @@
// In case we ever see an error, Runtime exception will be thrown
// since this is an implementation failure.
+ fGlobalAttrDecls = new SymbolHash(0);
+ fGlobalAttrGrpDecls = new SymbolHash(0);
+ fGlobalElemDecls = new SymbolHash(0);
+ fGlobalGroupDecls = new SymbolHash(0);
+ fGlobalNotationDecls = new SymbolHash(0);
+ fGlobalIDConstraintDecls = new SymbolHash(0);
+
// set the size of type SymbolHash to double the number of types need
// to be created. which should be the most effecient number.
fGlobalTypeDecls = new SymbolHash((fullSet?FULLSET_COUNT:BASICSET_COUNT)*2);
+
+ // REVISIT: use the newly designed interfaces
- // REVISIT: use XSSimpleTypeDecl instead
- XSComplexTypeDecl anyType = new XSComplexTypeDecl();
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYTYPE, anyType);
- //REVISIT: make anyType the base of anySimpleType
- //DatatypeValidator anySimpleType = new AnySimpleType(anyType, null, false);
- DatatypeValidator anySimpleType = new AnySimpleType(null, null, false, null);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYSIMPLETYPE, anySimpleType);
- DatatypeValidator stringDV = new StringDatatypeValidator(anySimpleType, null, false, null);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYTYPE, fAnyType);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYSIMPLETYPE, fAnySimpleType);
+ DatatypeValidator stringDV = new StringDatatypeValidator(fAnySimpleType, null, false, null);
addGlobalTypeDecl(SchemaSymbols.ATTVAL_STRING, stringDV);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_BOOLEAN, new BooleanDatatypeValidator(anySimpleType, null, false, null));
- DatatypeValidator decimalDV = new DecimalDatatypeValidator(anySimpleType, null, false, null);
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_BOOLEAN, new BooleanDatatypeValidator(fAnySimpleType, null, false, null));
+ DatatypeValidator decimalDV = new DecimalDatatypeValidator(fAnySimpleType, null, false, null);
addGlobalTypeDecl(SchemaSymbols.ATTVAL_DECIMAL, decimalDV);
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYURI, new AnyURIDatatypeValidator(anySimpleType, null, false, null));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_BASE64BINARY, new Base64BinaryDatatypeValidator(anySimpleType, null, false, null));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_DURATION, new DurationDatatypeValidator(anySimpleType, null, false, null));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_DATETIME, new DateTimeDatatypeValidator(anySimpleType, null, false, null));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_TIME, new TimeDatatypeValidator(anySimpleType, null, false, null));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_DATE, new DateDatatypeValidator(anySimpleType, null, false, null));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_YEARMONTH, new YearMonthDatatypeValidator(anySimpleType, null, false, null));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_YEAR, new YearDatatypeValidator(anySimpleType, null, false, null));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_MONTHDAY, new MonthDayDatatypeValidator(anySimpleType, null, false, null));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_DAY, new DayDatatypeValidator(anySimpleType, null, false, null));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_MONTH, new MonthDatatypeValidator(anySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYURI, new AnyURIDatatypeValidator(fAnySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_BASE64BINARY, new Base64BinaryDatatypeValidator(fAnySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_DURATION, new DurationDatatypeValidator(fAnySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_DATETIME, new DateTimeDatatypeValidator(fAnySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_TIME, new TimeDatatypeValidator(fAnySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_DATE, new DateDatatypeValidator(fAnySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_YEARMONTH, new YearMonthDatatypeValidator(fAnySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_YEAR, new YearDatatypeValidator(fAnySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_MONTHDAY, new MonthDayDatatypeValidator(fAnySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_DAY, new DayDatatypeValidator(fAnySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_MONTH, new MonthDatatypeValidator(fAnySimpleType, null, false, null));
Hashtable facets = new Hashtable(2);
facets.put(SchemaSymbols.ELT_FRACTIONDIGITS, "0");
@@ -228,10 +232,10 @@
if (!fullSet)
return;
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_FLOAT, new FloatDatatypeValidator(anySimpleType, null, false, null));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_DOUBLE, new DoubleDatatypeValidator(anySimpleType, null, false, null));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_HEXBINARY, new HexBinaryDatatypeValidator(anySimpleType, null, false, null));
- addGlobalTypeDecl(SchemaSymbols.ATTVAL_NOTATION, new NOTATIONDatatypeValidator(anySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_FLOAT, new FloatDatatypeValidator(fAnySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_DOUBLE, new DoubleDatatypeValidator(fAnySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_HEXBINARY, new HexBinaryDatatypeValidator(fAnySimpleType, null, false, null));
+ addGlobalTypeDecl(SchemaSymbols.ATTVAL_NOTATION, new NOTATIONDatatypeValidator(fAnySimpleType, null, false, null));
facets.clear();
facets.put(SchemaSymbols.ELT_WHITESPACE, SchemaSymbols.ATTVAL_REPLACE);
@@ -256,7 +260,7 @@
facets.put(AbstractStringValidator.FACET_SPECIAL_TOKEN, AbstractStringValidator.SPECIAL_TOKEN_NCNAME);
DatatypeValidator ncnameDV = new StringDatatypeValidator(nameDV, facets, false, null);
addGlobalTypeDecl(SchemaSymbols.ATTVAL_NCNAME, ncnameDV);
- DatatypeValidator qnameDV = new QNameDatatypeValidator(anySimpleType, null, false, null);
+ DatatypeValidator qnameDV = new QNameDatatypeValidator(fAnySimpleType, null, false, null);
((QNameDatatypeValidator)qnameDV).setNCNameValidator(ncnameDV);
addGlobalTypeDecl(SchemaSymbols.ATTVAL_QNAME, qnameDV);
addGlobalTypeDecl(SchemaSymbols.ATTVAL_ID, new IDDatatypeValidator(ncnameDV, null, false, null));
@@ -266,7 +270,7 @@
DatatypeValidator entityDV = new EntityDatatypeValidator(ncnameDV, null, false, null);
addGlobalTypeDecl(SchemaSymbols.ATTVAL_ENTITY, entityDV);
addGlobalTypeDecl(SchemaSymbols.ATTVAL_ENTITIES, new ListDatatypeValidator(entityDV, null, true, null));
-
+
facets.clear();
facets.put(SchemaSymbols.ELT_WHITESPACE, SchemaSymbols.ATTVAL_COLLAPSE);
facets.put(AbstractStringValidator.FACET_SPECIAL_TOKEN, AbstractStringValidator.SPECIAL_TOKEN_NMTOKEN);
@@ -322,15 +326,6 @@
* register one global type
*/
public final void addGlobalTypeDecl(XSTypeDecl decl) {
- if (decl == null) {
- System.err.println("decl");
- System.exit(0);
- }
- else if (decl.getXSTypeName() == null) {
- System.err.println("decl.whatever");
- System.exit(0);
- }
-
fGlobalTypeDecls.put(decl.getXSTypeName(), decl);
}
@@ -414,10 +409,34 @@
return fComplexTypeDecls;
}
+ // anyType and anySimpleType: because there are so many places where
+ // we need direct access to these two types
+ final static XSComplexTypeDecl fAnyType = new XSComplexTypeDecl();
+ final static DatatypeValidator fAnySimpleType = new AnySimpleType();
+ static {
+ fAnyType.fName = SchemaSymbols.ATTVAL_ANYTYPE;
+ fAnyType.fTargetNamespace = SchemaSymbols.URI_SCHEMAFORSCHEMA;
+ fAnyType.fBaseType = fAnyType;
+ fAnyType.fDerivedBy = SchemaSymbols.RESTRICTION;
+ fAnyType.fContentType = XSComplexTypeDecl.CONTENTTYPE_MIXED;
+ XSWildcardDecl wildcard = new XSWildcardDecl();
+ XSParticleDecl particle = new XSParticleDecl();
+ particle.fMinOccurs = 0;
+ particle.fMaxOccurs = SchemaSymbols.OCCURRENCE_UNBOUNDED;
+ particle.fType = XSParticleDecl.PARTICLE_WILDCARD;
+ particle.fValue = wildcard;
+ fAnyType.fParticle = particle;
+ fAnyType.fAttrGrp.fAttributeWC = wildcard;
+
+ AnySimpleType astype = (AnySimpleType)fAnySimpleType;
+ astype.fLocalName = SchemaSymbols.ATTVAL_ANYSIMPLETYPE;
+ // REVISIT: set target namespace
+ // REVISIT: set fAnyType as the base of fAnySimpleType
+ }
+
// the grammars to hold built-in types
final static SchemaGrammar SG_SchemaNS = new SchemaGrammar(null, true);
final static SchemaGrammar SG_SchemaBasicSet = new SchemaGrammar(null, false);
-
static final XSComplexTypeDecl[] resize(XSComplexTypeDecl[] oldArray, int newSize) {
XSComplexTypeDecl[] newArray = new XSComplexTypeDecl[newSize];
1.30 +13 -14 xml-xerces/java/src/org/apache/xerces/impl/v2/SchemaValidator.java
Index: SchemaValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/SchemaValidator.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- SchemaValidator.java 2001/10/16 15:11:37 1.29
+++ SchemaValidator.java 2001/10/17 21:46:09 1.30
@@ -114,7 +114,7 @@
* @author Andy Clark, IBM
* @author Jeffrey Rodriguez IBM
*
- * @version $Id: SchemaValidator.java,v 1.29 2001/10/16 15:11:37 elena Exp $
+ * @version $Id: SchemaValidator.java,v 1.30 2001/10/17 21:46:09 sandygao Exp $
*/
public class SchemaValidator
implements XMLComponent, XMLDocumentFilter,
@@ -852,7 +852,7 @@
// get error reporter
fErrorReporter = (XMLErrorReporter)componentManager.getProperty(ERROR_REPORTER);
-
+
fValidationManager= (ValidationManager)componentManager.getProperty(VALIDATION_MANAGER);
fValidationManager.reset();
@@ -1010,7 +1010,7 @@
if (DEBUG) {
System.out.println("handleStartElement: " +element);
}
-
+
// we receive prefix binding events before this one,
// so at this point, the prefix bindings for this element is done,
@@ -1145,7 +1145,7 @@
// Element Locally Valid (Type)
// 2 Its {abstract} must be false.
if (fCurrentType != null) {
- if ((fCurrentType.getXSType() & XSTypeDecl.COMPLEX_TYPE) != 0) {
+ if (fCurrentType.getXSType() == XSTypeDecl.COMPLEX_TYPE) {
XSComplexTypeDecl ctype = (XSComplexTypeDecl)fCurrentType;
if (ctype.isAbstractType()) {
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"});
@@ -1156,7 +1156,7 @@
// if the element decl is not found
if (fCurrentType == null ) {
if (fDoValidation) {
-
+
// if this is the root element, or wildcard = strict, report error
if (fElementDepth == 0) {
// report error, because it's root element
@@ -1176,7 +1176,7 @@
// then try to get the content model
fCurrentCM = null;
if (fCurrentType != null) {
- if ((fCurrentType.getXSType() & XSTypeDecl.COMPLEX_TYPE) != 0) {
+ if (fCurrentType.getXSType() == XSTypeDecl.COMPLEX_TYPE) {
fCurrentCM = ((XSComplexTypeDecl)fCurrentType).getContentModel(fCMBuilder);
}
}
@@ -1197,7 +1197,7 @@
// now validate everything related with the attributes
// first, get the attribute group
XSAttributeGroupDecl attrGrp = null;
- if ((fCurrentType.getXSType() & XSTypeDecl.COMPLEX_TYPE) != 0) {
+ if (fCurrentType.getXSType() == XSTypeDecl.COMPLEX_TYPE) {
XSComplexTypeDecl ctype = (XSComplexTypeDecl)fCurrentType;
attrGrp = ctype.fAttrGrp;
}
@@ -1348,7 +1348,7 @@
if (colonptr > 0) {
prefix = fSymbolTable.addSymbol(xsiType.substring(0,colonptr));
localpart = xsiType.substring(colonptr+1);
- }
+ }
// REVISIT: if we take the null approach (instead of ""),
// we need to chech the retrned value from getURI
// to see whether a binding is found.
@@ -1374,7 +1374,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).
int block = fCurrentElemDecl.fBlock;
- if ((fCurrentType.getXSType() & XSTypeDecl.COMPLEX_TYPE) != 0)
+ if (fCurrentType.getXSType() == XSTypeDecl.COMPLEX_TYPE)
block |= ((XSComplexTypeDecl)fCurrentType).fBlock;
if (!XSConstraints.checkTypeDerivationOk(type, fCurrentType, block))
reportSchemaError("cvc-elt.4.3", new Object[]{element.rawname, xsiType});
@@ -1415,8 +1415,7 @@
// Element Locally Valid (Type)
// 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) != 0) {
+ if (fCurrentType == null || fCurrentType.getXSType() == XSTypeDecl.SIMPLE_TYPE) {
int attCount = attributes.getLength();
for (int index = 0; index < attCount; index++) {
attributes.getName(index, fTempQName);
@@ -1678,7 +1677,7 @@
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) != 0) {
+ if (fCurrentType.getXSType() == 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) {
@@ -1693,7 +1692,7 @@
if (ctype.fDatatypeValidator.compare((String)actualValue, (String)fCurrentElemDecl.fDefault) != 0)
reportSchemaError("cvc-elt.5.2.2.2.2", new Object[]{element.rawname, content, fCurrentElemDecl.fDefault.toString()});
}
- } else if ((fCurrentType.getXSType() & XSTypeDecl.SIMPLE_TYPE) != 0) {
+ } else if (fCurrentType.getXSType() == XSTypeDecl.SIMPLE_TYPE) {
DatatypeValidator sType = (DatatypeValidator)fCurrentType;
// REVISIT: compare should be equal, and takes object, instead of string
// do it in the new datatype design
@@ -1713,7 +1712,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) != 0) {
+ if (fCurrentType.getXSType() == 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});
1.5 +17 -9 xml-xerces/java/src/org/apache/xerces/impl/v2/SubstitutionGroupHandler.java
Index: SubstitutionGroupHandler.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/SubstitutionGroupHandler.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SubstitutionGroupHandler.java 2001/10/15 22:55:16 1.4
+++ SubstitutionGroupHandler.java 2001/10/17 21:46:09 1.5
@@ -64,7 +64,7 @@
*
* @author Sandy Gao, IBM
*
- * @version $Id: SubstitutionGroupHandler.java,v 1.4 2001/10/15 22:55:16 sandygao Exp $
+ * @version $Id: SubstitutionGroupHandler.java,v 1.5 2001/10/17 21:46:09 sandygao Exp $
*/
class SubstitutionGroupHandler {
@@ -112,23 +112,31 @@
// 3.9.4 Element Sequence Locally Valid (Particle) 2.3.3
// check whether one element decl matches an element with the given qname
- boolean substitutionGroupOK(QName element, XSElementDecl exemplar) {
+ XSElementDecl getMatchingElemDecl(QName element, XSElementDecl exemplar) {
+ if (element.localpart == exemplar.fName &&
+ element.uri == exemplar.fTargetNamespace) {
+ return exemplar;
+ }
+
// if the decl blocks substitution, return false
if ((exemplar.fBlock & SchemaSymbols.SUBSTITUTION) != 0)
- return false;
+ return null;
// get grammar of the element
SchemaGrammar sGrammar = fGrammarResolver.getGrammar(element.uri);
if (sGrammar == null)
- return false;
+ return null;
// get the decl for the element
XSElementDecl eDecl = sGrammar.getGlobalElementDecl(element.localpart);
if (eDecl == null)
- return false;
+ return null;
// and check by using substitutionGroup information
- return substitutionGroupOK(eDecl, exemplar, exemplar.fBlock);
+ if (substitutionGroupOK(eDecl, exemplar, exemplar.fBlock))
+ return eDecl;
+
+ return null;
}
// 3.3.6 Substitution Group OK (Transitive)
@@ -145,14 +153,14 @@
// initialize the derivation method to be that of the type of D
XSTypeDecl type = element.fType;
- if ((type.getXSType() & XSTypeDecl.COMPLEX_TYPE) != 0)
+ if (type.getXSType() == XSTypeDecl.COMPLEX_TYPE)
devMethod = ((XSComplexTypeDecl)type).fDerivedBy;
else
devMethod = SchemaSymbols.RESTRICTION;
// initialize disallowed substitution to the passed in blocking constraint
type = exemplar.fType;
- if ((type.getXSType() & XSTypeDecl.COMPLEX_TYPE) != 0)
+ if (type.getXSType() == 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 . . .
@@ -161,7 +169,7 @@
// 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) != 0) {
+ if (type.getXSType() == XSTypeDecl.COMPLEX_TYPE) {
devMethod |= ((XSComplexTypeDecl)type).fDerivedBy;
blockConstraint |= ((XSComplexTypeDecl)type).fBlock;
} else {
1.3 +7 -5 xml-xerces/java/src/org/apache/xerces/impl/v2/XSAllCM.java
Index: XSAllCM.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSAllCM.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XSAllCM.java 2001/10/15 22:55:16 1.2
+++ XSAllCM.java 2001/10/17 21:46:09 1.3
@@ -63,7 +63,7 @@
* XSAllCM implements XSCMValidator and handles <all>
*
* @author Pavani Mukthipudi, Sun Microsystems Inc.
- * @version $Id: XSAllCM.java,v 1.2 2001/10/15 22:55:16 sandygao Exp $
+ * @version $Id: XSAllCM.java,v 1.3 2001/10/17 21:46:09 sandygao Exp $
*/
public class XSAllCM implements XSCMValidator {
@@ -166,11 +166,12 @@
*/
public Object oneTransition (QName elementName, int[] currentState, SubstitutionGroupHandler subGroupHandler) {
+ Object matchingDecl = null;
+
for (int i = 0; i < fNumElements; i++) {
- if (fAllElements[i].fTargetNamespace == elementName.uri &&
- fAllElements[i].fName == elementName.localpart ||
- subGroupHandler.substitutionGroupOK(elementName, fAllElements[i])) {
+ matchingDecl = subGroupHandler.getMatchingElemDecl(elementName, fAllElements[i]);
+ if (matchingDecl != null) {
if (currentState[i+1] == STATE_START) {
currentState[i+1] = STATE_VALID;
@@ -188,7 +189,8 @@
if (currentState[0] == STATE_START) {
currentState[0] = STATE_VALID;
}
- return fAllElements[i];
+
+ return matchingDecl;
}
}
1.2 +28 -23 xml-xerces/java/src/org/apache/xerces/impl/v2/XSConstraints.java
Index: XSConstraints.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSConstraints.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XSConstraints.java 2001/09/25 18:54:44 1.1
+++ XSConstraints.java 2001/10/17 21:46:09 1.2
@@ -65,7 +65,7 @@
*
* @author Sandy Gao, IBM
*
- * @version $Id: XSConstraints.java,v 1.1 2001/09/25 18:54:44 sandygao Exp $
+ * @version $Id: XSConstraints.java,v 1.2 2001/10/17 21:46:09 sandygao Exp $
*/
public class XSConstraints {
@@ -75,21 +75,23 @@
*/
public static boolean checkTypeDerivationOk(XSTypeDecl derived, XSTypeDecl base, int block) {
// if derived is anyType, then it's valid only if base is anyType too
- if (derived.getXSType() == XSTypeDecl.ANY_TYPE)
+ if (derived == SchemaGrammar.fAnyType)
return derived == base;
// if derived is anySimpleType, then it's valid only if the base
// is ur-type
- if (derived.getXSType() == XSTypeDecl.ANYSIMPLE_TYPE)
- return (base.getXSType() & XSTypeDecl.UR_TYPE) != 0;
+ if (derived == SchemaGrammar.fAnySimpleType) {
+ return (base == SchemaGrammar.fAnyType ||
+ base == SchemaGrammar.fAnySimpleType);
+ }
// if derived is simple type
- if ((derived.getXSType() & XSTypeDecl.SIMPLE_TYPE) != 0) {
+ if (derived.getXSType() == XSTypeDecl.SIMPLE_TYPE) {
// if base is complex type
- if ((base.getXSType() & XSTypeDecl.COMPLEX_TYPE) != 0) {
+ if (base.getXSType() == XSTypeDecl.COMPLEX_TYPE) {
// if base is anyType, change base to anySimpleType,
// otherwise, not valid
- if (base.getXSType() == XSTypeDecl.ANY_TYPE)
- base = SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYSIMPLETYPE);
+ if (base == SchemaGrammar.fAnyType)
+ base = SchemaGrammar.fAnySimpleType;
else
return false;
}
@@ -107,15 +109,17 @@
public static boolean checkSimpleDerivationOk(DatatypeValidator derived, XSTypeDecl base, int block) {
// if derived is anySimpleType, then it's valid only if the base
// is ur-type
- if (derived.getXSType() == XSTypeDecl.ANYSIMPLE_TYPE)
- return (base.getXSType() & XSTypeDecl.UR_TYPE) != 0;
+ if (derived == SchemaGrammar.fAnySimpleType) {
+ return (base == SchemaGrammar.fAnyType ||
+ base == SchemaGrammar.fAnySimpleType);
+ }
// if base is complex type
- if ((base.getXSType() & XSTypeDecl.COMPLEX_TYPE) != 0) {
+ if (base.getXSType() == XSTypeDecl.COMPLEX_TYPE) {
// if base is anyType, change base to anySimpleType,
// otherwise, not valid
- if (base.getXSType() == XSTypeDecl.ANY_TYPE)
- base = SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYSIMPLETYPE);
+ if (base == SchemaGrammar.fAnyType)
+ base = SchemaGrammar.fAnySimpleType;
else
return false;
}
@@ -129,7 +133,7 @@
*/
public static boolean checkComplexDerivationOk(XSComplexTypeDecl derived, XSTypeDecl base, int block) {
// if derived is anyType, then it's valid only if base is anyType too
- if (derived.getXSType() == XSTypeDecl.ANY_TYPE)
+ if (derived == SchemaGrammar.fAnyType)
return derived == base;
return checkComplexDerivation((XSComplexTypeDecl)derived, base, block);
}
@@ -158,7 +162,7 @@
return true;
// 2.2.2 D's �base type definition� is not the �simple ur-type definition� and is validly derived from B given the subset, as defined by this constraint.
- if (directBase.getXSType() != XSTypeDecl.ANYSIMPLE_TYPE &&
+ if (directBase != SchemaGrammar.fAnySimpleType &&
checkSimpleDerivation(directBase, base, block)) {
return true;
}
@@ -166,7 +170,7 @@
// 2.2.3 D's {variety} is list or union and B is the �simple ur-type definition�.
if ((derived instanceof ListDatatypeValidator ||
derived instanceof UnionDatatypeValidator) &&
- base.getXSType() == XSTypeDecl.ANYSIMPLE_TYPE) {
+ base == SchemaGrammar.fAnySimpleType) {
return true;
}
@@ -205,24 +209,25 @@
return true;
// 2.3 All of the following must be true:
- int directType = directBase.getXSType();
// 2.3.1 D's {base type definition} must not be the �ur-type definition�.
- if ((directType & XSTypeDecl.UR_TYPE) != 0)
+ if (directBase == SchemaGrammar.fAnyType ||
+ directBase == SchemaGrammar.fAnySimpleType) {
return false;
+ }
// 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 ((directType & XSTypeDecl.COMPLEX_TYPE) != 0)
+ if (directBase.getXSType() == 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 ((directType & XSTypeDecl.SIMPLE_TYPE) != 0) {
+ if (directBase.getXSType() == XSTypeDecl.SIMPLE_TYPE) {
// if base is complex type
- if ((base.getXSType() & XSTypeDecl.COMPLEX_TYPE) != 0) {
+ if (base.getXSType() == XSTypeDecl.COMPLEX_TYPE) {
// if base is anyType, change base to anySimpleType,
// otherwise, not valid
- if (base.getXSType() == XSTypeDecl.ANY_TYPE)
- base = SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(SchemaSymbols.ATTVAL_ANYSIMPLETYPE);
+ if (base == SchemaGrammar.fAnyType)
+ base = SchemaGrammar.fAnySimpleType;
else
return false;
}
1.16 +5 -6 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDAbstractParticleTraverser.java
Index: XSDAbstractParticleTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDAbstractParticleTraverser.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- XSDAbstractParticleTraverser.java 2001/10/16 19:31:35 1.15
+++ XSDAbstractParticleTraverser.java 2001/10/17 21:46:09 1.16
@@ -65,7 +65,7 @@
/**
* @author Elena Litani, IBM
* @author Sandy Gao, IBM
- * @version $Id: XSDAbstractParticleTraverser.java,v 1.15 2001/10/16 19:31:35 lmartin Exp $
+ * @version $Id: XSDAbstractParticleTraverser.java,v 1.16 2001/10/17 21:46:09 sandygao Exp $
*/
abstract class XSDAbstractParticleTraverser extends XSDAbstractTraverser {
@@ -135,16 +135,15 @@
}
}
- if (right != null) {
+ if (left != null) {
temp = new XSParticleDecl();
temp.fType = XSParticleDecl.PARTICLE_ALL;
temp.fValue = left;
temp.fOtherValue = right;
left = temp;
}
-
- // REVISIT: model group
+ // REVISIT: model group
// Quick fix for the case that particle <all> does not have any children.
// For now we return null. In the future we might want to return model group decl.
if (left != null) {
@@ -309,11 +308,11 @@
}
}
- // REVISIT: model group
+ // REVISIT: model group
// Quick fix for the case that particles <choice> | <sequence> do not have any children.
// For now we return null. In the future we might want to return model group decl.
- if (left !=null) {
+ if (left != null) {
temp = new XSParticleDecl();
if (choice)
temp.fType = XSParticleDecl.PARTICLE_CHOICE;
1.29 +12 -22 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDAbstractTraverser.java
Index: XSDAbstractTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDAbstractTraverser.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- XSDAbstractTraverser.java 2001/10/17 21:22:25 1.28
+++ XSDAbstractTraverser.java 2001/10/17 21:46:09 1.29
@@ -77,20 +77,10 @@
* @author Elena Litani, IBM
* @author Rahul Srivastava, Sun Microsystems Inc.
*
- * @version $Id: XSDAbstractTraverser.java,v 1.28 2001/10/17 21:22:25 lmartin Exp $
+ * @version $Id: XSDAbstractTraverser.java,v 1.29 2001/10/17 21:46:09 sandygao Exp $
*/
abstract class XSDAbstractTraverser {
- protected static final QName ANY_TYPE = new QName(null,
- SchemaSymbols.ATTVAL_ANYTYPE,
- SchemaSymbols.ATTVAL_ANYTYPE,
- SchemaSymbols.URI_SCHEMAFORSCHEMA);
-
- protected static final QName ANY_SIMPLE_TYPE = new QName(null,
- SchemaSymbols.ATTVAL_ANYSIMPLETYPE,
- SchemaSymbols.ATTVAL_ANYTYPE,
- SchemaSymbols.URI_SCHEMAFORSCHEMA);
-
protected static final String NO_NAME = "(no name)";
// Flags for checkOccurrences to indicate any special
@@ -160,7 +150,7 @@
// REVISIT: an annotation decl should be returned when we support PSVI
}
- DatatypeValidator createRestrictedValidator(DatatypeValidator baseValidator,
+ DatatypeValidator createRestrictedValidator(DatatypeValidator baseValidator,
Hashtable facetData, XMLErrorReporter reporter) {
DatatypeValidator newDV=null;
@@ -168,7 +158,7 @@
Class [] validatorArgsClass = new Class[] {
org.apache.xerces.impl.v2.datatypes.DatatypeValidator.class,
java.util.Hashtable.class,
- boolean.class,
+ boolean.class,
org.apache.xerces.impl.XMLErrorReporter.class};
if (facetData != null) {
@@ -214,12 +204,12 @@
Element nodeAfterFacets;
}
- fFacetInfo traverseFacets(Element content, Object[] contentAttrs, String simpleTypeName,
- DatatypeValidator baseValidator, XSDocumentInfo schemaDoc,
+ fFacetInfo traverseFacets(Element content, Object[] contentAttrs, String simpleTypeName,
+ DatatypeValidator baseValidator, XSDocumentInfo schemaDoc,
SchemaGrammar grammar) {
fFacetInfo fi = new fFacetInfo();
- Hashtable fFacetData = new Hashtable(10);
+ Hashtable fFacetData = new Hashtable(10);
short flags = 0; // flag facets that have fixed="true"
int numEnumerationLiterals = 0;
Vector enumData = new Vector();
@@ -262,7 +252,7 @@
}
else if (facet.equals(SchemaSymbols.ELT_ANNOTATION) || facet.equals(SchemaSymbols.ELT_SIMPLETYPE)) {
//REVISIT:
- Object[] args = {simpleTypeName};
+ Object[] args = {simpleTypeName};
fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
"ListUnionRestrictionError",
args,
@@ -314,7 +304,7 @@
facetType= DatatypeValidator.FACET_TOTALDIGITS;
}
else if (facet.equals(SchemaSymbols.ELT_FRACTIONDIGITS)) {
- facetType = DatatypeValidator.FACET_FRACTIONDIGITS;
+ facetType = DatatypeValidator.FACET_FRACTIONDIGITS;
}
else if (facet.equals(SchemaSymbols.ELT_WHITESPACE)) {
@@ -325,7 +315,7 @@
}
else {
break; // a non-facet
- }
+ }
if (content.getAttribute( SchemaSymbols.ATT_FIXED).equals(SchemaSymbols.ATTVAL_TRUE) ||
content.getAttribute( SchemaSymbols.ATT_FIXED).equals(SchemaSymbols.ATTVAL_TRUE_1)) {
@@ -376,7 +366,7 @@
attrGrp.addAttributeUse(tempAttrUse);
}
else {
- reportGenericSchemaError("Duplicate attribute " +
+ reportGenericSchemaError("Duplicate attribute " +
tempAttrUse.fAttrDecl.fName + " found ");
}
}
@@ -394,7 +384,7 @@
attrGrp.addAttributeUse(attrUseS[i]);
}
else {
- reportGenericSchemaError("Duplicate attribute " +
+ reportGenericSchemaError("Duplicate attribute " +
existingAttrUse.fAttrDecl.fName + " found ");
}
}
@@ -504,7 +494,7 @@
String particleName, Element parent,
int allContextFlags,
long defaultVals) {
-
+
int min = particle.fMinOccurs;
int max = particle.fMaxOccurs;
1.18 +6 -6 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDAttributeTraverser.java
Index: XSDAttributeTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDAttributeTraverser.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- XSDAttributeTraverser.java 2001/10/10 14:41:19 1.17
+++ XSDAttributeTraverser.java 2001/10/17 21:46:09 1.18
@@ -82,7 +82,7 @@
*
* @author Sandy Gao, IBM
*
- * @version $Id: XSDAttributeTraverser.java,v 1.17 2001/10/10 14:41:19 elena Exp $
+ * @version $Id: XSDAttributeTraverser.java,v 1.18 2001/10/17 21:46:09 sandygao Exp $
*/
class XSDAttributeTraverser extends XSDAbstractTraverser {
@@ -225,10 +225,10 @@
attribute.fTargetNamespace = schemaDoc.fTargetNamespace;
else
attribute.fTargetNamespace = null;
- } else if (schemaDoc.fAreLocalElementsQualified) {
+ } else if (schemaDoc.fAreLocalAttributesQualified) {
attribute.fTargetNamespace = schemaDoc.fTargetNamespace;
} else {
- attribute.fTargetNamespace = null;
+ attribute.fTargetNamespace = null;
}
// get 'value constraint'
@@ -278,7 +278,7 @@
}
if (attrType == null) {
- attrType = (DatatypeValidator)fSchemaHandler.getGlobalDecl(schemaDoc, fSchemaHandler.TYPEDECL_TYPE, ANY_SIMPLE_TYPE);
+ attrType = SchemaGrammar.fAnySimpleType;
}
attribute.fType = attrType;
@@ -372,7 +372,7 @@
try {
//REVISIT: Our validators don't return Objects yet, instead return null
- //
+ //
//attribute.fDefault = attribute.fType.validate((String)attribute.fDefault, null);
attribute.fType.validate((String)attribute.fDefault, null);
} catch (InvalidDatatypeValueException ide) {
@@ -390,7 +390,7 @@
try {
//REVISIT: Our validators don't return Objects yet, instead return null
- //
+ //
//attrUse.fDefault = attrUse.fAttrDecl.fType.validate((String)attrUse.fDefault, null);
attrUse.fAttrDecl.fType.validate((String)attrUse.fDefault, null);
} catch (InvalidDatatypeValueException ide) {
1.27 +124 -126 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDComplexTypeTraverser.java
Index: XSDComplexTypeTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDComplexTypeTraverser.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- XSDComplexTypeTraverser.java 2001/10/17 21:20:12 1.26
+++ XSDComplexTypeTraverser.java 2001/10/17 21:46:09 1.27
@@ -80,7 +80,7 @@
* ((group | all | choice | sequence)?,
* ((attribute | attributeGroup)*, anyAttribute?))))
* </complexType>
- * @version $Id: XSDComplexTypeTraverser.java,v 1.26 2001/10/17 21:20:12 lmartin Exp $
+ * @version $Id: XSDComplexTypeTraverser.java,v 1.27 2001/10/17 21:46:09 sandygao Exp $
*/
class XSDComplexTypeTraverser extends XSDAbstractParticleTraverser {
@@ -101,11 +101,11 @@
Object[] errorSubstText=null;
ComplexTypeRecoverableError() {super();}
ComplexTypeRecoverableError(String msgKey) {super(msgKey);}
- ComplexTypeRecoverableError(String msgKey, Object[] args)
+ ComplexTypeRecoverableError(String msgKey, Object[] args)
{super(msgKey);
errorSubstText=args;
}
-
+
}
/**
@@ -192,17 +192,16 @@
//
// EMPTY complexType with complexContent
//
-
+
// set the base to the anyType
- complexType.fBaseType = (XSTypeDecl)fSchemaHandler.getGlobalDecl(schemaDoc,
- fSchemaHandler.TYPEDECL_TYPE, ANY_TYPE);
+ complexType.fBaseType = SchemaGrammar.fAnyType;
processComplexContent(child, complexType, mixedAtt.booleanValue(),
schemaDoc, grammar);
}
else if (DOMUtil.getLocalName(child).equals
(SchemaSymbols.ELT_SIMPLECONTENT)) {
//
- // SIMPLE CONTENT
+ // SIMPLE CONTENT
//
traverseSimpleContent(child, complexType, schemaDoc, grammar);
}
@@ -219,8 +218,7 @@
//
// set the base to the anyType
- complexType.fBaseType = (XSTypeDecl)fSchemaHandler.getGlobalDecl(schemaDoc,
- fSchemaHandler.TYPEDECL_TYPE, ANY_TYPE);
+ complexType.fBaseType = SchemaGrammar.fAnyType;
processComplexContent(child, complexType, mixedAtt.booleanValue(),
schemaDoc, grammar);
}
@@ -239,21 +237,21 @@
}
- private void traverseSimpleContent(Element simpleContentElement,
+ private void traverseSimpleContent(Element simpleContentElement,
XSComplexTypeDecl typeInfo,
- XSDocumentInfo schemaDoc,
- SchemaGrammar grammar)
+ XSDocumentInfo schemaDoc,
+ SchemaGrammar grammar)
throws ComplexTypeRecoverableError {
+
-
String typeName = typeInfo.fName;
Object[] attrValues = fAttrChecker.checkAttributes(simpleContentElement, false,
schemaDoc);
// -----------------------------------------------------------------------
- // Set content type
+ // Set content type
// -----------------------------------------------------------------------
- typeInfo.fContentType = XSComplexTypeDecl.CONTENTTYPE_SIMPLE;
+ typeInfo.fContentType = XSComplexTypeDecl.CONTENTTYPE_SIMPLE;
typeInfo.fParticle = null;
Element simpleContent = checkContent(DOMUtil.getFirstChildElement(simpleContentElement), attrValues, schemaDoc);
@@ -274,16 +272,16 @@
else if (simpleContentName.equals(SchemaSymbols.ELT_EXTENSION))
typeInfo.fDerivedBy = SchemaSymbols.EXTENSION;
else {
- // REVISIT - should create a msg in properties file
- reportGenericSchemaError("ComplexType " + typeName + ": " +
- "Child of simpleContent must be restriction or extension");
- throw new ComplexTypeRecoverableError();
+ // REVISIT - should create a msg in properties file
+ reportGenericSchemaError("ComplexType " + typeName + ": " +
+ "Child of simpleContent must be restriction or extension");
+ throw new ComplexTypeRecoverableError();
}
if (DOMUtil.getNextSiblingElement(simpleContent) != null) {
- // REVISIT - should create a msg in properties file
- reportGenericSchemaError("ComplexType " + typeName + ": " +
- "Invalid child of simpleContent");
- throw new ComplexTypeRecoverableError();
+ // REVISIT - should create a msg in properties file
+ reportGenericSchemaError("ComplexType " + typeName + ": " +
+ "Invalid child of simpleContent");
+ throw new ComplexTypeRecoverableError();
}
attrValues = fAttrChecker.checkAttributes(simpleContent, false,
@@ -293,39 +291,39 @@
// -----------------------------------------------------------------------
- // Need a base type.
+ // Need a base type.
// -----------------------------------------------------------------------
if (baseTypeName==null) {
- // REVISIT - should create a msg in properties file
- reportGenericSchemaError("ComplexType " + typeName + ": " +
+ // REVISIT - should create a msg in properties file
+ reportGenericSchemaError("ComplexType " + typeName + ": " +
"The base attribute must be specified for the restriction or extension");
- throw new ComplexTypeRecoverableError();
+ throw new ComplexTypeRecoverableError();
}
- XSTypeDecl type = (XSTypeDecl)fSchemaHandler.getGlobalDecl(schemaDoc,
+ XSTypeDecl type = (XSTypeDecl)fSchemaHandler.getGlobalDecl(schemaDoc,
XSDHandler.TYPEDECL_TYPE, baseTypeName);
- if (type==null)
- throw new ComplexTypeRecoverableError();
+ if (type==null)
+ throw new ComplexTypeRecoverableError();
typeInfo.fBaseType = type;
-
+
DatatypeValidator baseValidator = null;
XSComplexTypeDecl baseComplexType = null;
// If the base type is complex, it must have simpleContent
if ((type instanceof XSComplexTypeDecl)) {
- baseComplexType = (XSComplexTypeDecl)type;
+ baseComplexType = (XSComplexTypeDecl)type;
if (baseComplexType.fContentType != XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
- // REVISIT - should create a msg in properties file
- reportGenericSchemaError("ComplexType " + typeName + ": " +
+ // REVISIT - should create a msg in properties file
+ reportGenericSchemaError("ComplexType " + typeName + ": " +
"The base type must be complex");
- throw new ComplexTypeRecoverableError();
+ throw new ComplexTypeRecoverableError();
}
baseValidator = baseComplexType.fDatatypeValidator;
}
else {
- baseValidator = (DatatypeValidator)type;
+ baseValidator = (DatatypeValidator)type;
if (typeInfo.fDerivedBy == SchemaSymbols.RESTRICTION) {
reportGenericSchemaError("ComplexTYpe " + typeName + ": " +
"ct-props-correct.2: The base is a simple type. It cannot be used in a derivation by restriction");
@@ -334,23 +332,23 @@
}
// -----------------------------------------------------------------------
- // Check that the base permits the derivation
+ // Check that the base permits the derivation
// -----------------------------------------------------------------------
if ((baseValidator.getFinalSet() & typeInfo.fDerivedBy)!=0) {
- //REVISIT - generate error
- reportGenericSchemaError("ComplexType " + typeName + ": " +
+ //REVISIT - generate error
+ reportGenericSchemaError("ComplexType " + typeName + ": " +
"The base type has a final value that prohibits this derivation");
- throw new ComplexTypeRecoverableError();
+ throw new ComplexTypeRecoverableError();
}
// -----------------------------------------------------------------------
- // Skip over any potential annotations
+ // Skip over any potential annotations
// -----------------------------------------------------------------------
- simpleContent = checkContent(DOMUtil.getFirstChildElement(simpleContent),
+ simpleContent = checkContent(DOMUtil.getFirstChildElement(simpleContent),
null, schemaDoc);
// -----------------------------------------------------------------------
- // Process a RESTRICTION
+ // Process a RESTRICTION
// -----------------------------------------------------------------------
if (typeInfo.fDerivedBy == SchemaSymbols.RESTRICTION) {
@@ -359,16 +357,16 @@
// The data type validator will be based on it, if specified
// -----------------------------------------------------------------------
if (DOMUtil.getLocalName(simpleContent).equals(SchemaSymbols.ELT_SIMPLETYPE )) {
- DatatypeValidator dv =fSchemaHandler.fSimpleTypeTraverser.traverseLocal(simpleContent, schemaDoc, grammar);
- if (dv == null)
+ DatatypeValidator dv =fSchemaHandler.fSimpleTypeTraverser.traverseLocal(simpleContent, schemaDoc, grammar);
+ if (dv == null)
throw new ComplexTypeRecoverableError();
//check that this datatype validator is validly derived from the base
//according to derivation-ok-restriction 5.1.1
- if (!XSConstraints.checkSimpleDerivationOk(dv, baseValidator,
+ if (!XSConstraints.checkSimpleDerivationOk(dv, baseValidator,
baseValidator.getFinalSet()) ) {
- reportGenericSchemaError("ComplexType " + typeName + ": " +
+ reportGenericSchemaError("ComplexType " + typeName + ": " +
"derivation-ok-restriction.5.1.1: The content type is not a valid restriction of the content type of the base");
}
baseValidator = dv;
@@ -376,19 +374,19 @@
}
// -----------------------------------------------------------------------
- // Traverse any facets
+ // Traverse any facets
// -----------------------------------------------------------------------
Hashtable fFacetData = null;
Element attrNode = null;
if (simpleContent!=null) {
- fFacetInfo fi = traverseFacets(simpleContent, null, typeName, baseValidator,
+ fFacetInfo fi = traverseFacets(simpleContent, null, typeName, baseValidator,
schemaDoc, grammar);
fFacetData = fi.facetdata;
attrNode = fi.nodeAfterFacets;
}
- typeInfo.fDatatypeValidator = createRestrictedValidator(baseValidator, fFacetData, fErrorReporter);
+ typeInfo.fDatatypeValidator = createRestrictedValidator(baseValidator, fFacetData, fErrorReporter);
if (typeInfo.fDatatypeValidator == null) {
// REVISIT error msg
reportGenericSchemaError("Internal error - could not create a new validator");
@@ -396,10 +394,10 @@
}
// -----------------------------------------------------------------------
- // Traverse any attributes
+ // Traverse any attributes
// -----------------------------------------------------------------------
if (!isAttrOrAttrGroup(attrNode)) {
- throw new ComplexTypeRecoverableError("src-ct",
+ throw new ComplexTypeRecoverableError("src-ct",
new Object[]{typeInfo.fName});
}
traverseAttrsAndAttrGrps(attrNode,typeInfo.fAttrGrp,
@@ -415,17 +413,17 @@
}
// -----------------------------------------------------------------------
- // Process a EXTENSION
+ // Process a EXTENSION
// -----------------------------------------------------------------------
else {
- typeInfo.fDatatypeValidator = baseValidator;
+ typeInfo.fDatatypeValidator = baseValidator;
if (simpleContent != null) {
// -----------------------------------------------------------------------
- // Traverse any attributes
+ // Traverse any attributes
// -----------------------------------------------------------------------
- Element attrNode = simpleContent;
+ Element attrNode = simpleContent;
if (!isAttrOrAttrGroup(attrNode)) {
- throw new ComplexTypeRecoverableError("src-ct",
+ throw new ComplexTypeRecoverableError("src-ct",
new Object[]{typeInfo.fName});
}
traverseAttrsAndAttrGrps(attrNode,typeInfo.fAttrGrp,
@@ -434,26 +432,26 @@
mergeAttributes(baseComplexType.fAttrGrp, typeInfo.fAttrGrp, typeName, true);
}
}
- }
+ }
}
- private void traverseComplexContent(Element complexContentElement,
+ private void traverseComplexContent(Element complexContentElement,
XSComplexTypeDecl typeInfo,
- boolean mixedOnType, XSDocumentInfo schemaDoc,
- SchemaGrammar grammar)
+ boolean mixedOnType, XSDocumentInfo schemaDoc,
+ SchemaGrammar grammar)
throws ComplexTypeRecoverableError {
+
-
String typeName = typeInfo.fName;
Object[] attrValues = fAttrChecker.checkAttributes(complexContentElement, false,
schemaDoc);
// -----------------------------------------------------------------------
- // Determine if this is mixed content
+ // Determine if this is mixed content
// -----------------------------------------------------------------------
- boolean mixedContent = mixedOnType;
+ boolean mixedContent = mixedOnType;
Boolean mixedAtt = (Boolean) attrValues[XSAttributeChecker.ATTIDX_MIXED];
if (mixedAtt != null) {
mixedContent = mixedAtt.booleanValue();
@@ -473,7 +471,7 @@
if (complexContent==null) {
throw new ComplexTypeRecoverableError();
}
-
+
// -----------------------------------------------------------------------
// The content should be either "restriction" or "extension"
// -----------------------------------------------------------------------
@@ -483,16 +481,16 @@
else if (complexContentName.equals(SchemaSymbols.ELT_EXTENSION))
typeInfo.fDerivedBy = SchemaSymbols.EXTENSION;
else {
- // REVISIT - should create a msg in properties file
- reportGenericSchemaError("ComplexType " + typeName + ": " +
- "Child of complexContent must be restriction or extension");
- throw new ComplexTypeRecoverableError();
+ // REVISIT - should create a msg in properties file
+ reportGenericSchemaError("ComplexType " + typeName + ": " +
+ "Child of complexContent must be restriction or extension");
+ throw new ComplexTypeRecoverableError();
}
if (DOMUtil.getNextSiblingElement(complexContent) != null) {
- // REVISIT - should create a msg in properties file
- reportGenericSchemaError("ComplexType " + typeName + ": " +
- "Invalid child of complexContent");
- throw new ComplexTypeRecoverableError();
+ // REVISIT - should create a msg in properties file
+ reportGenericSchemaError("ComplexType " + typeName + ": " +
+ "Invalid child of complexContent");
+ throw new ComplexTypeRecoverableError();
}
attrValues = fAttrChecker.checkAttributes(complexContent, false,
@@ -505,50 +503,50 @@
// Need a base type. Check that it's a complex type
// -----------------------------------------------------------------------
if (baseTypeName==null) {
- // REVISIT - should create a msg in properties file
- reportGenericSchemaError("ComplexType " + typeName + ": " +
+ // REVISIT - should create a msg in properties file
+ reportGenericSchemaError("ComplexType " + typeName + ": " +
"The base attribute must be specified for the restriction or extension");
- throw new ComplexTypeRecoverableError();
+ throw new ComplexTypeRecoverableError();
}
- XSTypeDecl type = (XSTypeDecl)fSchemaHandler.getGlobalDecl(schemaDoc,
+ XSTypeDecl type = (XSTypeDecl)fSchemaHandler.getGlobalDecl(schemaDoc,
XSDHandler.TYPEDECL_TYPE, baseTypeName);
- if (type==null)
- throw new ComplexTypeRecoverableError();
+ if (type==null)
+ throw new ComplexTypeRecoverableError();
if (! (type instanceof XSComplexTypeDecl)) {
- // REVISIT - should create a msg in properties file
- reportGenericSchemaError("ComplexType " + typeName + ": " +
+ // REVISIT - should create a msg in properties file
+ reportGenericSchemaError("ComplexType " + typeName + ": " +
"The base type must be complex");
- throw new ComplexTypeRecoverableError();
+ throw new ComplexTypeRecoverableError();
}
- XSComplexTypeDecl baseType = (XSComplexTypeDecl)type;
+ XSComplexTypeDecl baseType = (XSComplexTypeDecl)type;
typeInfo.fBaseType = baseType;
// -----------------------------------------------------------------------
- // Check that the base permits the derivation
+ // Check that the base permits the derivation
// -----------------------------------------------------------------------
if ((baseType.fFinal & typeInfo.fDerivedBy)!=0) {
- //REVISIT - generate error
- reportGenericSchemaError("ComplexType " + typeName + ": " +
+ //REVISIT - generate error
+ reportGenericSchemaError("ComplexType " + typeName + ": " +
"The base type has a final value that prohibits this derivation");
- throw new ComplexTypeRecoverableError();
+ throw new ComplexTypeRecoverableError();
}
// -----------------------------------------------------------------------
- // Skip over any potential annotations
+ // Skip over any potential annotations
// -----------------------------------------------------------------------
- complexContent = checkContent(DOMUtil.getFirstChildElement(complexContent),
+ complexContent = checkContent(DOMUtil.getFirstChildElement(complexContent),
null, schemaDoc);
// -----------------------------------------------------------------------
// Process the content. Note: should I try to catch any complexType errors
- // here in order to return the attr array?
+ // here in order to return the attr array?
// -----------------------------------------------------------------------
- processComplexContent(complexContent, typeInfo, mixedContent, schemaDoc,
+ processComplexContent(complexContent, typeInfo, mixedContent, schemaDoc,
grammar);
-
+
// -----------------------------------------------------------------------
// Compose the final content and attribute uses
// -----------------------------------------------------------------------
@@ -557,15 +555,15 @@
// This is an RESTRICTION
- if (typeInfo.fParticle==null && (!(baseContent==null ||
+ if (typeInfo.fParticle==null && (!(baseContent==null ||
baseContent.emptiable()))) {
- //REVISIT - need better error msg
- throw new ComplexTypeRecoverableError("derivation-ok-restriction",
+ //REVISIT - need better error msg
+ throw new ComplexTypeRecoverableError("derivation-ok-restriction",
null);
}
if (typeInfo.fParticle!=null && baseContent==null) {
- //REVISIT - need better error msg
- throw new ComplexTypeRecoverableError("derivation-ok-restriction",
+ //REVISIT - need better error msg
+ throw new ComplexTypeRecoverableError("derivation-ok-restriction",
null);
}
@@ -575,7 +573,7 @@
reportGenericSchemaError("ComplexType " + typeName + ": " + error);
throw new ComplexTypeRecoverableError();
}
-
+
}
else {
@@ -585,7 +583,7 @@
// Check if the contentType of the base is consistent with the new type
// cos-ct-extends.1.4.2.2
if (baseType.fContentType != XSComplexTypeDecl.CONTENTTYPE_EMPTY) {
- if (((baseType.fContentType ==
+ if (((baseType.fContentType ==
XSComplexTypeDecl.CONTENTTYPE_ELEMENT) &&
mixedContent) ||
((baseType.fContentType ==
@@ -593,21 +591,21 @@
// REVISIT - need to add a property message
- reportGenericSchemaError("cos-ct-extends.1.4.2.2.2.1: The content type of the base type " + baseTypeName + " and derived type " +
+ reportGenericSchemaError("cos-ct-extends.1.4.2.2.2.1: The content type of the base type " + baseTypeName + " and derived type " +
typeName + " must both be mixed or element-only");
throw new ComplexTypeRecoverableError();
}
}
- // Create the particle
+ // Create the particle
if (typeInfo.fParticle == null) {
typeInfo.fParticle = baseContent;
}
else if (baseContent==null) {
}
else {
- if (typeInfo.fParticle.fType == XSParticleDecl.PARTICLE_ALL ||
+ if (typeInfo.fParticle.fType == XSParticleDecl.PARTICLE_ALL ||
baseType.fParticle.fType == XSParticleDecl.PARTICLE_ALL) {
reportGenericSchemaError("cos-all-limited.1.2: An \"all\" model group that is part of a complex type definition must constitute the entire {content type} of the definition");
throw new ComplexTypeRecoverableError();
@@ -615,48 +613,48 @@
XSParticleDecl temp = new XSParticleDecl();
temp.fType = XSParticleDecl.PARTICLE_SEQUENCE;
temp.fValue = baseContent;
- temp.fOtherValue = typeInfo.fParticle;
+ temp.fOtherValue = typeInfo.fParticle;
typeInfo.fParticle = temp;
}
// Set the contentType
- if (mixedContent)
+ if (mixedContent)
typeInfo.fContentType = XSComplexTypeDecl.CONTENTTYPE_MIXED;
else if (typeInfo.fParticle == null)
typeInfo.fContentType = XSComplexTypeDecl.CONTENTTYPE_EMPTY;
else
typeInfo.fContentType = XSComplexTypeDecl.CONTENTTYPE_ELEMENT;
-
+
mergeAttributes(baseType.fAttrGrp, typeInfo.fAttrGrp, typeName, true);
}
-
+
} // end of traverseComplexContent
- // This method merges attribute uses from the base, into the derived set.
- // The first duplicate attribute, if any, is returned.
- // LM: may want to merge with attributeGroup processing.
- private void mergeAttributes(XSAttributeGroupDecl fromAttrGrp,
+ // This method merges attribute uses from the base, into the derived set.
+ // The first duplicate attribute, if any, is returned.
+ // LM: may want to merge with attributeGroup processing.
+ private void mergeAttributes(XSAttributeGroupDecl fromAttrGrp,
XSAttributeGroupDecl toAttrGrp,
String typeName,
- boolean extension)
+ boolean extension)
throws ComplexTypeRecoverableError {
XSAttributeUse[] attrUseS = fromAttrGrp.getAttributeUses();
XSAttributeUse existingAttrUse, duplicateAttrUse = null;
for (int i=0; i<attrUseS.length; i++) {
- existingAttrUse = toAttrGrp.getAttributeUse(attrUseS[i].fAttrDecl.fTargetNamespace,
- attrUseS[i].fAttrDecl.fName);
+ existingAttrUse = toAttrGrp.getAttributeUse(attrUseS[i].fAttrDecl.fTargetNamespace,
+ attrUseS[i].fAttrDecl.fName);
if (existingAttrUse == null) {
- toAttrGrp.addAttributeUse(attrUseS[i]);
- }
+ toAttrGrp.addAttributeUse(attrUseS[i]);
+ }
else {
if (extension) {
- //REVISIT - should create a msg in properties file
- reportGenericSchemaError("ComplexType " + typeName + ": " +
+ //REVISIT - should create a msg in properties file
+ reportGenericSchemaError("ComplexType " + typeName + ": " +
"Duplicate attribute use " + existingAttrUse.fAttrDecl.fName );
- throw new ComplexTypeRecoverableError();
+ throw new ComplexTypeRecoverableError();
}
}
}
@@ -676,7 +674,7 @@
private void processComplexContent(Element complexContentChild,
- XSComplexTypeDecl typeInfo,
+ XSComplexTypeDecl typeInfo,
boolean isMixed,
XSDocumentInfo schemaDoc, SchemaGrammar grammar)
throws ComplexTypeRecoverableError {
@@ -737,11 +735,11 @@
// -------------------------------------------------------------
- // Now, process attributes
+ // Now, process attributes
// -------------------------------------------------------------
if (attrNode != null) {
if (!isAttrOrAttrGroup(attrNode)) {
- throw new ComplexTypeRecoverableError("src-ct",
+ throw new ComplexTypeRecoverableError("src-ct",
new Object[]{typeInfo.fName});
}
traverseAttrsAndAttrGrps(attrNode,typeInfo.fAttrGrp,schemaDoc,grammar);
@@ -757,7 +755,7 @@
private boolean isAttrOrAttrGroup(Element e)
{
- String elementName = DOMUtil.getLocalName(e);
+ String elementName = DOMUtil.getLocalName(e);
if (elementName.equals(SchemaSymbols.ELT_ATTRIBUTE) ||
elementName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP) ||
@@ -797,10 +795,10 @@
private void handleComplexTypeError(String messageId,Object[] args,
- XSComplexTypeDecl typeInfo) {
+ XSComplexTypeDecl typeInfo) {
if (messageId!=null) {
- reportSchemaError(messageId, args);
+ reportSchemaError(messageId, args);
}
//
@@ -808,7 +806,7 @@
// validation
//
typeInfo.fContentType = XSComplexTypeDecl.CONTENTTYPE_MIXED;
- typeInfo.fParticle = getErrorContent();
+ typeInfo.fParticle = getErrorContent();
// REVISIT - do we need to create a template element?
@@ -827,7 +825,7 @@
particle.fValue = wildcard;
particle.fMinOccurs = 0;
particle.fMaxOccurs = SchemaSymbols.OCCURRENCE_UNBOUNDED;
- fErrorContent.fValue = particle;
+ fErrorContent.fValue = particle;
fErrorContent.fOtherValue = null;
}
return fErrorContent;
1.23 +4 -9 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDElementTraverser.java
Index: XSDElementTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDElementTraverser.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- XSDElementTraverser.java 2001/10/10 20:48:42 1.22
+++ XSDElementTraverser.java 2001/10/17 21:46:09 1.23
@@ -89,15 +89,10 @@
*
* @author Sandy Gao, IBM
*
- * @version $Id: XSDElementTraverser.java,v 1.22 2001/10/10 20:48:42 neilg Exp $
+ * @version $Id: XSDElementTraverser.java,v 1.23 2001/10/17 21:46:09 sandygao Exp $
*/
class XSDElementTraverser extends XSDAbstractTraverser {
- protected static final QName ANY_TYPE = new QName(null,
- SchemaSymbols.ATTVAL_ANYTYPE,
- SchemaSymbols.ATTVAL_ANYTYPE,
- SchemaSymbols.URI_SCHEMAFORSCHEMA);
-
protected XSElementDecl fTempElementDecl = new XSElementDecl();
protected XSParticleDecl fTempParticleDecl = new XSParticleDecl();
@@ -261,11 +256,11 @@
if (formAtt.intValue() == SchemaSymbols.FORM_QUALIFIED)
element.fTargetNamespace = schemaDoc.fTargetNamespace;
else
- element.fTargetNamespace = null;
+ element.fTargetNamespace = null;
} else if (schemaDoc.fAreLocalElementsQualified) {
element.fTargetNamespace = schemaDoc.fTargetNamespace;
} else {
- element.fTargetNamespace = null;
+ element.fTargetNamespace = null;
}
// get 'block', 'final', 'nillable', 'abstract'
@@ -330,7 +325,7 @@
}
if (elementType == null) {
- elementType = (XSTypeDecl)fSchemaHandler.getGlobalDecl(schemaDoc, fSchemaHandler.TYPEDECL_TYPE, ANY_TYPE);
+ elementType = SchemaGrammar.fAnyType;
}
element.fType = elementType;
1.5 +33 -22 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDFACM.java
Index: XSDFACM.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDFACM.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XSDFACM.java 2001/10/15 22:55:16 1.4
+++ XSDFACM.java 2001/10/17 21:46:09 1.5
@@ -69,7 +69,7 @@
* it then uses in its validation algorithm.
*
* @author Neil Graham, IBM
- * @version $Id: XSDFACM.java,v 1.4 2001/10/15 22:55:16 sandygao Exp $
+ * @version $Id: XSDFACM.java,v 1.5 2001/10/17 21:46:09 sandygao Exp $
*/
public class XSDFACM
implements XSCMValidator {
@@ -316,38 +316,26 @@
*/
public Object oneTransition(QName curElem, int[] state, SubstitutionGroupHandler subGroupHandler) {
int curState = state[0];
+
if(curState == XSCMValidator.FIRST_ERROR || curState == XSCMValidator.SUBSEQUENT_ERROR) {
// there was an error last time; so just go find correct Object in fElemmMap.
// ... after resetting state[0].
if(curState == XSCMValidator.FIRST_ERROR)
state[0] = XSCMValidator.SUBSEQUENT_ERROR;
- int elemIndex = 0;
- for (; elemIndex < fElemMapSize; elemIndex++) {
- int type = fElemMapType[elemIndex] ;
- if (type == XSParticleDecl.PARTICLE_ELEMENT) {
- if ((curElem.uri == ((XSElementDecl)fElemMap[elemIndex]).fTargetNamespace) &&
- (curElem.localpart == ((XSElementDecl)fElemMap[elemIndex]).fName) ||
- subGroupHandler.substitutionGroupOK(curElem, (XSElementDecl)fElemMap[elemIndex])) {
- return fElemMap[elemIndex];
- }
- }
- else if (type == XSParticleDecl.PARTICLE_WILDCARD) {
- if(((XSWildcardDecl)fElemMap[elemIndex]).allowNamespace(curElem.uri))
- return fElemMap[elemIndex];
- }
- }
+ return findMatchingDecl(curElem, subGroupHandler);
}
int nextState = 0;
int elemIndex = 0;
+ Object matchingDecl = null;
for (; elemIndex < fElemMapSize; elemIndex++) {
int type = fElemMapType[elemIndex] ;
if (type == XSParticleDecl.PARTICLE_ELEMENT) {
- if ((curElem.uri == ((XSElementDecl)fElemMap[elemIndex]).fTargetNamespace) &&
- (curElem.localpart == ((XSElementDecl)fElemMap[elemIndex]).fName) ||
- subGroupHandler.substitutionGroupOK(curElem, (XSElementDecl)fElemMap[elemIndex])) {
+ matchingDecl = subGroupHandler.getMatchingElemDecl(curElem, (XSElementDecl)fElemMap[elemIndex]);
+
+ if (matchingDecl != null) {
nextState = fTransTable[curState][elemIndex];
if (nextState != -1)
break;
@@ -355,6 +343,7 @@
}
else if (type == XSParticleDecl.PARTICLE_WILDCARD) {
if(((XSWildcardDecl)fElemMap[elemIndex]).allowNamespace(curElem.uri)) {
+ matchingDecl = fElemMap[elemIndex];
nextState = fTransTable[curState][elemIndex];
if (nextState != -1)
break;
@@ -366,12 +355,32 @@
// and return null
if (elemIndex == fElemMapSize) {
state[0] = XSCMValidator.FIRST_ERROR;
- return null;
+ return findMatchingDecl(curElem, subGroupHandler);
}
state[0] = nextState;
- return fElemMap[elemIndex];
- } // oneTransition(QName, int[], SubstitutionGroup): Object
+ return matchingDecl;
+ } // oneTransition(QName, int[], SubstitutionGroupHandler): Object
+
+ Object findMatchingDecl(QName curElem, SubstitutionGroupHandler subGroupHandler) {
+ Object matchingDecl = null;
+
+ for (int elemIndex = 0; elemIndex < fElemMapSize; elemIndex++) {
+ int type = fElemMapType[elemIndex] ;
+ if (type == XSParticleDecl.PARTICLE_ELEMENT) {
+ matchingDecl = subGroupHandler.getMatchingElemDecl(curElem, (XSElementDecl)fElemMap[elemIndex]);
+ if (matchingDecl != null) {
+ return matchingDecl;
+ }
+ }
+ else if (type == XSParticleDecl.PARTICLE_WILDCARD) {
+ if(((XSWildcardDecl)fElemMap[elemIndex]).allowNamespace(curElem.uri))
+ return fElemMap[elemIndex];
+ }
+ }
+
+ return null;
+ }
// This method returns the start states of the content model.
public int[] startContentModel() {
@@ -563,6 +572,8 @@
// Get the current leaf's element
final XSElementDecl element = fLeafList[outIndex].getElement();
+ if (element.fName == fEOCString)
+ continue;
// See if the current leaf node's element index is in the list
int inIndex = 0;
1.44 +105 -95 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDHandler.java
Index: XSDHandler.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDHandler.java,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- XSDHandler.java 2001/10/17 16:00:45 1.43
+++ XSDHandler.java 2001/10/17 21:46:09 1.44
@@ -97,7 +97,7 @@
* schema, other grammars may be constructed as a side-effect.
*
* @author Neil Graham, IBM
- * @version $Id: XSDHandler.java,v 1.43 2001/10/17 16:00:45 neilg Exp $
+ * @version $Id: XSDHandler.java,v 1.44 2001/10/17 21:46:09 sandygao Exp $
*/
class XSDHandler {
@@ -280,7 +280,7 @@
Document schemaRoot = getSchema(schemaNamespace, schemaHint);
if(schemaRoot == null) {
// something went wrong right off the hop
- fElementTraverser.reportGenericSchemaError("Could not locate a schema document corresponding to grammar " + schemaNamespace);
+ reportGenericSchemaError("Could not locate a schema document corresponding to grammar " + schemaNamespace);
return null;
}
// handle empty string URI as null
@@ -293,7 +293,7 @@
fRoot = constructTrees(schemaRoot, schemaNamespace);
if(fRoot == null) {
// REVISIT: something went wrong; print error about no schema found
- fElementTraverser.reportGenericSchemaError("Could not locate a schema document");
+ reportGenericSchemaError("Could not locate a schema document");
return null;
}
@@ -343,7 +343,7 @@
currSchemaInfo.fTargetNamespace = callerTNS;
currSchemaInfo.fIsChameleonSchema = true;
} else if(callerTNS != currSchemaInfo.fTargetNamespace) {
- fElementTraverser.reportSchemaError("src-include.2", new Object [] {callerTNS, currSchemaInfo.fTargetNamespace});
+ reportSchemaError("src-include.2", new Object [] {callerTNS, currSchemaInfo.fTargetNamespace});
}
}
SchemaGrammar sg = null;
@@ -373,7 +373,7 @@
if(schemaNamespace != null)
schemaNamespace = fSymbolTable.addSymbol(schemaNamespace);
if(schemaNamespace == currSchemaInfo.fTargetNamespace) {
- fElementTraverser.reportSchemaError("src-import.1.1", new Object [] {schemaNamespace});
+ reportSchemaError("src-import.1.1", new Object [] {schemaNamespace});
}
fAttributeChecker.returnAttrArray(includeAttrs, currSchemaInfo);
// consciously throw away whether was a duplicate; don't care.
@@ -459,13 +459,13 @@
} else if(DOMUtil.getLocalName(globalComp).equals(SchemaSymbols.ELT_INCLUDE) ||
DOMUtil.getLocalName(globalComp).equals(SchemaSymbols.ELT_IMPORT)) {
if(!dependenciesCanOccur) {
- fElementTraverser.reportSchemaError("sch-props-correct.1", new Object [] {DOMUtil.getLocalName(globalComp)});
+ reportSchemaError("sch-props-correct.1", new Object [] {DOMUtil.getLocalName(globalComp)});
}
// we've dealt with this; mark as traversed
DOMUtil.setHidden(globalComp);
} else if(DOMUtil.getLocalName(globalComp).equals(SchemaSymbols.ELT_REDEFINE)) {
if(!dependenciesCanOccur) {
- fElementTraverser.reportSchemaError("sch-props-correct.1", new Object [] {DOMUtil.getLocalName(globalComp)});
+ reportSchemaError("sch-props-correct.1", new Object [] {DOMUtil.getLocalName(globalComp)});
}
for(Element redefineComp = DOMUtil.getFirstChildElement(globalComp);
redefineComp != null;
@@ -506,7 +506,7 @@
lName, targetLName);
} else {
// REVISIT: report schema element ordering error
- fElementTraverser.reportSchemaError("src-redefine", new Object [] {componentType});
+ reportSchemaError("src-redefine", new Object [] {componentType});
}
} // end march through <redefine> children
// and now set as traversed
@@ -534,7 +534,7 @@
} else if(componentType.equals(SchemaSymbols.ELT_NOTATION)) {
checkForDuplicateNames(qName, fUnparsedNotationRegistry, globalComp, currSchemaDoc);
} else {
- fElementTraverser.reportSchemaError("sch-props-correct.1", new Object [] {DOMUtil.getLocalName(globalComp)});
+ reportSchemaError("sch-props-correct.1", new Object [] {DOMUtil.getLocalName(globalComp)});
}
}
} // end for
@@ -663,68 +663,68 @@
protected Object getGlobalDecl(XSDocumentInfo currSchema,
int declType,
QName declToTraverse) {
- XSDocumentInfo schemaWithDecl = null;
- SchemaGrammar sGrammar = null;
- Element decl = null;
- Object retObj = null;
+ // from the schema spec, all built-in types are present in all schemas,
+ // so if the requested component is a type, and could be found in the
+ // default schema grammar, we should return that type.
+ // otherwise (since we would support user-defined schema grammar) we'll
+ // use the normal way to get the decl
if (declToTraverse.uri != null &&
- declToTraverse.uri.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)) {
- sGrammar = SchemaGrammar.SG_SchemaNS;
- if(currSchema.fTargetNamespace != SchemaSymbols.URI_SCHEMAFORSCHEMA) {
- if(declType == TYPEDECL_TYPE) {
- retObj = sGrammar.getGlobalTypeDecl(declToTraverse.localpart);
- }
- if (retObj == null) {
- fElementTraverser.reportGenericSchemaError("Could not locate a component corresponding to " + declToTraverse.localpart);
- return null;
- }
- }
- } else {
- String declKey = declToTraverse.uri == null? ","+declToTraverse.localpart:
- declToTraverse.uri+","+declToTraverse.localpart;
- switch (declType) {
- case ATTRIBUTE_TYPE :
- decl = (Element)fUnparsedAttributeRegistry.get(declKey);
- break;
- case ATTRIBUTEGROUP_TYPE :
- decl = (Element)fUnparsedAttributeGroupRegistry.get(declKey);
- break;
- case ELEMENT_TYPE :
- decl = (Element)fUnparsedElementRegistry.get(declKey);
- break;
- case GROUP_TYPE :
- decl = (Element)fUnparsedGroupRegistry.get(declKey);
- break;
- case IDENTITYCONSTRAINT_TYPE :
- decl = (Element)fUnparsedIdentityConstraintRegistry.get(declKey);
- break;
- case NOTATION_TYPE :
- decl = (Element)fUnparsedNotationRegistry.get(declKey);
- break;
- case TYPEDECL_TYPE :
- decl = (Element)fUnparsedTypeRegistry.get(declKey);
- break;
- default:
- // REVISIT: report internal error...
- fElementTraverser.reportGenericSchemaError("XSDHandler asked to locate component of type " + declType + "; it does not recognize this type (internal error!)");
- }
- if (decl != null)
- schemaWithDecl = findXSDocumentForDecl(currSchema, decl);
- else {
- fElementTraverser.reportGenericSchemaError("Could not locate a component corresponding to " + declToTraverse.localpart);
- return null;
+ declToTraverse.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA) {
+ if (declType == TYPEDECL_TYPE) {
+ Object retObj = SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(declToTraverse.localpart);
+ if (retObj != null)
+ return retObj;
}
+ }
- if (schemaWithDecl == null) {
- // cannot get to this schema from the one containing the requesting decl
- // REVISIT: report component not found error
- fElementTraverser.reportGenericSchemaError("components from the schema document containing " + declToTraverse.localpart + " are not referenceable from schema document " + currSchema);
- return null;
- }
- sGrammar = fGrammarResolver.getGrammar(schemaWithDecl.fTargetNamespace);
+ XSDocumentInfo schemaWithDecl = null;
+ Element decl = null;
+
+ String declKey = declToTraverse.uri == null? ","+declToTraverse.localpart:
+ declToTraverse.uri+","+declToTraverse.localpart;
+ switch (declType) {
+ case ATTRIBUTE_TYPE :
+ decl = (Element)fUnparsedAttributeRegistry.get(declKey);
+ break;
+ case ATTRIBUTEGROUP_TYPE :
+ decl = (Element)fUnparsedAttributeGroupRegistry.get(declKey);
+ break;
+ case ELEMENT_TYPE :
+ decl = (Element)fUnparsedElementRegistry.get(declKey);
+ break;
+ case GROUP_TYPE :
+ decl = (Element)fUnparsedGroupRegistry.get(declKey);
+ break;
+ case IDENTITYCONSTRAINT_TYPE :
+ decl = (Element)fUnparsedIdentityConstraintRegistry.get(declKey);
+ break;
+ case NOTATION_TYPE :
+ decl = (Element)fUnparsedNotationRegistry.get(declKey);
+ break;
+ case TYPEDECL_TYPE :
+ decl = (Element)fUnparsedTypeRegistry.get(declKey);
+ break;
+ default:
+ // REVISIT: report internal error...
+ reportGenericSchemaError("XSDHandler asked to locate component of type " + declType + "; it does not recognize this type (internal error!)");
+ }
+ if (decl != null)
+ schemaWithDecl = findXSDocumentForDecl(currSchema, decl);
+ else {
+ reportGenericSchemaError("Could not locate a component corresponding to " + declToTraverse.localpart);
+ return null;
}
+ if (schemaWithDecl == null) {
+ // cannot get to this schema from the one containing the requesting decl
+ // REVISIT: report component not found error
+ reportGenericSchemaError("components from the schema document containing " + declToTraverse.localpart + " are not referenceable from schema document " + currSchema);
+ return null;
+ }
+ SchemaGrammar sGrammar = fGrammarResolver.getGrammar(schemaWithDecl.fTargetNamespace);
+
+ Object retObj = null;
switch (declType) {
case ATTRIBUTE_TYPE :
retObj = sGrammar.getGlobalAttributeDecl(declToTraverse.localpart);
@@ -752,15 +752,10 @@
if (retObj != null)
return retObj;
- // decl can be null, if the grammar picked was SG_SchemaNS
- if (decl == null) {
- fElementTraverser.reportGenericSchemaError("Could not locate a component corresponding to " +declToTraverse.uri+":"+declToTraverse.localpart);
- return null;
- }
- else if (DOMUtil.isHidden(decl)) {
+ if (DOMUtil.isHidden(decl)) {
// decl must not be null if we're here...
//REVISIT: report an error: circular reference
- fElementTraverser.reportGenericSchemaError("Circular reference detected in schema component named " + declToTraverse.prefix+":"+declToTraverse.localpart);
+ reportGenericSchemaError("Circular reference detected in schema component named " + declToTraverse.prefix+":"+declToTraverse.localpart);
return null;
}
@@ -1065,10 +1060,10 @@
if(redefinedSchema == currSchema) { // object comp. okay here
// now have to do some renaming...
currComp.setAttribute(SchemaSymbols.ATT_NAME, newName);
- if(currSchema.fTargetNamespace == null)
+ if(currSchema.fTargetNamespace == null)
registry.put(","+newName, currComp);
else
- registry.put(currSchema.fTargetNamespace+","+newName, currComp);
+ registry.put(currSchema.fTargetNamespace+","+newName, currComp);
// and take care of nested redefines by calling recursively:
if(currSchema.fTargetNamespace == null)
checkForDuplicateNames(","+newName, registry, currComp, currSchema);
@@ -1076,17 +1071,17 @@
checkForDuplicateNames(currSchema.fTargetNamespace+","+newName, registry, currComp, currSchema);
} else { // we may be redefining the wrong schema
if(collidedWithRedefine) {
- if(currSchema.fTargetNamespace == null)
+ if(currSchema.fTargetNamespace == null)
checkForDuplicateNames(","+newName, registry, currComp, currSchema);
- else
+ else
checkForDuplicateNames(currSchema.fTargetNamespace+","+newName, registry, currComp, currSchema);
} else {
// REVISIT: error that redefined element in wrong schema
- fElementTraverser.reportSchemaError("src-redefine.1", new Object [] {qName});
+ reportSchemaError("src-redefine.1", new Object [] {qName});
}
- }
+ }
} else { // we've just got a flat-out collision
- fElementTraverser.reportSchemaError("sch-props-correct.2", new Object []{qName});
+ reportSchemaError("sch-props-correct.2", new Object []{qName});
}
}
} // checkForDuplicateNames(String, Hashtable, Element, XSDocumentInfo):void
@@ -1124,7 +1119,7 @@
Element grandKid = DOMUtil.getFirstChildElement(child);
if (grandKid == null) {
// fRedefineSucceeded = false;
- fElementTraverser.reportSchemaError("src-redefine.5", null);
+ reportSchemaError("src-redefine.5", null);
} else {
String grandKidName = grandKid.getLocalName();
if(grandKidName.equals(SchemaSymbols.ELT_ANNOTATION)) {
@@ -1133,16 +1128,16 @@
}
if (grandKid == null) {
// fRedefineSucceeded = false;
- fElementTraverser.reportSchemaError("src-redefine.5", null);
+ reportSchemaError("src-redefine.5", null);
} else if(!grandKidName.equals(SchemaSymbols.ELT_RESTRICTION)) {
// fRedefineSucceeded = false;
- fElementTraverser.reportSchemaError("src-redefine.5", null);
+ reportSchemaError("src-redefine.5", null);
} else {
String derivedBase = grandKid.getAttribute( SchemaSymbols.ATT_BASE );
String processedDerivedBase = findQName(derivedBase, currSchema);
if(!processedTypeName.equals(processedDerivedBase)) {
// fRedefineSucceeded = false;
- fElementTraverser.reportSchemaError("src-redefine.5", null);
+ reportSchemaError("src-redefine.5", null);
} else {
// now we have to do the renaming...
int colonptr = derivedBase.indexOf(":");
@@ -1161,20 +1156,20 @@
Element grandKid = DOMUtil.getFirstChildElement(child);
if (grandKid == null) {
// fRedefineSucceeded = false;
- fElementTraverser.reportSchemaError("src-redefine.5", null);
+ reportSchemaError("src-redefine.5", null);
} else {
if(grandKid.getLocalName().equals(SchemaSymbols.ELT_ANNOTATION)) {
grandKid = DOMUtil.getNextSiblingElement(grandKid);
}
if (grandKid == null) {
// fRedefineSucceeded = false;
- fElementTraverser.reportSchemaError("src-redefine.5", null);
+ reportSchemaError("src-redefine.5", null);
} else {
// have to go one more level down; let another pass worry whether complexType is valid.
Element greatGrandKid = DOMUtil.getFirstChildElement(grandKid);
if (greatGrandKid == null) {
// fRedefineSucceeded = false;
- fElementTraverser.reportSchemaError("src-redefine.5", null);
+ reportSchemaError("src-redefine.5", null);
} else {
String greatGrandKidName = greatGrandKid.getLocalName();
if(greatGrandKidName.equals(SchemaSymbols.ELT_ANNOTATION)) {
@@ -1183,17 +1178,17 @@
}
if (greatGrandKid == null) {
// fRedefineSucceeded = false;
- fElementTraverser.reportSchemaError("src-redefine.5", null);
+ reportSchemaError("src-redefine.5", null);
} else if(!greatGrandKidName.equals(SchemaSymbols.ELT_RESTRICTION) &&
!greatGrandKidName.equals(SchemaSymbols.ELT_EXTENSION)) {
// fRedefineSucceeded = false;
- fElementTraverser.reportSchemaError("src-redefine.5", null);
+ reportSchemaError("src-redefine.5", null);
} else {
String derivedBase = greatGrandKid.getAttribute( SchemaSymbols.ATT_BASE );
String processedDerivedBase = findQName(derivedBase, currSchema);
if(!processedTypeName.equals(processedDerivedBase)) {
// fRedefineSucceeded = false;
- fElementTraverser.reportSchemaError("src-redefine.5", null);
+ reportSchemaError("src-redefine.5", null);
} else {
// now we have to do the renaming...
int colonptr = derivedBase.indexOf(":");
@@ -1215,7 +1210,7 @@
int attGroupRefsCount = changeRedefineGroup(processedBaseName, componentType, newName, child, currSchema);
if(attGroupRefsCount > 1) {
// fRedefineSucceeded = false;
- fElementTraverser.reportSchemaError("src-redefine.7.1", new Object []{new Integer(attGroupRefsCount)});
+ reportSchemaError("src-redefine.7.1", new Object []{new Integer(attGroupRefsCount)});
} else if (attGroupRefsCount == 1) {
// return true;
} else
@@ -1229,7 +1224,7 @@
int groupRefsCount = changeRedefineGroup(processedBaseName, componentType, newName, child, currSchema);
if(groupRefsCount > 1) {
// fRedefineSucceeded = false;
- fElementTraverser.reportSchemaError("src-redefine.6.1.1", new Object []{new Integer(groupRefsCount)});
+ reportSchemaError("src-redefine.6.1.1", new Object []{new Integer(groupRefsCount)});
} else if (groupRefsCount == 1) {
// return true;
} else {
@@ -1241,7 +1236,7 @@
} else {
// fRedefineSucceeded = false;
// REVISIT: Localize
- fElementTraverser.reportGenericSchemaError("internal Xerces error; please submit a bug with schema as testcase");
+ reportGenericSchemaError("internal Xerces error; please submit a bug with schema as testcase");
}
// if we get here then we must have reported an error and failed somewhere...
// return false;
@@ -1259,8 +1254,8 @@
prefix = name.substring(0, colonPtr);
String uri = currNSMap.getURI(fSymbolTable.addSymbol(prefix));
String localpart = (colonPtr == 0)?name:name.substring(colonPtr+1);
- if(prefix == this.EMPTY_STRING && uri == null && schemaDoc.fIsChameleonSchema)
- uri = schemaDoc.fTargetNamespace;
+ if(prefix == this.EMPTY_STRING && uri == null && schemaDoc.fIsChameleonSchema)
+ uri = schemaDoc.fTargetNamespace;
if(uri == null)
return ","+localpart;
return uri+","+localpart;
@@ -1301,7 +1296,7 @@
String maxOccurs = child.getAttribute( SchemaSymbols.ATT_MAXOCCURS );
if(!((maxOccurs.length() == 0 || maxOccurs.equals("1"))
&& (minOccurs.length() == 0 || minOccurs.equals("1")))) {
- fElementTraverser.reportSchemaError("src-redefine.6.1.2", new Object [] {ref});
+ reportSchemaError("src-redefine.6.1.2", new Object [] {ref});
}
}
}
@@ -1354,6 +1349,21 @@
}
// if it's visible already than so must be its children
} // setSchemasVisible(XSDocumentInfo): void
+
+ // report schema error
+ void reportSchemaError (String key, Object[] args) {
+ fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
+ key, args,
+ XMLErrorReporter.SEVERITY_ERROR);
+ }
+
+ // REVISIT: is it how we want to handle error reporting?
+ void reportGenericSchemaError (String error) {
+ fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
+ "General",
+ new Object[]{error},
+ XMLErrorReporter.SEVERITY_ERROR);
+ }
/******* only for testing! ******/
public static void main (String args[]) throws Exception {
1.23 +5 -6 xml-xerces/java/src/org/apache/xerces/impl/v2/XSDSimpleTypeTraverser.java
Index: XSDSimpleTypeTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDSimpleTypeTraverser.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- XSDSimpleTypeTraverser.java 2001/10/11 21:05:29 1.22
+++ XSDSimpleTypeTraverser.java 2001/10/17 21:46:09 1.23
@@ -71,7 +71,6 @@
import org.w3c.dom.Node;
import java.lang.reflect.*;
-import java.util.Stack;
import java.util.Hashtable;
import java.util.Vector;
import java.util.StringTokenizer;
@@ -109,7 +108,7 @@
* </union>
*
* @author Elena Litani, IBM
- * @version $Id: XSDSimpleTypeTraverser.java,v 1.22 2001/10/11 21:05:29 elena Exp $
+ * @version $Id: XSDSimpleTypeTraverser.java,v 1.23 2001/10/17 21:46:09 sandygao Exp $
*/
class XSDSimpleTypeTraverser extends XSDAbstractTraverser {
@@ -255,7 +254,7 @@
fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
"InvalidSTContent",
args, XMLErrorReporter.SEVERITY_ERROR);
-
+
}
DatatypeValidator baseValidator = null;
@@ -403,7 +402,7 @@
if (list) {
newDV = new ListDatatypeValidator(baseValidator, fFacetData, true, fErrorReporter);
}
- else if (restriction) {
+ else if (restriction) {
newDV = createRestrictedValidator(baseValidator, fFacetData, fErrorReporter);
}
else { //union
@@ -439,7 +438,7 @@
fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
"UnknownBaseDatatype",
new Object[] {
- DOMUtil.getAttrValue(elm, SchemaSymbols.ATT_NAME), DOMUtil.getAttrValue(elm, SchemaSymbols.ATT_BASE)},
+ DOMUtil.getAttrValue(elm, SchemaSymbols.ATT_NAME), DOMUtil.getAttrValue(elm, SchemaSymbols.ATT_BASE)},
XMLErrorReporter.SEVERITY_ERROR);
return (DatatypeValidator)SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(SchemaSymbols.ATTVAL_STRING);
@@ -450,7 +449,7 @@
if ((baseValidator.getFinalSet() & baseRefContext) != 0) {
fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
"RestrictionBaseFinal",
- new Object[] { baseTypeStr.rawname },
+ new Object[] { baseTypeStr.rawname },
XMLErrorReporter.SEVERITY_ERROR);
}
}
1.15 +2 -2 xml-xerces/java/src/org/apache/xerces/impl/v2/XSElementDecl.java
Index: XSElementDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSElementDecl.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- XSElementDecl.java 2001/10/10 20:48:42 1.14
+++ XSElementDecl.java 2001/10/17 21:46:09 1.15
@@ -65,7 +65,7 @@
*
* @author Elena Litani, IBM
* @author Sandy Gao, IBM
- * @version $Id: XSElementDecl.java,v 1.14 2001/10/10 20:48:42 neilg Exp $
+ * @version $Id: XSElementDecl.java,v 1.15 2001/10/17 21:46:09 sandygao Exp $
*/
public class XSElementDecl {
@@ -142,6 +142,6 @@
}
public String toString() {
- return fTargetNamespace+":"+fName;
+ return fTargetNamespace+","+fName;
}
} // class XMLElementDecl
1.15 +25 -19 xml-xerces/java/src/org/apache/xerces/impl/v2/XSParticleDecl.java
Index: XSParticleDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSParticleDecl.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- XSParticleDecl.java 2001/10/16 19:30:43 1.14
+++ XSParticleDecl.java 2001/10/17 21:46:09 1.15
@@ -62,7 +62,7 @@
*
* @author Sandy Gao, IBM
*
- * @version $Id: XSParticleDecl.java,v 1.14 2001/10/16 19:30:43 lmartin Exp $
+ * @version $Id: XSParticleDecl.java,v 1.15 2001/10/17 21:46:09 sandygao Exp $
*/
public class XSParticleDecl {
@@ -93,13 +93,32 @@
public int fMaxOccurs = 1;
- private final StringBuffer fBuffer = new StringBuffer();
+ private StringBuffer fBuffer = null;
public String toString() {
- // build fBuffering
- fBuffer.setLength(0);
- appendParticle(fBuffer);
- fBuffer.append(" with minOccurs="+fMinOccurs +", maxOccurs="+fMaxOccurs);
+ if (fBuffer == null) {
+ fBuffer = new StringBuffer();
+ appendParticle(fBuffer);
+ // REVISIT: what would be the best form?
+ // 1. do we output "element[1-1]" or just "element"?
+ // 2. do we output "element[3-3]" or "elment[3]"?
+ // 3. how to output "unbounded"?
+ /*if (!(fMinOccurs == 0 && fMaxOccurs == 0 ||
+ fMinOccurs == 1 && fMaxOccurs == 1)) {
+ fBuffer.append("[" + fMinOccurs);
+ if (fMaxOccurs == SchemaSymbols.OCCURRENCE_UNBOUNDED)
+ fBuffer.append("-INF");
+ else if (fMinOccurs != fMaxOccurs)
+ fBuffer.append("-" + fMaxOccurs);
+ fBuffer.append("]");
+ }*/
+ if (!(fMinOccurs == 0 && fMaxOccurs == 0)) {
+ if (fMaxOccurs == SchemaSymbols.OCCURRENCE_UNBOUNDED)
+ fBuffer.append("[" + fMinOccurs + "-UNBOUNDED]");
+ else
+ fBuffer.append("[" + fMinOccurs + "-" + fMaxOccurs + "]");
+ }
+ }
return fBuffer.toString();
}
@@ -134,19 +153,6 @@
fBuffer.append(fOtherValue.toString());
}
fBuffer.append(')');
- break;
- case PARTICLE_ZERO_OR_ONE:
- case PARTICLE_ZERO_OR_MORE:
- case PARTICLE_ONE_OR_MORE:
- fBuffer.append('(');
- fBuffer.append(fValue.toString());
- fBuffer.append(')');
- if (fType == PARTICLE_ZERO_OR_ONE)
- fBuffer.append('?');
- if (fType == PARTICLE_ZERO_OR_MORE)
- fBuffer.append('*');
- if (fType == PARTICLE_ONE_OR_MORE)
- fBuffer.append('+');
break;
}
}
1.8 +21 -27 xml-xerces/java/src/org/apache/xerces/impl/v2/XSSimpleCM.java
Index: XSSimpleCM.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSSimpleCM.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XSSimpleCM.java 2001/10/16 17:21:39 1.7
+++ XSSimpleCM.java 2001/10/17 21:46:09 1.8
@@ -81,7 +81,7 @@
* This model validated on the way in.
*
* @author Elena Litani, IBM
- * @version $Id: XSSimpleCM.java,v 1.7 2001/10/16 17:21:39 elena Exp $
+ * @version $Id: XSSimpleCM.java,v 1.8 2001/10/17 21:46:09 sandygao Exp $
*/
public class XSSimpleCM
implements XSCMValidator {
@@ -154,7 +154,7 @@
* @return Start state of the content model
*/
public int[] startContentModel(){
- return (new int[] {STATE_START});
+ return (new int[] {STATE_START});
}
@@ -174,16 +174,16 @@
}
int state = currentState[0];
+ Object matchingDecl = null;
switch (fOperator) {
case XSParticleDecl.PARTICLE_ELEMENT :
case XSParticleDecl.PARTICLE_ZERO_OR_ONE :
if (state == STATE_START) {
- if (fFirstElement.fTargetNamespace == elementName.uri &&
- fFirstElement.fName == elementName.localpart ||
- subGroupHandler.substitutionGroupOK(elementName, fFirstElement)) {
+ matchingDecl = subGroupHandler.getMatchingElemDecl(elementName, fFirstElement);
+ if (matchingDecl != null) {
currentState[0] = STATE_VALID;
- return fFirstElement;
+ return matchingDecl;
}
//error
}
@@ -191,28 +191,24 @@
case XSParticleDecl.PARTICLE_ZERO_OR_MORE :
case XSParticleDecl.PARTICLE_ONE_OR_MORE :
- if (fFirstElement.fTargetNamespace == elementName.uri &&
- fFirstElement.fName == elementName.localpart ||
- subGroupHandler.substitutionGroupOK(elementName, fFirstElement)) {
+ matchingDecl = subGroupHandler.getMatchingElemDecl(elementName, fFirstElement);
+ if (matchingDecl != null) {
currentState[0] = STATE_VALID;
- return fFirstElement;
+ return matchingDecl;
}
break;
case XSParticleDecl.PARTICLE_CHOICE :
if (state == STATE_START) {
- if (fFirstElement.fTargetNamespace == elementName.uri &&
- fFirstElement.fName == elementName.localpart ||
- subGroupHandler.substitutionGroupOK(elementName, fFirstElement)) {
+ matchingDecl = subGroupHandler.getMatchingElemDecl(elementName, fFirstElement);
+ if (matchingDecl != null) {
currentState[0] = STATE_VALID;
- return fFirstElement;
-
+ return matchingDecl;
}
- else if (fSecondElement.fTargetNamespace == elementName.uri &&
- fSecondElement.fName == elementName.localpart ||
- subGroupHandler.substitutionGroupOK(elementName, fSecondElement)) {
+ matchingDecl = subGroupHandler.getMatchingElemDecl(elementName, fSecondElement);
+ if (matchingDecl != null) {
currentState[0] = STATE_VALID;
- return fSecondElement;
+ return matchingDecl;
}
//error
}
@@ -225,20 +221,18 @@
// we stored, in the stored order.
//
if (state == STATE_START) {
- if (fFirstElement.fTargetNamespace == elementName.uri &&
- fFirstElement.fName == elementName.localpart ||
- subGroupHandler.substitutionGroupOK(elementName, fFirstElement)) {
+ matchingDecl = subGroupHandler.getMatchingElemDecl(elementName, fFirstElement);
+ if (matchingDecl != null) {
currentState[0] = STATE_FIRST;
- return fFirstElement;
+ return matchingDecl;
}
//error
}
else if (state == STATE_FIRST) {
- if (fSecondElement.fTargetNamespace == elementName.uri &&
- fSecondElement.fName == elementName.localpart ||
- subGroupHandler.substitutionGroupOK(elementName, fSecondElement)) {
+ matchingDecl = subGroupHandler.getMatchingElemDecl(elementName, fSecondElement);
+ if (matchingDecl != null) {
currentState[0] = STATE_VALID;
- return fSecondElement;
+ return matchingDecl;
}
//error
}
1.2 +1 -4 xml-xerces/java/src/org/apache/xerces/impl/v2/XSTypeDecl.java
Index: XSTypeDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSTypeDecl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XSTypeDecl.java 2001/09/19 16:17:44 1.1
+++ XSTypeDecl.java 2001/10/17 21:46:09 1.2
@@ -62,15 +62,12 @@
* schema component is a <simpleType> or <complexType> element information item
*
* @author Elena Litani, IBM
- * @version $Id: XSTypeDecl.java,v 1.1 2001/09/19 16:17:44 sandygao Exp $
+ * @version $Id: XSTypeDecl.java,v 1.2 2001/10/17 21:46:09 sandygao Exp $
*/
public interface XSTypeDecl {
public static final short COMPLEX_TYPE = 1;
public static final short SIMPLE_TYPE = 2;
- public static final short UR_TYPE = 4;
- public static final short ANY_TYPE = UR_TYPE | COMPLEX_TYPE;
- public static final short ANYSIMPLE_TYPE = UR_TYPE | SIMPLE_TYPE;
// REVISIT: change XSTypeDecl to an class after the new datatype design
// then we'll add common fields here: name, base, ...
1.8 +239 -237 xml-xerces/java/src/org/apache/xerces/impl/v2/XSWildcardDecl.java
Index: XSWildcardDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSWildcardDecl.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XSWildcardDecl.java 2001/10/15 21:40:58 1.7
+++ XSWildcardDecl.java 2001/10/17 21:46:09 1.8
@@ -67,7 +67,7 @@
* @author Sandy Gao, IBM
* @author Rahul Srivastava, Sun Microsystems Inc.
*
- * @version $Id: XSWildcardDecl.java,v 1.7 2001/10/15 21:40:58 lmartin Exp $
+ * @version $Id: XSWildcardDecl.java,v 1.8 2001/10/17 21:46:09 sandygao Exp $
*/
public class XSWildcardDecl extends XSElementDecl {
@@ -125,259 +125,261 @@
// one of the element in the set. This may be taken as an enhanced feature, later.
public boolean isSubsetOf(XSWildcardDecl superWildcard) {
- // For a namespace constraint (call it sub) to be an intensional subset of another namespace
- // constraint (call it super) one of the following must be true:
-
- // 1 super must be any.
- if (superWildcard.fType == WILDCARD_ANY) {
- return true;
- }
- // 2 All of the following must be true:
- // 2.1 sub must be a pair of not and a namespace name or �absent�.
- // 2.2 super must be a pair of not and the same value.
- else if ( (fType == WILDCARD_OTHER) && (superWildcard.fType == WILDCARD_OTHER) ){
- return (fNamespaceList[0] == superWildcard.fNamespaceList[0]);
- }
- // 3 All of the following must be true:
- // 3.1 sub must be a set whose members are either namespace names or �absent�.
- // 3.2 One of the following must be true:
- // 3.2.1 super must be the same set or a superset thereof.
- // 3.2.2 super must be a pair of not and a namespace name or �absent� and
- // that value must not be in sub's set.
- else if (fType == WILDCARD_LIST) {
- if (superWildcard.fType == WILDCARD_LIST) {
- boolean found;
-
- for (int i=0; i<fNamespaceList.length; i++) {
- found = false;
- for (int j=0; j<superWildcard.fNamespaceList.length; j++)
- if (fNamespaceList[i] == superWildcard.fNamespaceList[j]) {
- found = true;
- break;
- }
- if (!found) return false;
- }
- return true;
- }
- else if (superWildcard.fType == WILDCARD_OTHER) {
- for (int i=0; i<fNamespaceList.length; i++) {
- if (superWildcard.fNamespaceList[0] == fNamespaceList[i])
- return false;
- }
- return true;
- }
- }
-
- return false;
+ // For a namespace constraint (call it sub) to be an intensional subset of another namespace
+ // constraint (call it super) one of the following must be true:
+
+ // 1 super must be any.
+ if (superWildcard.fType == WILDCARD_ANY) {
+ return true;
+ }
+ // 2 All of the following must be true:
+ // 2.1 sub must be a pair of not and a namespace name or �absent�.
+ // 2.2 super must be a pair of not and the same value.
+ else if ( (fType == WILDCARD_OTHER) && (superWildcard.fType == WILDCARD_OTHER) ){
+ return (fNamespaceList[0] == superWildcard.fNamespaceList[0]);
}
-
-
+ // 3 All of the following must be true:
+ // 3.1 sub must be a set whose members are either namespace names or �absent�.
+ // 3.2 One of the following must be true:
+ // 3.2.1 super must be the same set or a superset thereof.
+ // 3.2.2 super must be a pair of not and a namespace name or �absent� and
+ // that value must not be in sub's set.
+ else if (fType == WILDCARD_LIST) {
+ if (superWildcard.fType == WILDCARD_LIST) {
+ boolean found;
+
+ for (int i=0; i<fNamespaceList.length; i++) {
+ found = false;
+ for (int j=0; j<superWildcard.fNamespaceList.length; j++)
+ if (fNamespaceList[i] == superWildcard.fNamespaceList[j]) {
+ found = true;
+ break;
+ }
+ if (!found) return false;
+ }
+ return true;
+ }
+ else if (superWildcard.fType == WILDCARD_OTHER) {
+ for (int i=0; i<fNamespaceList.length; i++) {
+ if (superWildcard.fNamespaceList[0] == fNamespaceList[i])
+ return false;
+ }
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+
public XSWildcardDecl performUnionWith(XSWildcardDecl wildcard) {
- // For a wildcard's {namespace constraint} value to be the intensional union of two other such
- // values (call them O1 and O2): the appropriate case among the following must be true:
-
- XSWildcardDecl unionWildcard = new XSWildcardDecl();
-
+ // For a wildcard's {namespace constraint} value to be the intensional union of two other such
+ // values (call them O1 and O2): the appropriate case among the following must be true:
+
+ XSWildcardDecl unionWildcard = new XSWildcardDecl();
+
// 1 If O1 and O2 are the same value, then that value must be the value.
- if (areSame(wildcard)) {
- unionWildcard.fType = fType;
- if (fType != WILDCARD_ANY)
- //REVISIT: Is it okay to copy like this.
- unionWildcard.fNamespaceList = fNamespaceList;
- }
- // 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;
- }
- // 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) ) {
- boolean found;
- Vector union = null;
-
- // This way, the vector may be resized exactly once or none.
- if (fNamespaceList.length > wildcard.fNamespaceList.length)
- union = new Vector(fNamespaceList.length, wildcard.fNamespaceList.length);
- else
- union = new Vector(wildcard.fNamespaceList.length, fNamespaceList.length);
-
- for (int i=0; i<fNamespaceList.length; i++)
- union.addElement(fNamespaceList[i]);
-
- for (int i=0; i<wildcard.fNamespaceList.length; i++) {
- found = false;
- for (int j=0; j<fNamespaceList.length; j++)
- if (fNamespaceList[j] == wildcard.fNamespaceList[i]) {
- found = true;
- break;
- }
- if (!found)
- union.addElement(wildcard.fNamespaceList[i]);
- }
-
- unionWildcard.fType = WILDCARD_LIST;
- // copy elements from vector to array
- int size = union.size();
- unionWildcard.fNamespaceList = new String[size];
- union.copyInto(unionWildcard.fNamespaceList);
- }
-
- //REVISIT: 4 If the two are negations of different namespace names, then the intersection is not expressible.
-
- // 5 If either O1 or O2 is a pair of not and a namespace name and the other is a set of
- // (namespace names or �absent�), then The appropriate case among the following must be true:
+ if (areSame(wildcard)) {
+ unionWildcard.fType = fType;
+ if (fType != WILDCARD_ANY)
+ //REVISIT: Is it okay to copy like this.
+ unionWildcard.fNamespaceList = fNamespaceList;
+ }
+ // 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;
+ }
+ // 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) ) {
+ boolean found;
+ Vector union = null;
+
+ // This way, the vector may be resized exactly once or none.
+ if (fNamespaceList.length > wildcard.fNamespaceList.length)
+ union = new Vector(fNamespaceList.length, wildcard.fNamespaceList.length);
+ else
+ union = new Vector(wildcard.fNamespaceList.length, fNamespaceList.length);
+
+ for (int i=0; i<fNamespaceList.length; i++)
+ union.addElement(fNamespaceList[i]);
+
+ for (int i=0; i<wildcard.fNamespaceList.length; i++) {
+ found = false;
+ for (int j=0; j<fNamespaceList.length; j++)
+ if (fNamespaceList[j] == wildcard.fNamespaceList[i]) {
+ found = true;
+ break;
+ }
+ if (!found)
+ union.addElement(wildcard.fNamespaceList[i]);
+ }
+
+ unionWildcard.fType = WILDCARD_LIST;
+ // copy elements from vector to array
+ int size = union.size();
+ unionWildcard.fNamespaceList = new String[size];
+ union.copyInto(unionWildcard.fNamespaceList);
+ }
+
+ //REVISIT: 4 If the two are negations of different namespace names, then the intersection is not expressible.
+
+ // 5 If either O1 or O2 is a pair of not and a namespace name and the other is a set of
+ // (namespace names or �absent�), then The appropriate case among the following must be true:
// 5.1 If the set includes the negated namespace name, then any must be the value.
- // 5.2 If the set does not include the negated namespace name, then whichever of O1 or O2
+ // 5.2 If the set does not include the negated namespace name, then whichever of O1 or O2
// is a pair of not and a namespace name must be the value.
- else if ( ((fType == WILDCARD_OTHER) && (wildcard.fType == WILDCARD_LIST)) ||
- ((fType == WILDCARD_LIST) && (wildcard.fType == WILDCARD_OTHER)) ) {
-
- int i=0;
-
- if (fType == WILDCARD_OTHER) {
- for (i=0; i<wildcard.fNamespaceList.length; i++)
- if (fNamespaceList[0] == wildcard.fNamespaceList[i]) {
- unionWildcard.fType = WILDCARD_ANY;
- break;
- }
- // Loop traversed completely. This means, negated namespace viz. tNS (here)
- // is not in the other list. So, union is other.
- if (i == wildcard.fNamespaceList.length) {
- unionWildcard.fType = fType;
- //REVISIT: Is it okay to copy like this.
- unionWildcard.fNamespaceList = fNamespaceList;
- }
- }
- else {
- for (i=0; i<fNamespaceList.length; i++)
- if (wildcard.fNamespaceList[0] == fNamespaceList[i]) {
- unionWildcard.fType = WILDCARD_ANY;
- break;
- }
- // Loop traversed completely. This means, negated namespace viz. tNS (here)
- // is not in the other list. So, union is other.
- if (i == fNamespaceList.length) {
- unionWildcard.fType = wildcard.fType;
- //REVISIT: Is it okay to copy like this.
- unionWildcard.fNamespaceList = wildcard.fNamespaceList;
- }
- }
- }
-
- unionWildcard.fProcessContents = fProcessContents;
- return unionWildcard;
-
+ else if ( ((fType == WILDCARD_OTHER) && (wildcard.fType == WILDCARD_LIST)) ||
+ ((fType == WILDCARD_LIST) && (wildcard.fType == WILDCARD_OTHER)) ) {
+
+ int i=0;
+
+ if (fType == WILDCARD_OTHER) {
+ for (i=0; i<wildcard.fNamespaceList.length; i++)
+ if (fNamespaceList[0] == wildcard.fNamespaceList[i]) {
+ unionWildcard.fType = WILDCARD_ANY;
+ break;
+ }
+ // Loop traversed completely. This means, negated namespace viz. tNS (here)
+ // is not in the other list. So, union is other.
+ if (i == wildcard.fNamespaceList.length) {
+ unionWildcard.fType = fType;
+ //REVISIT: Is it okay to copy like this.
+ unionWildcard.fNamespaceList = fNamespaceList;
+ }
+ }
+ else {
+ for (i=0; i<fNamespaceList.length; i++)
+ if (wildcard.fNamespaceList[0] == fNamespaceList[i]) {
+ unionWildcard.fType = WILDCARD_ANY;
+ break;
+ }
+ // Loop traversed completely. This means, negated namespace viz. tNS (here)
+ // is not in the other list. So, union is other.
+ if (i == fNamespaceList.length) {
+ unionWildcard.fType = wildcard.fType;
+ //REVISIT: Is it okay to copy like this.
+ unionWildcard.fNamespaceList = wildcard.fNamespaceList;
+ }
+ }
+ }
+
+ unionWildcard.fProcessContents = fProcessContents;
+ return unionWildcard;
+
} // performUnionWith
public XSWildcardDecl performIntersectionWith(XSWildcardDecl wildcard) {
- // For a wildcard's {namespace constraint} value to be the intensional intersection of two other
- // such values (call them O1 and O2): the appropriate case among the following must be true:
-
- XSWildcardDecl intersectWildcard = new XSWildcardDecl();
+ // For a wildcard's {namespace constraint} value to be the intensional intersection of two other
+ // such values (call them O1 and O2): the appropriate case among the following must be true:
+ XSWildcardDecl intersectWildcard = new XSWildcardDecl();
+
// 1 If O1 and O2 are the same value, then that value must be the value.
- if (areSame(wildcard)) {
- intersectWildcard.fType = fType;
- if (fType != WILDCARD_ANY)
- //REVISIT: Is it okay to copy like this.
- intersectWildcard.fNamespaceList = fNamespaceList;
- }
- // 2 If either O1 or O2 is any, then the other must be the value.
- else if ( (fType == WILDCARD_ANY) || (wildcard.fType == WILDCARD_ANY) ) {
- if (fType == WILDCARD_ANY) {
- intersectWildcard.fType = wildcard.fType;
- // both cannot be ANY, if we have reached here.
- //REVISIT: Is it okay to copy like this.
- intersectWildcard.fNamespaceList = wildcard.fNamespaceList;
- }
- else {
- intersectWildcard.fType = fType;
- // both cannot be ANY, if we have reached here.
- //REVISIT: Is it okay to copy like this.
- intersectWildcard.fNamespaceList = fNamespaceList;
- }
- }
- // 3 If either O1 or O2 is a pair of not and a namespace name and the other is a set of
- // (namespace names or �absent�), then that set, minus the negated namespace name if it was in
- // the set, must be the value.
- else if ( ((fType == WILDCARD_OTHER) && (wildcard.fType == WILDCARD_LIST)) ||
- ((fType == WILDCARD_LIST) && (wildcard.fType == WILDCARD_OTHER)) ) {
- Vector intersect = null;
- if (fType == WILDCARD_OTHER) {
- intersect = new Vector(wildcard.fNamespaceList.length);
- for (int i=0; i<wildcard.fNamespaceList.length; i++)
- if (fNamespaceList[0] != wildcard.fNamespaceList[i])
- intersect.addElement(wildcard.fNamespaceList[i]);
- }
- else {
- intersect = new Vector(fNamespaceList.length);
- for (int i=0; i<fNamespaceList.length; i++)
- if (wildcard.fNamespaceList[0] != fNamespaceList[i])
- intersect.addElement(fNamespaceList[i]);
- }
- intersectWildcard.fType = WILDCARD_LIST;
- // copy elements from vector to array
- int size = intersect.size();
- intersectWildcard.fNamespaceList = new String[size];
- intersect.copyInto(intersectWildcard.fNamespaceList);
- }
- // 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) ) {
- boolean found;
- Vector intersect = null;
-
- if (fNamespaceList.length < wildcard.fNamespaceList.length)
- intersect = new Vector(fNamespaceList.length);
- else
- intersect = new Vector(wildcard.fNamespaceList.length);
-
- for (int i=0; i<fNamespaceList.length; i++) {
- found = false;
- for (int j=0; j<wildcard.fNamespaceList.length; j++)
- if (fNamespaceList[i] == wildcard.fNamespaceList[j]) {
- found = true;
- break;
- }
- if (found)
- intersect.addElement(fNamespaceList[i]);
- }
-
- intersectWildcard.fType = WILDCARD_LIST;
- // copy elements from vector to array
- int size = intersect.size();
- intersectWildcard.fNamespaceList = new String[size];
- intersect.copyInto(intersectWildcard.fNamespaceList);
- }
- //REVISIT: 5 If the two are negations of different namespace names, then the intersection is not expressible.
-
- intersectWildcard.fProcessContents = fProcessContents;
- return intersectWildcard;
-
+ if (areSame(wildcard)) {
+ intersectWildcard.fType = fType;
+ if (fType != WILDCARD_ANY)
+ //REVISIT: Is it okay to copy like this.
+ intersectWildcard.fNamespaceList = fNamespaceList;
+ }
+ // 2 If either O1 or O2 is any, then the other must be the value.
+ else if ( (fType == WILDCARD_ANY) || (wildcard.fType == WILDCARD_ANY) ) {
+ if (fType == WILDCARD_ANY) {
+ intersectWildcard.fType = wildcard.fType;
+ // both cannot be ANY, if we have reached here.
+ //REVISIT: Is it okay to copy like this.
+ intersectWildcard.fNamespaceList = wildcard.fNamespaceList;
+ }
+ else {
+ intersectWildcard.fType = fType;
+ // both cannot be ANY, if we have reached here.
+ //REVISIT: Is it okay to copy like this.
+ intersectWildcard.fNamespaceList = fNamespaceList;
+ }
+ }
+ // 3 If either O1 or O2 is a pair of not and a namespace name and the other is a set of
+ // (namespace names or �absent�), then that set, minus the negated namespace name if it was in
+ // the set, must be the value.
+ else if ( ((fType == WILDCARD_OTHER) && (wildcard.fType == WILDCARD_LIST)) ||
+ ((fType == WILDCARD_LIST) && (wildcard.fType == WILDCARD_OTHER)) ) {
+ Vector intersect = null;
+ if (fType == WILDCARD_OTHER) {
+ intersect = new Vector(wildcard.fNamespaceList.length);
+ for (int i=0; i<wildcard.fNamespaceList.length; i++)
+ if (fNamespaceList[0] != wildcard.fNamespaceList[i])
+ intersect.addElement(wildcard.fNamespaceList[i]);
+ }
+ else {
+ intersect = new Vector(fNamespaceList.length);
+ for (int i=0; i<fNamespaceList.length; i++)
+ if (wildcard.fNamespaceList[0] != fNamespaceList[i])
+ intersect.addElement(fNamespaceList[i]);
+ }
+ intersectWildcard.fType = WILDCARD_LIST;
+ // copy elements from vector to array
+ int size = intersect.size();
+ intersectWildcard.fNamespaceList = new String[size];
+ intersect.copyInto(intersectWildcard.fNamespaceList);
+ }
+ // 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) ) {
+ boolean found;
+ Vector intersect = null;
+
+ if (fNamespaceList.length < wildcard.fNamespaceList.length)
+ intersect = new Vector(fNamespaceList.length);
+ else
+ intersect = new Vector(wildcard.fNamespaceList.length);
+
+ for (int i=0; i<fNamespaceList.length; i++) {
+ found = false;
+ for (int j=0; j<wildcard.fNamespaceList.length; j++)
+ if (fNamespaceList[i] == wildcard.fNamespaceList[j]) {
+ found = true;
+ break;
+ }
+ if (found)
+ intersect.addElement(fNamespaceList[i]);
+ }
+
+ intersectWildcard.fType = WILDCARD_LIST;
+ // copy elements from vector to array
+ int size = intersect.size();
+ intersectWildcard.fNamespaceList = new String[size];
+ intersect.copyInto(intersectWildcard.fNamespaceList);
+ }
+ //REVISIT: 5 If the two are negations of different namespace names, then the intersection is not expressible.
+
+ intersectWildcard.fProcessContents = fProcessContents;
+ return intersectWildcard;
+
} // performIntersectionWith
private boolean areSame(XSWildcardDecl wildcard) {
- if (fType == wildcard.fType) {
- if (fType == WILDCARD_ANY)
- return true;
- else {
- if (fNamespaceList.length == wildcard.fNamespaceList.length) {
- int i=0;
- for (; i<fNamespaceList.length; i++) {
- if (fNamespaceList[i] != wildcard.fNamespaceList[i])
- break;
- }
- if (i == fNamespaceList.length)
- return true;
- }
- }
- }
-
- return false;
+ if (fType == wildcard.fType) {
+ if (fType == WILDCARD_ANY)
+ return true;
+ else {
+ if (fNamespaceList.length == wildcard.fNamespaceList.length) {
+ int i=0;
+ for (; i<fNamespaceList.length; i++) {
+ if (fNamespaceList[i] != wildcard.fNamespaceList[i])
+ break;
+ }
+ if (i == fNamespaceList.length)
+ return true;
+ }
+ }
+ }
+
+ return false;
} // areSame
+ // REVISIT: how to prepresent wildcard in string.
+ // "namespace:usr=someuri," is not so descriptive
public String toString() {
String ret = null;
switch (fType) {
1.5 +5 -3 xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/AnySimpleType.java
Index: AnySimpleType.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/datatypes/AnySimpleType.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AnySimpleType.java 2001/10/16 17:21:39 1.4
+++ AnySimpleType.java 2001/10/17 21:46:10 1.5
@@ -66,13 +66,13 @@
/**
* AnySimpleType is the base of all simple types.
* @author Sandy Gao
- * @version $Id: AnySimpleType.java,v 1.4 2001/10/16 17:21:39 elena Exp $
+ * @version $Id: AnySimpleType.java,v 1.5 2001/10/17 21:46:10 sandygao Exp $
*/
public class AnySimpleType extends AbstractDatatypeValidator {
public AnySimpleType() {
}
- public AnySimpleType(DatatypeValidator base, Hashtable facets, boolean derivedByList,
+ public AnySimpleType(DatatypeValidator base, Hashtable facets, boolean derivedByList,
XMLErrorReporter reporter) {
fBaseValidator = base;
@@ -88,7 +88,7 @@
}
fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
"DatatypeFacetError", new Object[]{msg},
- XMLErrorReporter.SEVERITY_ERROR);
+ XMLErrorReporter.SEVERITY_ERROR);
}
}
@@ -99,6 +99,8 @@
}
public int compare( String value1, String value2 ) {
+ if (value1.equals(value2))
+ return 0;
return -1;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org