You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mu...@apache.org on 2013/01/06 07:19:26 UTC
svn commit: r1429469 -
/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathXPath2Impl.java
Author: mukulg
Date: Sun Jan 6 06:19:26 2013
New Revision: 1429469
URL: http://svn.apache.org/viewvc?rev=1429469&view=rev
Log:
schema 1.1 commit: committing a minor improvement to assertions implementation. this handles better the case, when assertions are within a simpleType->union scenario (particularly, when a memberType of union in non XSD namespace having non-assertion facets can validate successfully an XML instance value).
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathXPath2Impl.java
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathXPath2Impl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathXPath2Impl.java?rev=1429469&r1=1429468&r2=1429469&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathXPath2Impl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathXPath2Impl.java Sun Jan 6 06:19:26 2013
@@ -618,65 +618,58 @@ public class XMLAssertPsychopathXPath2Im
private boolean isValidationFailedForSTUnion(XSObjectList memberTypes, QName element, String value, Augmentations augs) {
boolean isValidationFailedForUnion = true;
- final int memberTypesLength = memberTypes.getLength();
- int memberTypesHavingAsserts = 0;
-
- for (int memberTypeIdx = 0; memberTypeIdx < memberTypesLength; memberTypeIdx++) {
+
+ for (int memberTypeIdx = 0; memberTypeIdx < memberTypes.getLength(); memberTypeIdx++) {
XSSimpleTypeDefinition memType = (XSSimpleTypeDefinition) memberTypes.item(memberTypeIdx);
- // check for assertions on types in an non-schema namespace
- if (!SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(memType.getNamespace()) && XS11TypeHelper.simpleTypeHasAsserts(memType)) {
- memberTypesHavingAsserts++;
- XSObjectList memberTypeFacets = memType.getMultiValueFacets();
- final int memberTypeFacetsLength = memberTypeFacets.getLength();
- for (int memberTypeFacetIdx = 0; memberTypeFacetIdx < memberTypeFacetsLength; memberTypeFacetIdx++) {
- XSMultiValueFacet facet = (XSMultiValueFacet) memberTypeFacets.item(memberTypeFacetIdx);
- if (facet.getFacetKind() == XSSimpleTypeDefinition.FACET_ASSERT) {
- Vector assertFacets = facet.getAsserts();
- int assertsSucceeded = 0;
- for (Iterator iter = assertFacets.iterator(); iter.hasNext(); ) {
- XSAssertImpl assertImpl = (XSAssertImpl) iter.next();
- try {
- setXDMTypedValueOf$value(fCurrentAssertDomNode, value, memType, null, false, fXpath2DynamicContext);
- AssertionError assertError = evaluateOneAssertion(element, assertImpl, value, false, false);
- if (assertError == null) {
- assertsSucceeded++;
- }
- }
- catch(Exception ex) {
- // An exception may occur if for example a typed value cannot be constructed by PsychoPath
- // XPath engine for a given "string value" (say a value '5' was attempted to be converted to a typed
- // value xs:date).
- // it's useful to report warning ... REVISIT
- }
- }
- if (assertsSucceeded == assertFacets.size()) {
- // all assertions on a 'union' member type have evaluated to 'true', therefore validation with
- // union has succeeded wrt assertions.
- // update memberType PSVI property
- ItemPSVI elemPSVI = (ItemPSVI)augs.getItem(Constants.ELEMENT_PSVI);
- ItemPSVI attrPSVI = (ItemPSVI)augs.getItem(Constants.ATTRIBUTE_PSVI);
- if (elemPSVI != null) {
- ((ElementPSVImpl) elemPSVI).fValue.memberType = (XSSimpleType) memType;
+ if (!SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(memType.getNamespace())) {
+ // only look for member types in non XSD namespace
+ if (!XS11TypeHelper.simpleTypeHasAsserts(memType) && XS11TypeHelper.isStrValueValidForASimpleType(value, (XSSimpleType)memType, Constants.SCHEMA_VERSION_1_1)) {
+ isValidationFailedForUnion = false;
+ break;
+ }
+ else {
+ XSObjectList memberTypeFacets = memType.getMultiValueFacets();
+ for (int memberTypeFacetIdx = 0; memberTypeFacetIdx < memberTypeFacets.getLength(); memberTypeFacetIdx++) {
+ XSMultiValueFacet facet = (XSMultiValueFacet) memberTypeFacets.item(memberTypeFacetIdx);
+ if (facet.getFacetKind() == XSSimpleTypeDefinition.FACET_ASSERT) {
+ Vector assertFacets = facet.getAsserts();
+ int assertsSucceeded = 0;
+ for (Iterator iter = assertFacets.iterator(); iter.hasNext(); ) {
+ XSAssertImpl assertImpl = (XSAssertImpl) iter.next();
+ try {
+ setXDMTypedValueOf$value(fCurrentAssertDomNode, value, memType, null, false, fXpath2DynamicContext);
+ AssertionError assertError = evaluateOneAssertion(element, assertImpl, value, false, false);
+ if (assertError == null) {
+ assertsSucceeded++;
+ }
+ }
+ catch(Exception ex) {
+ // do nothing for now. REVISIT...
+ }
}
- else {
- ((AttributePSVImpl) attrPSVI).fValue.memberType = (XSSimpleType) memType;
+ if (assertsSucceeded == assertFacets.size()) {
+ // all assertions on a 'union' member type have evaluated to 'true', therefore validation with union has succeeded wrt assertions.
+ // update memberType PSVI property
+ ItemPSVI elemPSVI = (ItemPSVI)augs.getItem(Constants.ELEMENT_PSVI);
+ ItemPSVI attrPSVI = (ItemPSVI)augs.getItem(Constants.ATTRIBUTE_PSVI);
+ if (elemPSVI != null) {
+ ((ElementPSVImpl) elemPSVI).fValue.memberType = (XSSimpleType) memType;
+ }
+ else {
+ ((AttributePSVImpl) attrPSVI).fValue.memberType = (XSSimpleType) memType;
+ }
+ isValidationFailedForUnion = false;
+ break;
}
- isValidationFailedForUnion = false;
- break;
}
}
- }
- if (!isValidationFailedForUnion) {
- break;
+ if (!isValidationFailedForUnion) {
+ break;
+ }
}
}
}
-
- if (memberTypesHavingAsserts == 0) {
- // none of the member types have asserts. therefore, validation cannot fail due to checks from this method.
- isValidationFailedForUnion = false;
- }
-
+
return isValidationFailedForUnion;
} // isValidationFailedForSTUnion
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org