Author: knoaman Date: Thu Sep 8 18:21:19 2011 New Revision: 1166836 URL: http://svn.apache.org/viewvc?rev=1166836&view=rev Log: Allow equality check between singleton list value and atomic value - Jira 1527 (https://issues.apache.org/jira/browse/XERCESJ-1527)
Added: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/EqualityHelper.java (with props) Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSConstraints.java xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/models/XS11CMRestriction.java xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java Added: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/EqualityHelper.java URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/EqualityHelper.java?rev=1166836&view=auto ============================================================================== --- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/EqualityHelper.java (added) +++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/EqualityHelper.java Thu Sep 8 18:21:19 2011 @@ -0,0 +1,217 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.xerces.impl.dv.xs; + +import org.apache.xerces.impl.Constants; +import org.apache.xerces.impl.dv.ValidatedInfo; +import org.apache.xerces.impl.dv.xs.ListDV.ListData; +import org.apache.xerces.xs.ShortList; +import org.apache.xerces.xs.XSConstants; + +/** + * @version $Id$ + */ +public class EqualityHelper { + + // private constructor + private EqualityHelper() {} + + // public methods + + /** + * Compare 2 actual values + */ + public static boolean isEqual(Object value1, Object value2, + short value1Type, short value2Type, + ShortList typeList1, ShortList typeList2, + short schemaVersion) { + if (schemaVersion == Constants.SCHEMA_VERSION_1_1) { + return isEqual11(value1, value2, value1Type, value2Type, typeList1, typeList2); + } + + return isEqual(value1, value2, value1Type, value2Type, typeList1, typeList2); + } + + public static boolean isEqual(ValidatedInfo value1, ValidatedInfo value2, short schemaVersion) { + if (schemaVersion == Constants.SCHEMA_VERSION_1_1) { + return isEqual11(value1.actualValue, value2.actualValue, + value1.actualValueType, value2.actualValueType, + value1.itemValueTypes, value2.itemValueTypes); + } + + return isEqual(value1.actualValue, value2.actualValue, + value1.actualValueType, value2.actualValueType, + value1.itemValueTypes, value2.itemValueTypes); + } + + // private XML Schema 1.0 methods + private static boolean isEqual(Object value1, Object value2, + short value1Type, short value2Type, + ShortList typeList1, ShortList typeList2) { + + if (!isTypeComparable(value1Type, value2Type, typeList1, typeList2)) { + return false; + } + + if (value1 == value2) { + return true; + } + + if (value1 == null || value2 == null) { + return false; + } + + return value1.equals(value2); + } + + private static boolean isTypeComparable(short type1, short type2, + ShortList typeList1, ShortList typeList2) { + + final short primitiveType1 = convertToPrimitiveKind(type1); + final short primitiveType2 = convertToPrimitiveKind(type2); + + // Same types + if (primitiveType1 == primitiveType2) { + if (primitiveType1 == XSConstants.LIST_DT) { + return isListTypeComparable(typeList1, typeList2); + } + + return true; + } + + // Different types + return (primitiveType1 == XSConstants.ANYSIMPLETYPE_DT && primitiveType2 == XSConstants.STRING_DT || + primitiveType1 == XSConstants.STRING_DT && primitiveType2 == XSConstants.ANYSIMPLETYPE_DT); + } + + // private XML Schema 1.1 methods + private static boolean isEqual11(Object value1, Object value2, + short value1Type, short value2Type, + ShortList typeList1, ShortList typeList2) { + + if (!isType11Comparable(value1Type, value2Type, typeList1, typeList2)) { + return false; + } + + if (value1 == value2) { + return true; + } + + if (value1 == null || value2 == null) { + return false; + } + + if (value1 instanceof ListData) { + if (!(value2 instanceof ListData)) { + final ListData listData = (ListData) value1; + if (listData.getLength() != 1) { + return false; + } + value1 = listData.get(0); + } + } + else if (value2 instanceof ListData) { + final ListData listData = (ListData) value2; + if (listData.getLength() != 1) { + return false; + } + value2 = listData.get(0); + } + + return value1.equals(value2); + } + + private static boolean isType11Comparable(short type1, short type2, + ShortList typeList1, ShortList typeList2) { + + final short primitiveType1 = convertToPrimitiveKind(type1); + final short primitiveType2 = convertToPrimitiveKind(type2); + + // Same types + if (primitiveType1 == primitiveType2) { + if (primitiveType1 == XSConstants.LIST_DT) { + return isListTypeComparable(typeList1, typeList2); + } + + return true; + } + + // Different types + // Check singleton list vs atomic + if (primitiveType1 == XSConstants.LIST_DT) { + if (typeList1 == null || typeList1.getLength() != 1) { + return false; + } + return isType11Comparable(typeList1.item(0), primitiveType2, null, null); + } + else if (primitiveType2 == XSConstants.LIST_DT) { + if (typeList2 == null || typeList2.getLength() != 1) { + return false; + } + return isType11Comparable(primitiveType1, typeList2.item(0), null, null); + } + + return (primitiveType1 == XSConstants.ANYSIMPLETYPE_DT && primitiveType2 == XSConstants.STRING_DT || + primitiveType1 == XSConstants.STRING_DT && primitiveType2 == XSConstants.ANYSIMPLETYPE_DT); + } + + // Private common methods + private static 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; + } + + /** List datatypes */ + if (valueType == XSConstants.LIST_DT || valueType == XSConstants.LISTOFUNION_DT) { + return XSConstants.LIST_DT; + } + /** Other types. */ + return valueType; + } + + private static boolean isListTypeComparable(ShortList typeList1, ShortList typeList2) { + final int typeList1Length = typeList1 != null ? typeList1.getLength() : 0; + final int typeList2Length = typeList2 != null ? typeList2.getLength() : 0; + if (typeList1Length != typeList2Length) { + return false; + } + for (int i = 0; i < typeList1Length; ++i) { + final short primitiveItem1 = convertToPrimitiveKind(typeList1.item(i)); + final short primitiveItem2 = convertToPrimitiveKind(typeList2.item(i)); + if (primitiveItem1 != primitiveItem2) { + if (primitiveItem1 == XSConstants.ANYSIMPLETYPE_DT && primitiveItem2 == XSConstants.STRING_DT || + primitiveItem1 == XSConstants.STRING_DT && primitiveItem2 == XSConstants.ANYSIMPLETYPE_DT) { + continue; + } + return false; + } + } + + return true; + } + +} Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/EqualityHelper.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/EqualityHelper.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java?rev=1166836&r1=1166835&r2=1166836&view=diff ============================================================================== --- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java (original) +++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java Thu Sep 8 18:21:19 2011 @@ -1814,7 +1814,7 @@ public class XSSimpleTypeDecl implements // then validate the actual value against the facets if (context.needFacetChecking() && (fFacetsDefined != 0 && fFacetsDefined != FACET_WHITESPACE)) { - checkFacets(validatedInfo); + checkFacets(validatedInfo, context); } // now check extra rules: for ID/IDREF/ENTITY @@ -1824,12 +1824,11 @@ public class XSSimpleTypeDecl implements } - private void checkFacets(ValidatedInfo validatedInfo) throws InvalidDatatypeValueException { + private void checkFacets(ValidatedInfo validatedInfo, ValidationContext context) throws InvalidDatatypeValueException { Object ob = validatedInfo.actualValue; String content = validatedInfo.normalizedValue; - short type = validatedInfo.actualValueType; - ShortList itemType = validatedInfo.itemValueTypes; + final short schemaVersion = (context.getTypeValidatorHelper().isXMLSchema11()) ? Constants.SCHEMA_VERSION_1_1 : Constants.SCHEMA_VERSION_1_0; // For QName and NOTATION types, we don't check length facets if (fValidationDV != DV_QNAME && fValidationDV != DV_NOTATION) { @@ -1864,42 +1863,13 @@ public class XSSimpleTypeDecl implements if ( ((fFacetsDefined & FACET_ENUMERATION) != 0 ) ) { boolean present = false; final int enumSize = fEnumerationSize; - final short primitiveType1 = convertToPrimitiveKind(type); for (int i = 0; i < enumSize; i++) { - final short primitiveType2 = convertToPrimitiveKind(fEnumeration[i].actualValueType); - if ((primitiveType1 == primitiveType2 || - primitiveType1 == XSConstants.ANYSIMPLETYPE_DT && primitiveType2 == XSConstants.STRING_DT || - primitiveType1 == XSConstants.STRING_DT && primitiveType2 == XSConstants.ANYSIMPLETYPE_DT) - && fEnumeration[i].actualValue.equals(ob)) { - if (primitiveType1 == XSConstants.LIST_DT || primitiveType1 == XSConstants.LISTOFUNION_DT) { - ShortList enumItemType = fEnumeration[i].itemValueTypes; - 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; - } + if (EqualityHelper.isEqual(validatedInfo, fEnumeration[i], schemaVersion)) { + present = true; + break; } } + if(!present){ StringBuffer sb = new StringBuffer(); appendEnumString(sb); @@ -2122,7 +2092,7 @@ public class XSSimpleTypeDecl implements avalue[i] = fItemType.getActualValue(parsedList.nextToken(), context, validatedInfo, false); if (context.needFacetChecking() && (fItemType.fFacetsDefined != 0 && fItemType.fFacetsDefined != FACET_WHITESPACE)) { - fItemType.checkFacets(validatedInfo); + fItemType.checkFacets(validatedInfo, context); } memberTypes[i] = (XSSimpleTypeDecl)validatedInfo.memberType; if (isUnion) @@ -2154,7 +2124,7 @@ public class XSSimpleTypeDecl implements Object aValue = fMemberTypes[i].getActualValue(_content, context, validatedInfo, true); if (context.needFacetChecking() && (fMemberTypes[i].fFacetsDefined != 0 && fMemberTypes[i].fFacetsDefined != FACET_WHITESPACE)) { - fMemberTypes[i].checkFacets(validatedInfo); + fMemberTypes[i].checkFacets(validatedInfo, context); } if (fMemberTypes[i].fVariety != VARIETY_UNION) { Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java?rev=1166836&r1=1166835&r2=1166836&view=diff ============================================================================== --- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java (original) +++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java Thu Sep 8 18:21:19 2011 @@ -36,6 +36,7 @@ import org.apache.xerces.impl.dv.Datatyp import org.apache.xerces.impl.dv.InvalidDatatypeValueException; import org.apache.xerces.impl.dv.ValidatedInfo; import org.apache.xerces.impl.dv.XSSimpleType; +import org.apache.xerces.impl.dv.xs.EqualityHelper; import org.apache.xerces.impl.dv.xs.TypeValidatorHelper; import org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl; import org.apache.xerces.impl.validation.ValidationManager; @@ -3511,7 +3512,7 @@ public class XMLSchemaValidator // get the value constraint from use or decl // 4 The item's actual value must match the value of the {value constraint}, if it is present and fixed. // now check the value against the simpleType if (actualValue != null && currDecl.getConstraintType() == XSConstants.VC_FIXED) { - if (!ValidatedInfo.isComparable(fValidatedInfo, currDecl.fDefault) || !actualValue.equals(currDecl.fDefault.actualValue)) { + if (!EqualityHelper.isEqual(fValidatedInfo, currDecl.fDefault, fSchemaVersion)) { reportSchemaError( "cvc-attribute.4", new Object[] { @@ -3526,7 +3527,7 @@ public class XMLSchemaValidator if (actualValue != null && currUse != null && currUse.fConstraintType == XSConstants.VC_FIXED) { - if (!ValidatedInfo.isComparable(fValidatedInfo, currUse.fDefault) || !actualValue.equals(currUse.fDefault.actualValue)) { + if (!EqualityHelper.isEqual(fValidatedInfo, currUse.fDefault, fSchemaVersion)) { reportSchemaError( "cvc-complex-type.3.1", new Object[] { @@ -3768,8 +3769,8 @@ public class XMLSchemaValidator } // 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 && (!ValidatedInfo.isComparable(fValidatedInfo, fCurrentElemDecl.fDefault) - || !actualValue.equals(fCurrentElemDecl.fDefault.actualValue))) { + if (actualValue != null && + !EqualityHelper.isEqual(fValidatedInfo, fCurrentElemDecl.fDefault, fSchemaVersion)) { reportSchemaError( "cvc-elt.5.2.2.2.2", new Object[] { @@ -3779,8 +3780,8 @@ public class XMLSchemaValidator } } } else if (fCurrentType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) { - if (actualValue != null && (!ValidatedInfo.isComparable(fValidatedInfo, fCurrentElemDecl.fDefault) - || !actualValue.equals(fCurrentElemDecl.fDefault.actualValue))) { + if (actualValue != null && + !EqualityHelper.isEqual(fValidatedInfo, fCurrentElemDecl.fDefault, fSchemaVersion)) { // REVISIT: the spec didn't mention this case: fixed // value with simple type reportSchemaError( @@ -4191,6 +4192,10 @@ public class XMLSchemaValidator public void append(ValueStoreBase newVal) { for (int i = 0; i < newVal.fValues.size(); i++) { fValues.addElement(newVal.fValues.elementAt(i)); + + // REVISIT: + addValueType(newVal.getValueTypeAt(i)); + addItemValueType(newVal.getItemValueTypeAt(i)); } } // append(ValueStoreBase) @@ -4336,19 +4341,16 @@ public class XMLSchemaValidator LOOP : for (int i = 0; i < size; i = next) { next = i + fFieldCount; for (int j = 0; j < fFieldCount; j++) { - Object value1 = fLocalValues[j]; - Object value2 = fValues.elementAt(i); - short valueType1 = fLocalValueTypes[j]; - short valueType2 = getValueTypeAt(i); - if (value1 == null || value2 == null || valueType1 != valueType2 || !(value1.equals(value2))) { + final Object value1 = fLocalValues[j]; + final Object value2 = fValues.elementAt(i); + final short valueType1 = fLocalValueTypes[j]; + final short valueType2 = getValueTypeAt(i); + final ShortList typeList1 = isListType(valueType1) ? fLocalItemValueTypes[j] : null; + final ShortList typeList2 = isListType(valueType2) ? getItemValueTypeAt(i) : null; + + if (!EqualityHelper.isEqual(value1, value2, valueType1, valueType2, typeList1, typeList2, fSchemaVersion)) { continue LOOP; } - else if(valueType1 == XSConstants.LIST_DT || valueType1 == XSConstants.LISTOFUNION_DT) { - ShortList list1 = fLocalItemValueTypes[j]; - ShortList list2 = getItemValueTypeAt(i); - if(list1 == null || list2 == null || !list1.equals(list2)) - continue LOOP; - } i++; } // found it @@ -4368,17 +4370,19 @@ public class XMLSchemaValidator final Vector values = vsb.fValues; final int size1 = values.size(); if (fFieldCount <= 1) { - for (int i = 0; i < size1; ++i) { - short val = vsb.getValueTypeAt(i); - if (!valueTypeContains(val) || !fValues.contains(values.elementAt(i))) { - return i; - } - else if(val == XSConstants.LIST_DT || val == XSConstants.LISTOFUNION_DT) { - ShortList list1 = vsb.getItemValueTypeAt(i); - if (!itemValueTypeContains(list1)) { - return i; + LOOP: for (int i = 0; i < size1; ++i) { + final Object value1 = values.elementAt(i); + final short valueType1 = vsb.getValueTypeAt(i); + final ShortList typeList1 = isListType(valueType1) ? vsb.getItemValueTypeAt(i) : null; + for (int j=0; j < fValues.size(); ++j) { + final Object value2 = fValues.elementAt(j); + final short valueType2 = getValueTypeAt(j); + final ShortList typeList2 = isListType(valueType2) ? getItemValueTypeAt(j) : null; + if (EqualityHelper.isEqual(value1, value2, valueType1, valueType2, typeList1, typeList2, fSchemaVersion)) { + continue LOOP; } } + return i; } } /** Handle n-tuples. **/ @@ -4393,16 +4397,12 @@ public class XMLSchemaValidator final Object value2 = fValues.elementAt(j+k); final short valueType1 = vsb.getValueTypeAt(i+k); final short valueType2 = getValueTypeAt(j+k); - if (value1 != value2 && (valueType1 != valueType2 || value1 == null || !value1.equals(value2))) { + final ShortList typeList1 = isListType(valueType1) ? vsb.getItemValueTypeAt(i+k) : null; + final ShortList typeList2 = isListType(valueType2) ? getItemValueTypeAt(j+k) : null; + + if (!EqualityHelper.isEqual(value1, value2, valueType1, valueType2, typeList1, typeList2, fSchemaVersion)) { continue INNER; } - else if(valueType1 == XSConstants.LIST_DT || valueType1 == XSConstants.LISTOFUNION_DT) { - ShortList list1 = vsb.getItemValueTypeAt(i+k); - ShortList list2 = getItemValueTypeAt(j+k); - if (list1 == null || list2 == null || !list1.equals(list2)) { - continue INNER; - } - } } continue OUTER; } @@ -4489,6 +4489,9 @@ public class XMLSchemaValidator // // Private methods // + private boolean isListType(short type) { + return type == XSConstants.LIST_DT || type == XSConstants.LISTOFUNION_DT; + } private void addValueType(short type) { if (fUseValueTypeVector) { @@ -4516,13 +4519,6 @@ public class XMLSchemaValidator return fValueType; } - private boolean valueTypeContains(short value) { - if (fUseValueTypeVector) { - return fValueTypes.contains(value); - } - return fValueType == value; - } - private void addItemValueType(ShortList itemValueType) { if (fUseItemValueTypeVector) { fItemValueTypes.add(itemValueType); @@ -4550,14 +4546,6 @@ public class XMLSchemaValidator return fItemValueType; } - private boolean itemValueTypeContains(ShortList value) { - if (fUseItemValueTypeVector) { - return fItemValueTypes.contains(value); - } - return fItemValueType == value || - (fItemValueType != null && fItemValueType.equals(value)); - } - } // class ValueStoreBase /** Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java?rev=1166836&r1=1166835&r2=1166836&view=diff ============================================================================== --- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java (original) +++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java Thu Sep 8 18:21:19 2011 @@ -18,6 +18,7 @@ package org.apache.xerces.impl.xs; import org.apache.xerces.impl.dv.ValidatedInfo; +import org.apache.xerces.impl.dv.xs.EqualityHelper; import org.apache.xerces.impl.xs.util.XSObjectListImpl; import org.apache.xerces.xs.XSAnnotation; import org.apache.xerces.xs.XSAttributeGroupDefinition; @@ -254,11 +255,12 @@ public class XSAttributeGroupDecl implem return errorArgs; } else { // check the values are the same. - ValidatedInfo baseFixedValue=(baseAttrUse.fDefault!=null ? + final ValidatedInfo baseFixedValue=(baseAttrUse.fDefault!=null ? baseAttrUse.fDefault: baseAttrDecl.fDefault); - ValidatedInfo thisFixedValue=(attrUse.fDefault!=null ? + final ValidatedInfo thisFixedValue=(attrUse.fDefault!=null ? attrUse.fDefault: attrDecl.fDefault); - if (!baseFixedValue.actualValue.equals(thisFixedValue.actualValue)) { + + if (!EqualityHelper.isEqual(baseFixedValue, thisFixedValue, xsConstraints.getSchemaVersion())) { errorArgs = new Object[]{typeName, attrDecl.fName, thisFixedValue.stringValue(), baseFixedValue.stringValue(), "derivation-ok-restriction.2.1.3.b"}; return errorArgs; Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSConstraints.java URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSConstraints.java?rev=1166836&r1=1166835&r2=1166836&view=diff ============================================================================== --- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSConstraints.java (original) +++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSConstraints.java Thu Sep 8 18:21:19 2011 @@ -86,6 +86,10 @@ public abstract class XSConstraints { fAnyType = anyType; fSchemaVersion = schemaVersion; } + + final public short getSchemaVersion() { + return fSchemaVersion; + } /** * check whether derived is valid derived from base, given a subset Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/models/XS11CMRestriction.java URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/models/XS11CMRestriction.java?rev=1166836&r1=1166835&r2=1166836&view=diff ============================================================================== --- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/models/XS11CMRestriction.java (original) +++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/models/XS11CMRestriction.java Thu Sep 8 18:21:19 2011 @@ -22,6 +22,7 @@ import java.util.Arrays; import java.util.List; import org.apache.xerces.impl.Constants; +import org.apache.xerces.impl.dv.xs.EqualityHelper; import org.apache.xerces.impl.xs.SchemaGrammar; import org.apache.xerces.impl.xs.SubstitutionGroupHandler; import org.apache.xerces.impl.xs.XSConstraints; @@ -32,11 +33,8 @@ import org.apache.xerces.impl.xs.XSOpenC import org.apache.xerces.impl.xs.XSWildcardDecl; import org.apache.xerces.impl.xs.identity.IdentityConstraint; import org.apache.xerces.xni.QName; -import org.apache.xerces.xs.XSComplexTypeDefinition; import org.apache.xerces.xs.XSConstants; import org.apache.xerces.xs.XSNamedMap; -import org.apache.xerces.xs.XSSimpleTypeDefinition; -import org.apache.xerces.xs.XSTypeDefinition; // TODO: tests: @@ -474,36 +472,9 @@ public final class XS11CMRestriction imp return false; } - // Get primitive kind for the fixed values. Use "string" for - // complex type with mixed content. - short btype, dtype; - if (eb.fType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) { - btype = ((XSSimpleTypeDefinition)eb.fType).getPrimitiveType().getBuiltInKind(); - } - else { - XSComplexTypeDefinition complex = (XSComplexTypeDefinition)eb.fType; - if (complex.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_SIMPLE) { - btype = complex.getSimpleType().getPrimitiveType().getBuiltInKind(); - } - else { - btype = XSConstants.STRING_DT; - } - } - if (ed.fType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) { - dtype = ((XSSimpleTypeDefinition)ed.fType).getPrimitiveType().getBuiltInKind(); - } - else { - XSComplexTypeDefinition complex = (XSComplexTypeDefinition)ed.fType; - if (complex.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_SIMPLE) { - dtype = complex.getSimpleType().getPrimitiveType().getBuiltInKind(); - } - else { - dtype = XSConstants.STRING_DT; - } - } // The 2 values must have the same primitive kind and actual value. // equals() checks both equality and identity. - if (btype != dtype || !eb.fDefault.actualValue.equals(ed.fDefault.actualValue)) { + if (!EqualityHelper.isEqual(eb.fDefault, ed.fDefault, Constants.SCHEMA_VERSION_1_1)) { return false; } } Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java?rev=1166836&r1=1166835&r2=1166836&view=diff ============================================================================== --- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java (original) +++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java Thu Sep 8 18:21:19 2011 @@ -21,6 +21,7 @@ import org.apache.xerces.impl.Constants; import org.apache.xerces.impl.dv.InvalidDatatypeValueException; import org.apache.xerces.impl.dv.ValidatedInfo; import org.apache.xerces.impl.dv.XSSimpleType; +import org.apache.xerces.impl.dv.xs.EqualityHelper; import org.apache.xerces.impl.xs.SchemaGrammar; import org.apache.xerces.impl.xs.SchemaSymbols; import org.apache.xerces.impl.xs.XSAnnotationImpl; @@ -208,7 +209,7 @@ class XSDAttributeTraverser extends XSDA if (attrUse.fAttrDecl.getConstraintType() == XSConstants.VC_FIXED && attrUse.fConstraintType != XSConstants.VC_NONE) { if (attrUse.fConstraintType != XSConstants.VC_FIXED || - !attrUse.fAttrDecl.getValInfo().actualValue.equals(attrUse.fDefault.actualValue)) { + !EqualityHelper.isEqual(attrUse.fAttrDecl.getValInfo(), attrUse.fDefault, fSchemaHandler.fSchemaVersion)) { reportSchemaError ("au-props-correct.2", new Object[]{nameAtt, attrUse.fAttrDecl.getValInfo().stringValue()}, attrDecl); // Recover by using the decl's {value constraint} attrUse.fDefault = attrUse.fAttrDecl.getValInfo(); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@xerces.apache.org For additional commands, e-mail: commits-h...@xerces.apache.org