Author: mukulg
Date: Wed Mar 16 04:08:16 2011
New Revision: 1082043
URL: http://svn.apache.org/viewvc?rev=1082043&view=rev
Log:
committing few improvements to PSVI results for simpleType's with variety
union, when assertions are involved. i'll be working to improve PSVI generation
logic further, when assertions in simpleType -> union are involved. also
removing few ambiguous javadoc comments and doing miscellaneous refactoring
(method renaming etc).
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathXPath2Impl.java
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/util/XSTypeHelper.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=1082043&r1=1082042&r2=1082043&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
Wed Mar 16 04:08:16 2011
@@ -481,18 +481,12 @@ public class XMLAssertPsychopathXPath2Im
private void evaluateAssertionOnSTUnion(QName element, XSObjectList
memberTypes, boolean isTypeDerivedFromUnion, XSAssertImpl assertImpl, String
value) {
if (memberTypes != null && memberTypes.getLength() > 0 &&
!isTypeDerivedFromUnion) {
- boolean isValidationFailedForUnion =
isValidationFailedForUnion(memberTypes, element, value, false);
- // only 1 error message is reported for assertion failures on
"simpleType -> union", since it is hard
- // (perhaps impossible?) to determine statically that what all
assertions can cause validation failure,
- // when participating in an XML schema union.
+ boolean isValidationFailedForUnion =
isValidationFailedForSTUnion(memberTypes, element, value, false);
if (isValidationFailedForUnion) {
fValidator.reportSchemaError("cvc-assertion.union.3.13.4.1",
new Object[] {element.rawname, value});
}
}
else if (isTypeDerivedFromUnion) {
- // although Xerces XSModel treats this case as a simpleType with
variety union, but from assertions perspective
- // this is treated like a "simpleType -> restriction" case (which
also appears to be syntactically true in every case?).
- // REVISIT...
setValueOf$valueForSTVarietyUnion(value, memberTypes);
AssertionError assertError = evaluateOneAssertion(element,
assertImpl, value, false, false);
if (assertError != null) {
@@ -506,7 +500,7 @@ public class XMLAssertPsychopathXPath2Im
/*
* Determine if an validation episode must fail due to assertions
evaluation for "simpleType -> union" member types.
*/
- private boolean isValidationFailedForUnion(XSObjectList memberTypes, QName
element, String value, boolean isAttribute) {
+ private boolean isValidationFailedForSTUnion(XSObjectList memberTypes,
QName element, String value, boolean isAttribute) {
boolean isValidationFailedForUnion = true;
final int memberTypesLength = memberTypes.getLength();
@@ -551,7 +545,7 @@ public class XMLAssertPsychopathXPath2Im
return isValidationFailedForUnion;
- } // isValidationFailedForUnion
+ } // isValidationFailedForSTUnion
/*
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=1082043&r1=1082042&r2=1082043&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 Mar 16 04:08:16 2011
@@ -3255,12 +3255,9 @@ public class XMLSchemaValidator
try {
actualValue = attDV.validate(attrValue, fValidationState,
fValidatedInfo);
- // additional check for assertions processing, for simple type
having variety 'union'
- if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1 &&
attDV.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION &&
- ((XSSimpleType)
attDV.getBaseType()).getVariety() != XSSimpleTypeDefinition.VARIETY_UNION) {
- if
(XSTypeHelper.isAtomicValueValidForAnUnion(attDV.getMemberTypes(), attrValue,
null)) {
- fIsAssertProcessingNeededForSTUnion = false;
- }
+ // additional check for assertions processing, for simple type
having variety 'union'
+ if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
+ extraCheckForSTUnionAsserts(attDV, attrValue, fValidatedInfo);
}
// store the normalized value
@@ -3409,12 +3406,9 @@ public class XMLSchemaValidator
fValidationState.setFacetChecking(false);
attDV.validate(fValidationState, defaultValue);
- // additional check for assertions processing, for simple
type having variety 'union'
- if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1 &&
attDV.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION &&
- ((XSSimpleType)
attDV.getBaseType()).getVariety() != XSSimpleTypeDefinition.VARIETY_UNION) {
- if
(XSTypeHelper.isAtomicValueValidForAnUnion(attDV.getMemberTypes(), null,
defaultValue)) {
- fIsAssertProcessingNeededForSTUnion = false;
- }
+ // additional check for assertions processing, for simple
type having variety 'union'
+ if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
+ extraCheckForSTUnionAsserts(attDV,
defaultValue.stringValue(), defaultValue);
}
}
catch (InvalidDatatypeValueException idve) {
@@ -3621,12 +3615,9 @@ public class XMLSchemaValidator
}
retValue = dv.validate(textContent, fValidationState,
fValidatedInfo);
- // additional check for assertions processing, for simple
type having variety 'union'
- if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1 &&
dv.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION &&
- ((XSSimpleType)
dv.getBaseType()).getVariety() != XSSimpleTypeDefinition.VARIETY_UNION) {
- if
(XSTypeHelper.isAtomicValueValidForAnUnion(dv.getMemberTypes(),
String.valueOf(textContent), null)) {
- fIsAssertProcessingNeededForSTUnion = false;
- }
+ // additional check for assertions processing, for simple
type having variety 'union'
+ if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
+ extraCheckForSTUnionAsserts(dv,
String.valueOf(textContent), fValidatedInfo);
}
} catch (InvalidDatatypeValueException e) {
fIsAssertProcessingNeededForSTUnion = false;
@@ -3669,12 +3660,9 @@ public class XMLSchemaValidator
}
actualValue = dv.validate(textContent, fValidationState,
fValidatedInfo);
- // additional check for assertions processing, for simple
type having variety 'union'
- if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1 &&
dv.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION &&
- ((XSSimpleType)
dv.getBaseType()).getVariety() != XSSimpleTypeDefinition.VARIETY_UNION) {
- if
(XSTypeHelper.isAtomicValueValidForAnUnion(dv.getMemberTypes(),
String.valueOf(textContent), null)) {
- fIsAssertProcessingNeededForSTUnion = false;
- }
+ // additional check for assertions processing, for simple
type having variety 'union'
+ if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
+ extraCheckForSTUnionAsserts(dv,
String.valueOf(textContent), fValidatedInfo);
}
} catch (InvalidDatatypeValueException e) {
fIsAssertProcessingNeededForSTUnion = false;
@@ -4833,6 +4821,17 @@ public class XMLSchemaValidator
fData = newdata;
}
}
- }
+ }
+
+ /*
+ * Preprocessing checks for assertion evaluations for simpleType's with
variety union.
+ */
+ private void extraCheckForSTUnionAsserts(XSSimpleType simpleTypeDv, String
content, ValidatedInfo validatedInfo) {
+ if (simpleTypeDv.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION
&& ((XSSimpleType) simpleTypeDv.getBaseType()).getVariety() !=
XSSimpleTypeDefinition.VARIETY_UNION) {
+ if
(XSTypeHelper.isAtomicValueValidForSTUnion(simpleTypeDv.getMemberTypes(),
content, validatedInfo)) {
+ fIsAssertProcessingNeededForSTUnion = false;
+ }
+ }
+ } // extraCheckForSTUnionAsserts
} // class XMLSchemaValidator
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=1082043&r1=1082042&r2=1082043&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
Wed Mar 16 04:08:16 2011
@@ -87,10 +87,10 @@ public class XSTypeHelper {
/*
- * Determine if an atomic value is valid with respect to any of the
union's member types (those that are in XML Schema namespace).
+ * 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.
*/
- public static boolean isAtomicValueValidForAnUnion(XSObjectList
memberTypes, String content, ValidatedInfo validatedInfo) {
+ public static boolean isAtomicValueValidForSTUnion(XSObjectList
memberTypes, String content, ValidatedInfo validatedInfo) {
boolean isValueValid = false;
@@ -98,16 +98,16 @@ public class XSTypeHelper {
// 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.isValueValidForASimpleType(content, simpleTypeDv)) {
isValueValid = true;
+ validatedInfo.memberType = simpleTypeDv;
break;
}
}
return isValueValid;
- } // isAtomicValueValidForAnUnion
+ } // isAtomicValueValidForSTUnion
/*
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]