Author: mukulg Date: Thu Aug 11 13:21:33 2011 New Revision: 1156609 URL: http://svn.apache.org/viewvc?rev=1156609&view=rev Log: committing a schema 1.1 change. the changes committed by Khaled during the SVN commit 1156230 required these changes (otherwise some of the xsd 1.1 assertion use cases would fail). thanks to Khaled actually for improving the design with this respect.
Modified: 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/assertion/XSAssertionXPath2ValueImpl.java xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/util/XSTypeHelper.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=1156609&r1=1156608&r2=1156609&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 Aug 11 13:21:33 2011 @@ -5049,11 +5049,11 @@ public class XMLSchemaValidator } /* - * Preprocessing checks for assertion evaluations for simpleType's with variety union. + * Extra checks for assertion evaluations for simpleType definitions with variety union. */ private void extraCheckForSTUnionAsserts(XSSimpleType simpleTypeDv, String content, ValidatedInfo validatedInfo, Augmentations augs) { if (simpleTypeDv.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION && ((XSSimpleType) simpleTypeDv.getBaseType()).getVariety() != XSSimpleTypeDefinition.VARIETY_UNION) { - if (XSTypeHelper.isAtomicValueValidForSTUnion(simpleTypeDv.getMemberTypes(), content, validatedInfo)) { + if (XSTypeHelper.isAtomicStrValueValidForSTUnion(simpleTypeDv.getMemberTypes(), content, validatedInfo, Constants.SCHEMA_VERSION_1_1)) { fIsAssertProcessingNeededForSTUnion = false; } if (augs != null) { Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2ValueImpl.java URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2ValueImpl.java?rev=1156609&r1=1156608&r2=1156609&view=diff ============================================================================== --- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2ValueImpl.java (original) +++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/assertion/XSAssertionXPath2ValueImpl.java Thu Aug 11 13:21:33 2011 @@ -185,14 +185,14 @@ public class XSAssertionXPath2ValueImpl /* - * Given a string value, this method sets an XPath 2.0 typed value for variable "$value" in XPath dynamic context, when the value is for simpleType variety union. + * Given a string value, this method sets an XPath 2.0 typed value for variable "$value" in XPath dynamic context, when the value is for simpleType with variety union. */ public void setXDMTypedValueOf$valueForSTVarietyUnion(String value, XSObjectList memberTypes, DynamicContext xpath2DynamicContext) { // check member types of union in order to find that which member type can successfully validate the string value - // first, and set value of XPath2 context variable $value using the member type found as its type annotation. + // first, and set the type annotation of XPath2 context variable $value with this member type definition. for (int memTypeIdx = 0; memTypeIdx < memberTypes.getLength(); memTypeIdx++) { XSSimpleType simpleTypeDv = (XSSimpleType) memberTypes.item(memTypeIdx); - if (XSTypeHelper.isValueValidForASimpleType(value, simpleTypeDv)) { + if (XSTypeHelper.isStrValueValidForASimpleType(value, simpleTypeDv, Constants.SCHEMA_VERSION_1_1)) { setXDMTypedValueOf$valueForSTVarietyAtomic(value, getXercesXSDTypeCodeFor$value(simpleTypeDv), xpath2DynamicContext); break; } @@ -291,7 +291,7 @@ public class XSAssertionXPath2ValueImpl final int memberTypesLength = memberTypes.getLength(); for (int memTypeIdx = 0; memTypeIdx < memberTypesLength; memTypeIdx++) { XSSimpleType memSimpleType = (XSSimpleType) memberTypes.item(memTypeIdx); - if (XSTypeHelper.isValueValidForASimpleType(xdmItemStrValue, memSimpleType)) { + if (XSTypeHelper.isStrValueValidForASimpleType(xdmItemStrValue, memSimpleType, Constants.SCHEMA_VERSION_1_1)) { // no more memberTypes need to be checked xdmItemType = memSimpleType; break; Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/util/XSTypeHelper.java URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/util/XSTypeHelper.java?rev=1156609&r1=1156608&r2=1156609&view=diff ============================================================================== --- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/util/XSTypeHelper.java (original) +++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/util/XSTypeHelper.java Thu Aug 11 13:21:33 2011 @@ -25,8 +25,8 @@ import org.apache.xerces.impl.Constants; import org.apache.xerces.impl.XMLErrorReporter; import org.apache.xerces.impl.dv.InvalidDatatypeValueException; import org.apache.xerces.impl.dv.ValidatedInfo; -import org.apache.xerces.impl.dv.ValidationContext; import org.apache.xerces.impl.dv.XSSimpleType; +import org.apache.xerces.impl.dv.xs.TypeValidatorHelper; import org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl; import org.apache.xerces.impl.validation.ValidationState; import org.apache.xerces.impl.xs.SchemaSymbols; @@ -93,18 +93,18 @@ public class XSTypeHelper { /* - * Determine if an atomic value is valid with respect to any of the simpleType -> union's member types (those that are in XML Schema namespace). - * If this method returns 'true', then the value is valid with respect to entire union schema component. + * Determine if a string value (which will result in an XDM atomic value) is valid with respect to any of the simpleType -> union's member types + * (those that are in XML Schema namespace). If this method returns a boolean 'true', then the value is valid with respect to entire union schema component. */ - public static boolean isAtomicValueValidForSTUnion(XSObjectList memberTypes, String content, ValidatedInfo validatedInfo) { + public static boolean isAtomicStrValueValidForSTUnion(XSObjectList memberTypes, String content, ValidatedInfo validatedInfo, short schemaVersion) { boolean isValueValid = false; - // check the union member types in order to check for validity of an 'atomic value'. the validity of 'atomic value' wrt + // check the union member types in order to check for validity of an atomic value. the validity of atomic value wrt // to the 1st available type in union's member type collection, is sufficient to achieve the objective of this method. for (int memTypeIdx = 0; memTypeIdx < memberTypes.getLength(); memTypeIdx++) { XSSimpleType simpleTypeDv = (XSSimpleType) memberTypes.item(memTypeIdx); - if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(simpleTypeDv.getNamespace()) && XSTypeHelper.isValueValidForASimpleType(content, simpleTypeDv)) { + if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(simpleTypeDv.getNamespace()) && XSTypeHelper.isStrValueValidForASimpleType(content, simpleTypeDv, schemaVersion)) { isValueValid = true; validatedInfo.memberType = simpleTypeDv; break; @@ -113,32 +113,33 @@ public class XSTypeHelper { return isValueValid; - } // isAtomicValueValidForSTUnion + } // isAtomicStrValueValidForSTUnion /* * Determine if a lexical "string value" belongs to the value space (i.e is valid according to the type) of a given schema * simpleType definition. Using Xerces API 'XSSimpleType.validate' for this need. */ - public static boolean isValueValidForASimpleType(String value, XSSimpleType simplType) { + public static boolean isStrValueValidForASimpleType(String value, XSSimpleType simplType, short schemaVersion) { - boolean isValueValid = true; + boolean isStrValueValid = true; try { // construct necessary context objects ValidatedInfo validatedInfo = new ValidatedInfo(); - ValidationContext validationState = new ValidationState(); + ValidationState validationState = new ValidationState(); + validationState.setTypeValidatorHelper(TypeValidatorHelper.getInstance(schemaVersion)); - // attempt to validate the "string value" with a simpleType instance. + // attempt to validate the "string value" with a simpleType definition simplType.validate(value, validationState, validatedInfo); } catch(InvalidDatatypeValueException ex){ - isValueValid = false; + isStrValueValid = false; } - return isValueValid; + return isStrValueValid; - } // isValueValidForASimpleType + } // isStrValueValidForASimpleType /* --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@xerces.apache.org For additional commands, e-mail: commits-h...@xerces.apache.org