mrglavas 2005/06/23 20:47:28
Modified: java/src/org/apache/xerces/impl/dv/xs XSSimpleTypeDecl.java
Log:
Bug fix: When checking enumerations, two values are comparable if they're in
the same value space.
Revision Changes Path
1.73 +58 -19
xml-xerces/java/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java
Index: XSSimpleTypeDecl.java
===================================================================
RCS file:
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- XSSimpleTypeDecl.java 13 Jun 2005 20:44:08 -0000 1.72
+++ XSSimpleTypeDecl.java 24 Jun 2005 03:47:28 -0000 1.73
@@ -1616,28 +1616,50 @@
}
//enumeration
- if ( ((fFacetsDefined & FACET_ENUMERATION) != 0 ) ) {
- boolean present = false;
- for (int i = 0; i < fEnumeration.size(); i++) {
- if (fEnumerationType[i] == type &&
fEnumeration.elementAt(i).equals(ob)) {
- if(type == XSConstants.LIST_DT || type ==
XSConstants.LISTOFUNION_DT) {
+ if ( ((fFacetsDefined & FACET_ENUMERATION) != 0 ) ) {
+ boolean present = false;
+ final int enumSize = fEnumeration.size();
+ for (int i = 0; i < enumSize; i++) {
+ final short primitiveType1 =
convertToPrimitiveKind(fEnumerationType[i]);
+ final short primitiveType2 = convertToPrimitiveKind(type);
+ if ((primitiveType1 == primitiveType2 ||
+ primitiveType1 == XSConstants.ANYSIMPLETYPE_DT &&
primitiveType2 == XSConstants.STRING_DT ||
+ primitiveType1 == XSConstants.STRING_DT &&
primitiveType2 == XSConstants.ANYSIMPLETYPE_DT)
+ && fEnumeration.elementAt(i).equals(ob)) {
+ if (primitiveType1 == XSConstants.LIST_DT ||
primitiveType1 == XSConstants.LISTOFUNION_DT) {
ShortList enumItemType = fEnumerationItemType[i];
- if(enumItemType.equals(itemType)) {
- present = true;
- break;
+ final int typeList1Length = itemType != null ?
itemType.getLength() : 0;
+ final int typeList2Length = enumItemType != null ?
enumItemType.getLength() : 0;
+ if (typeList1Length == typeList2Length) {
+ int j;
+ for (j = 0; j < typeList1Length; ++j) {
+ final short primitiveItem1 =
convertToPrimitiveKind(itemType.item(j));
+ final short primitiveItem2 =
convertToPrimitiveKind(enumItemType.item(j));
+ if (primitiveItem1 != primitiveItem2) {
+ if (primitiveItem1 ==
XSConstants.ANYSIMPLETYPE_DT && primitiveItem2 == XSConstants.STRING_DT ||
+ primitiveItem1 ==
XSConstants.STRING_DT && primitiveItem2 == XSConstants.ANYSIMPLETYPE_DT) {
+ continue;
+ }
+ break;
+ }
+ }
+ if (j == typeList1Length) {
+ present = true;
+ break;
+ }
}
- }
+ }
else {
- present = true;
- break;
+ present = true;
+ break;
}
- }
- }
- if(!present){
- throw new
InvalidDatatypeValueException("cvc-enumeration-valid",
- new Object [] {content,
fEnumeration.toString()});
- }
- }
+ }
+ }
+ if(!present){
+ throw new
InvalidDatatypeValueException("cvc-enumeration-valid",
+ new Object [] {content, fEnumeration.toString()});
+ }
+ }
//fractionDigits
if ((fFacetsDefined & FACET_FRACTIONDIGITS) != 0) {
@@ -3212,6 +3234,23 @@
public boolean isDerivedFrom(String typeNamespaceArg, String
typeNameArg, int derivationMethod) {
return isDOMDerivedFrom(typeNamespaceArg, typeNameArg,
derivationMethod);
}
+
+ private short convertToPrimitiveKind(short valueType) {
+ /** Primitive datatypes. */
+ if (valueType <= XSConstants.NOTATION_DT) {
+ return valueType;
+ }
+ /** Types derived from string. */
+ if (valueType <= XSConstants.ENTITY_DT) {
+ return XSConstants.STRING_DT;
+ }
+ /** Types derived from decimal. */
+ if (valueType <= XSConstants.POSITIVEINTEGER_DT) {
+ return XSConstants.DECIMAL_DT;
+ }
+ /** Other types. */
+ return valueType;
+ }
} // class XSSimpleTypeDecl
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]