You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by sa...@apache.org on 2002/11/19 00:11:56 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/xs/traversers XSDAttributeTraverser.java
sandygao 2002/11/18 15:11:55
Modified: java/src/org/apache/xerces/impl/xs XMLSchemaValidator.java
XSAttributeDecl.java XSAttributeGroupDecl.java
XSAttributeUseImpl.java XSConstraints.java
XSElementDecl.java
java/src/org/apache/xerces/impl/xs/identity IDValue.java
java/src/org/apache/xerces/impl/xs/traversers
XSDAttributeTraverser.java
Log:
Make use of the changes made to the data types:
1. Use canonical representations for validation and PSVI, when required;
2. Use new equality checking machenism.
Revision Changes Path
1.122 +15 -14 xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
Index: XMLSchemaValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -r1.121 -r1.122
--- XMLSchemaValidator.java 8 Nov 2002 19:38:16 -0000 1.121
+++ XMLSchemaValidator.java 18 Nov 2002 23:11:54 -0000 1.122
@@ -2671,7 +2671,7 @@
// 4 The item's actual value must match the value of the {value constraint}, if it is present and fixed. // now check the value against the simpleType
if (actualValue != null &&
currDecl.getConstraintType() == XSConstants.VC_FIXED) {
- if (!attDV.isEqual(actualValue, currDecl.fDefault.actualValue)){
+ if (!actualValue.equals(currDecl.fDefault.actualValue)){
reportSchemaError("cvc-attribute.4", new Object[]{element.rawname, fTempQName.rawname, attrValue});
}
}
@@ -2679,7 +2679,7 @@
// 3.1 If there is among the {attribute uses} an attribute use with an {attribute declaration} whose {name} matches the attribute information item's [local name] and whose {target namespace} is identical to the attribute information item's [namespace name] (where an absent {target namespace} is taken to be identical to a [namespace name] with no value), then the attribute information must be valid with respect to that attribute use as per Attribute Locally Valid (Use) (3.5.4). In this case the {attribute declaration} of that attribute use is the context-determined declaration for the attribute information item with respect to Schema-Validity Assessment (Attribute) (3.2.4) and Assessment Outcome (Attribute) (3.2.5).
if (actualValue != null &&
currUse != null && currUse.fConstraintType == XSConstants.VC_FIXED) {
- if (!attDV.isEqual(actualValue, currUse.fDefault.actualValue)){
+ if (!actualValue.equals(currUse.fDefault.actualValue)){
reportSchemaError("cvc-complex-type.3.1", new Object[]{element.rawname, fTempQName.rawname, attrValue});
}
}
@@ -2688,7 +2688,7 @@
// PSVI: attribute declaration
attrPSVI.fDeclaration = currDecl;
if (currDecl != null && currDecl.fDefault != null)
- attrPSVI.fSchemaDefault = currDecl.fDefault.normalizedValue;
+ attrPSVI.fSchemaDefault = currDecl.fDefault.toString();
// PSVI: attribute type
attrPSVI.fTypeDecl = attDV;
@@ -2757,7 +2757,7 @@
// if the attribute is not specified, then apply the value constraint
if (!isSpecified && constType != XSConstants.VC_NONE) {
attName = new QName(null, currDecl.fName, currDecl.fName, currDecl.fTargetNamespace);
- String normalized = (defaultValue!=null)?defaultValue.normalizedValue:"";
+ String normalized = (defaultValue!=null)?defaultValue.toString():"";
int attrIndex = attributes.addAttribute(attName, "CDATA", normalized);
if (attributes instanceof XMLAttributesImpl) {
XMLAttributesImpl attrs = (XMLAttributesImpl)attributes;
@@ -2800,11 +2800,12 @@
if (fCurrentElemDecl != null && fCurrentElemDecl.fDefault != null &&
!fSawText && !fSubElement && !fNil) {
- int bufLen = fCurrentElemDecl.fDefault.normalizedValue.length();
+ String strv = fCurrentElemDecl.fDefault.stringValue();
+ int bufLen = strv.length();
if (fNormalizedStr.ch == null || fNormalizedStr.ch.length < bufLen) {
fNormalizedStr.ch = new char[bufLen];
}
- fCurrentElemDecl.fDefault.normalizedValue.getChars(0, bufLen, fNormalizedStr.ch, 0);
+ strv.getChars(0, bufLen, fNormalizedStr.ch, 0);
fNormalizedStr.offset = 0;
fNormalizedStr.length = bufLen;
fDefaultValue = fNormalizedStr;
@@ -2831,13 +2832,13 @@
// 5.1.1 If the actual type definition is a local type definition then the canonical lexical representation of the {value constraint} value must be a valid default for the actual type definition as defined in Element Default Valid (Immediate) (3.3.6).
if (fCurrentType != fCurrentElemDecl.fType) {
//REVISIT:we should pass ValidatedInfo here.
- if (XSConstraints.ElementDefaultValidImmediate(fCurrentType, fCurrentElemDecl.fDefault.normalizedValue, fState4XsiType, null) == null)
- reportSchemaError("cvc-elt.5.1.1", new Object[]{element.rawname, fCurrentType.getName(), fCurrentElemDecl.fDefault.normalizedValue});
+ if (XSConstraints.ElementDefaultValidImmediate(fCurrentType, fCurrentElemDecl.fDefault.stringValue(), fState4XsiType, null) == null)
+ reportSchemaError("cvc-elt.5.1.1", new Object[]{element.rawname, fCurrentType.getName(), fCurrentElemDecl.fDefault.stringValue()});
}
// 5.1.2 The element information item with the canonical lexical representation of the {value constraint} value used as its normalized value must be valid with respect to the actual type definition as defined by Element Locally Valid (Type) (3.3.4).
// REVISIT: don't use toString, but validateActualValue instead
// use the fState4ApplyDefault
- elementLocallyValidType(element, fCurrentElemDecl.fDefault.normalizedValue);
+ elementLocallyValidType(element, fCurrentElemDecl.fDefault.stringValue());
}
else {
// The following method call also deal with clause 1.2.2 of the constraint
@@ -2866,17 +2867,17 @@
// 5.2.2.2.2 If the {content type} of the actual type definition is a simple type definition, then the actual value of the item must match the canonical lexical representation of the {value constraint} value.
else if (ctype.fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
if (actualValue != null &&
- !ctype.fXSSimpleType.isEqual(actualValue, fCurrentElemDecl.fDefault.actualValue))
- reportSchemaError("cvc-elt.5.2.2.2.2", new Object[]{element.rawname, content, fCurrentElemDecl.fDefault.normalizedValue});
+ !actualValue.equals(fCurrentElemDecl.fDefault.actualValue))
+ reportSchemaError("cvc-elt.5.2.2.2.2", new Object[]{element.rawname, content, fCurrentElemDecl.fDefault.stringValue()});
}
}
else if (fCurrentType.getTypeCategory() == XSTypeDecl.SIMPLE_TYPE) {
XSSimpleType sType = (XSSimpleType)fCurrentType;
if (actualValue != null &&
- !sType.isEqual(actualValue, fCurrentElemDecl.fDefault.actualValue))
+ !actualValue.equals(fCurrentElemDecl.fDefault.actualValue))
// REVISIT: the spec didn't mention this case: fixed
// value with simple type
- reportSchemaError("cvc-elt.5.2.2.2.2", new Object[]{element.rawname, content, fCurrentElemDecl.fDefault.normalizedValue});
+ reportSchemaError("cvc-elt.5.2.2.2.2", new Object[]{element.rawname, content, fCurrentElemDecl.fDefault.stringValue()});
}
}
}
1.10 +2 -2 xml-xerces/java/src/org/apache/xerces/impl/xs/XSAttributeDecl.java
Index: XSAttributeDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSAttributeDecl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- XSAttributeDecl.java 15 Jul 2002 20:24:27 -0000 1.9
+++ XSAttributeDecl.java 18 Nov 2002 23:11:54 -0000 1.10
@@ -178,7 +178,7 @@
// REVISIT: SCAPI: what's the proper representation
return getConstraintType() == XSConstants.VC_NONE ?
null :
- fDefault.normalizedValue;
+ fDefault.actualValue.toString();
}
/**
1.10 +2 -2 xml-xerces/java/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java
Index: XSAttributeGroupDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- XSAttributeGroupDecl.java 16 May 2002 18:25:54 -0000 1.9
+++ XSAttributeGroupDecl.java 18 Nov 2002 23:11:54 -0000 1.10
@@ -220,7 +220,7 @@
baseAttrUse.fDefault: baseAttrDecl.fDefault);
ValidatedInfo thisFixedValue=(attrUse.fDefault!=null ?
attrUse.fDefault: attrDecl.fDefault);
- if (!baseAttrDecl.fType.isEqual(baseFixedValue.actualValue,thisFixedValue.actualValue)) {
+ if (!baseFixedValue.actualValue.equals(thisFixedValue.actualValue)) {
errorCode="derivation-ok-restriction.2.1.3";
return errorCode;
}
1.2 +2 -2 xml-xerces/java/src/org/apache/xerces/impl/xs/XSAttributeUseImpl.java
Index: XSAttributeUseImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSAttributeUseImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XSAttributeUseImpl.java 16 May 2002 18:25:54 -0000 1.1
+++ XSAttributeUseImpl.java 18 Nov 2002 23:11:54 -0000 1.2
@@ -141,7 +141,7 @@
// REVISIT: SCAPI: what's the proper representation
return getConstraintType() == XSConstants.VC_NONE ?
null :
- fDefault.normalizedValue;
+ fDefault.actualValue.toString();
}
} // class XSAttributeUseImpl
1.27 +8 -8 xml-xerces/java/src/org/apache/xerces/impl/xs/XSConstraints.java
Index: XSConstraints.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSConstraints.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- XSConstraints.java 26 Aug 2002 13:57:48 -0000 1.26
+++ XSConstraints.java 18 Nov 2002 23:11:54 -0000 1.27
@@ -1053,15 +1053,15 @@
}
// get simple type
- XSSimpleType dv = null;
- if (dElement.fType.getTypeCategory() == XSTypeDecl.SIMPLE_TYPE)
- dv = (XSSimpleType)dElement.fType;
- else if (((XSComplexTypeDecl)dElement.fType).fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE)
- dv = ((XSComplexTypeDecl)dElement.fType).fXSSimpleType;
+ boolean isSimple = false;
+ if (dElement.fType.getTypeCategory() == XSTypeDecl.SIMPLE_TYPE ||
+ ((XSComplexTypeDecl)dElement.fType).fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
+ isSimple = true;
+ }
// if there is no simple type, then compare based on string
- if (dv == null && !bElement.fDefault.normalizedValue.equals(dElement.fDefault.normalizedValue) ||
- dv != null && !dv.isEqual(bElement.fDefault.actualValue, dElement.fDefault.actualValue)) {
+ if (!isSimple && !bElement.fDefault.normalizedValue.equals(dElement.fDefault.normalizedValue) ||
+ isSimple && !bElement.fDefault.actualValue.equals(dElement.fDefault.actualValue)) {
throw new XMLSchemaException("rcase-NameAndTypeOK.4",
new Object[]{dElement.fName});
}
1.10 +2 -2 xml-xerces/java/src/org/apache/xerces/impl/xs/XSElementDecl.java
Index: XSElementDecl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSElementDecl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- XSElementDecl.java 16 May 2002 18:25:54 -0000 1.9
+++ XSElementDecl.java 18 Nov 2002 23:11:54 -0000 1.10
@@ -271,7 +271,7 @@
// REVISIT: SCAPI: what's the proper representation
return getConstraintType() == XSConstants.VC_NONE ?
null :
- fDefault.normalizedValue;
+ fDefault.stringValue();
}
/**
1.6 +2 -2 xml-xerces/java/src/org/apache/xerces/impl/xs/identity/IDValue.java
Index: IDValue.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/identity/IDValue.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- IDValue.java 9 Aug 2002 15:18:18 -0000 1.5
+++ IDValue.java 18 Nov 2002 23:11:55 -0000 1.6
@@ -137,7 +137,7 @@
try {
Object av1 = dv.validate(v1, VS, null);
Object av2 = dv.validate(v2, VS, null);
- return dv.isEqual(av1, av2);
+ return av1.equals(av2);
} catch (Exception e) {
return false;
}
1.19 +2 -3 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java
Index: XSDAttributeTraverser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- XSDAttributeTraverser.java 13 Aug 2002 22:57:10 -0000 1.18
+++ XSDAttributeTraverser.java 18 Nov 2002 23:11:55 -0000 1.19
@@ -203,8 +203,7 @@
if (attrUse.fAttrDecl.getConstraintType() == XSConstants.VC_FIXED &&
attrUse.fConstraintType != XSConstants.VC_NONE) {
if (attrUse.fConstraintType != XSConstants.VC_FIXED ||
- !((XSSimpleType)attrUse.fAttrDecl.getTypeDefinition()).isEqual(attrUse.fAttrDecl.getValInfo().actualValue,
- attrUse.fDefault.actualValue)) {
+ !attrUse.fAttrDecl.getValInfo().actualValue.equals(attrUse.fDefault.actualValue)) {
reportSchemaError ("au-props-correct.2", new Object[]{nameAtt}, attrDecl);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org