Author: mukulg Date: Wed Nov 23 10:43:29 2011 New Revision: 1205359 URL: http://svn.apache.org/viewvc?rev=1205359&view=rev Log: in some cases, XSD 1.1 assertion evaluations produce a lengthy and undesirable stack trace on standard output. i'm providing a quick fix for this problem (by suppressing the java exception).
here's a test case for this, XML document: <X>g</X> schema document fragment: <xs:element name="X"> <xs:simpleType> <xs:restriction base="xs:integer"> <xs:assertion test="$value mod 2 = 0"/> </xs:restriction> </xs:simpleType> </xs:element> before this fix, Xerces produced following output when above validation was invoked, [Error] test.xml:1:9: cvc-datatype-valid.1.2.1: 'g' is not a valid value for 'integer'. [Error] test.xml:1:9: cvc-type.3.1.3: The value 'g' of element 'X' is not valid. error: Parse error occurred - For input string: "g" java.lang.NumberFormatException: For input string: "g" at java.lang.NumberFormatException.forInputString(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at java.math.BigInteger.<init>(Unknown Source) ... This commit improves the error message that's produced in such cases. Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java 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=1205359&r1=1205358&r2=1205359&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 Wed Nov 23 10:43:29 2011 @@ -2739,7 +2739,12 @@ public class XMLSchemaValidator // delegate to assertions validator subcomponent if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) { - assertionValidatorEndElementDelegate(element); + try { + assertionValidatorEndElementDelegate(element); + } + catch(Exception ex) { + // NO OP + } } // Check if we should modify the xsi:type ignore depth --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@xerces.apache.org For additional commands, e-mail: commits-h...@xerces.apache.org