sandygao 2003/01/16 10:37:37 Modified: java/src/org/apache/xerces/impl/xs XSConstraints.java java/src/org/apache/xerces/impl/xs/traversers XSDAttributeTraverser.java XSDElementTraverser.java Log: According to a recent clarification of the schma spec, both the original lexical rep and the canonical rep of fixed/default values need to be valid wrt the type definition. Revision Changes Path 1.30 +6 -9 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.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- XSConstraints.java 14 Jan 2003 20:21:45 -0000 1.29 +++ XSConstraints.java 16 Jan 2003 18:37:36 -0000 1.30 @@ -257,7 +257,7 @@ * returns the compiled form of the value * The parameter value could be either a String or a ValidatedInfo object */ - public static Object ElementDefaultValidImmediate(XSTypeDefinition type, Object value, ValidationContext context, ValidatedInfo vinfo) { + public static Object ElementDefaultValidImmediate(XSTypeDefinition type, String value, ValidationContext context, ValidatedInfo vinfo) { XSSimpleType dv = null; @@ -296,13 +296,10 @@ dv = STRING_TYPE; } try { - if (value instanceof String) { - actualValue = dv.validate((String)value, context, vinfo); - } else { - ValidatedInfo info = (ValidatedInfo)value; - dv.validate(context, info); - actualValue = info.actualValue; - } + // validate the original lexical rep, and set the actual value + actualValue = dv.validate(value, context, vinfo); + // validate the canonical lexical rep + actualValue = dv.validate(vinfo.stringValue(), context, vinfo); } catch (InvalidDatatypeValueException ide) { return null; } 1.21 +8 -4 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.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- XSDAttributeTraverser.java 14 Jan 2003 20:21:47 -0000 1.20 +++ XSDAttributeTraverser.java 16 Jan 2003 18:37:36 -0000 1.21 @@ -384,7 +384,7 @@ if (attDefault != null) { fValidationState.setNamespaceSupport(schemaDoc.fNamespaceSupport); if (!checkDefaultValid(attribute)) { - reportSchemaError ("a-props-correct.2", new Object[]{nameAtt, defaultAtt}, attrDecl); + reportSchemaError ("a-props-correct.2", new Object[]{nameAtt, attDefault.normalizedValue}, attrDecl); } } @@ -418,8 +418,10 @@ boolean ret = true; try { - //set the actual value + // validate the original lexical rep, and set the actual value ((XSSimpleType)attribute.getTypeDefinition()).validate(attribute.getValInfo().normalizedValue, fValidationState, attribute.getValInfo()); + // validate the canonical lexical rep + ((XSSimpleType)attribute.getTypeDefinition()).validate(attribute.getValInfo().stringValue(), fValidationState, attribute.getValInfo()); } catch (InvalidDatatypeValueException ide) { ret = false; } @@ -433,8 +435,10 @@ boolean ret = true; try { - //set the actual value + // validate the original lexical rep, and set the actual value ((XSSimpleType)attrUse.fAttrDecl.getTypeDefinition()).validate(attrUse.fDefault.normalizedValue, fValidationState, attrUse.fDefault); + // validate the canonical lexical rep + ((XSSimpleType)attrUse.fAttrDecl.getTypeDefinition()).validate(attrUse.fDefault.stringValue(), fValidationState, attrUse.fDefault); } catch (InvalidDatatypeValueException ide) { ret = false; } 1.20 +2 -3 xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java Index: XSDElementTraverser.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- XSDElementTraverser.java 14 Jan 2003 20:21:48 -0000 1.19 +++ XSDElementTraverser.java 16 Jan 2003 18:37:36 -0000 1.20 @@ -440,8 +440,7 @@ // 2 If there is a {value constraint}, the canonical lexical representation of its value must be valid with respect to the {type definition} as defined in Element Default Valid (Immediate) (3.3.6). if (element.fDefault != null) { fValidationState.setNamespaceSupport(schemaDoc.fNamespaceSupport); - XSConstraints.ElementDefaultValidImmediate(element.fType, element.fDefault.normalizedValue, fValidationState, element.fDefault); - if (element.fDefault.actualValue == null) { + if (XSConstraints.ElementDefaultValidImmediate(element.fType, element.fDefault.normalizedValue, fValidationState, element.fDefault) == null) { reportSchemaError ("e-props-correct.2", new Object[]{nameAtt, element.fDefault.normalizedValue}, elmDecl); element.setConstraintType(XSConstants.VC_NONE); }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]