Author: mukulg
Date: Wed Apr 13 11:56:56 2022
New Revision: 1899806
URL: http://svn.apache.org/viewvc?rev=1899806&view=rev
Log:
improvements to, fixes for jira issue XERCESJ-1743
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/XMLAssertXPath2EngineImpl.java
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=1899806&r1=1899805&r2=1899806&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
Wed Apr 13 11:56:56 2022
@@ -970,7 +970,7 @@ public class XSSimpleTypeDecl implements
for (int i = 0; i < size; i++) {
enumVal = (String)enumVals.elementAt(i);
- if (fAssertion != null && fAssertion.size() > 0) {
+ if (fAssertion != null) {
for (int idx = 0; idx < fAssertion.size();
idx++) {
XSAssertImpl assertImpl =
(XSAssertImpl)fAssertion.get(idx);
Boolean isAssertSucceeded =
fAssertionProcessor.evaluateOneAssertionFromSimpleType(elemQname, enumVal,
null,
@@ -989,6 +989,14 @@ public class XSSimpleTypeDecl implements
throw new InvalidDatatypeFacetException(null,
null);
}
}
+
+ if (isTypeDerivedFromUnion) {
+ boolean isValidationFailedForUnion =
fAssertionProcessor.isValidationFailedForSTUnion(((XSSimpleTypeDefinition)this.getBaseType()).
+
getMemberTypes(), elemQname, enumVal, null, true);
+ if (isValidationFailedForUnion) {
+ throw new
InvalidDatatypeFacetException(null, null);
+ }
+ }
}
}
catch (InvalidDatatypeFacetException ex) {
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertXPath2EngineImpl.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertXPath2EngineImpl.java?rev=1899806&r1=1899805&r2=1899806&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertXPath2EngineImpl.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertXPath2EngineImpl.java
Wed Apr 13 11:56:56 2022
@@ -554,7 +554,7 @@ public class XMLAssertXPath2EngineImpl e
XSObjectList memberTypes = simpleTypeDefn.getMemberTypes();
if (memberTypes != null && memberTypes.getLength() > 0 &&
!isTypeDerivedFromUnion) {
- if (isValidationFailedForSTUnion(memberTypes, element, value,
augs)) {
+ if (isValidationFailedForSTUnion(memberTypes, element, value,
augs, false)) {
isValueValid = false;
if (assertImpl.getAttrName() == null) {
// assertion evaluation was for an element
@@ -696,59 +696,63 @@ public class XMLAssertXPath2EngineImpl e
/*
* Determine if an validation episode must fail due to assertions
evaluation for "simpleType -> union" member types.
*/
- private boolean isValidationFailedForSTUnion(XSObjectList memberTypes,
QName element, String value, Augmentations augs) {
+ public boolean isValidationFailedForSTUnion(XSObjectList memberTypes,
QName element, String value, Augmentations augs,
+ boolean
isAssertEvaluationFromSchema) {
boolean isValidationFailedForUnion = true;
for (int memberTypeIdx = 0; memberTypeIdx < memberTypes.getLength();
memberTypeIdx++) {
- XSSimpleTypeDefinition memType = (XSSimpleTypeDefinition)
memberTypes.item(memberTypeIdx);
- 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...
- }
- }
- 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;
- }
+ XSSimpleTypeDefinition memType = (XSSimpleTypeDefinition)
memberTypes.item(memberTypeIdx);
+ if
(!SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(memType.getNamespace()) &&
!XS11TypeHelper.simpleTypeHasAsserts(memType) &&
XS11TypeHelper.isStrValueValidForASimpleType(value, (XSSimpleType)memType,
Constants.SCHEMA_VERSION_1_1)) {
+ isValidationFailedForUnion = false;
+ break;
+ }
+ else if
(SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(memType.getNamespace()) &&
XS11TypeHelper.isStrValueValidForASimpleType(value, (XSSimpleType)memType,
Constants.SCHEMA_VERSION_1_1)) {
+ isValidationFailedForUnion = false;
+ break;
+ }
+ else if
(!SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(memType.getNamespace())) {
+ 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) {
+ // NO OP
}
- }
- if (!isValidationFailedForUnion) {
- break;
- }
+ }
+ if (assertsSucceeded == assertFacets.size()) {
+ // all assertions on a 'union' member type have
evaluated to 'true', therefore validation with union has succeeded wrt
assertions.
+ if (!isAssertEvaluationFromSchema) {
+ // 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;
+ }
+ }
}
- }
+ if (!isValidationFailedForUnion) {
+ break;
+ }
+ }
}
return isValidationFailedForUnion;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]