Author: mukulg
Date: Mon Apr 18 13:23:10 2022
New Revision: 1899980
URL: http://svn.apache.org/viewvc?rev=1899980&view=rev
Log:
improvements to, fixes for jira issue XERCESJ-1744
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertXPath2EngineImpl.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDAssertionValidator.java
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties?rev=1899980&r1=1899979&r2=1899980&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
Mon Apr 18 13:23:10 2022
@@ -78,6 +78,7 @@
cvc-datatype-valid.1.2.3 = cvc-datatype-valid.1.2.3: ''{0}'' is not a
valid value of union type ''{1}''.
cvc-datatype-valid.1.2.4 = cvc-datatype-valid.1.2.4: The NOTATION
type, ''{0}'' used to validate ''{1}'', must have an enumeration facet value
which specifies the notation elements used by this type.
cvc-datatype-valid.4.1.4 = cvc-datatype-valid.4.1.4: The value ''{0}''
of element ''{1}'' is not valid with the required simple type. Value ''{2}'' is
not valid with any member of union type ''{3}''.
+ cvc-datatype-valid_attr.4.1.4 = cvc-datatype-valid.4.1.4: The value
''{0}'' of attribute ''{2}'' on element ''{1}'' is not valid with the required
simple type. Value ''{3}'' is not valid with any member of union type ''{4}''.
cvc-elt.1.a = cvc-elt.1.a: Cannot find the declaration of element
''{0}''.
cvc-elt.1.b = cvc-elt.1.b: The name of the element does not match the
name of the element declaration. Saw ''{0}''. Expected ''{1}''.
cvc-elt.2 = cvc-elt.2: The value of '{'abstract'}' in the element
declaration for ''{0}'' must be false.
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=1899980&r1=1899979&r2=1899980&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
Mon Apr 18 13:23:10 2022
@@ -179,18 +179,99 @@ public class XMLAssertXPath2EngineImpl e
fCurrentAssertDomNode.setAttributeNode(attrNode);
}
- // if we have assertions applicable to this element, store the element
reference and the assertions on it on the runtime stacks
- List assertionList = (List) augs.getItem(XSAssertConstants.assertList);
- if (assertionList != null) {
- fAssertRootStack.push(fCurrentAssertDomNode);
- fAssertListStack.push(assertionList);
- initXPathProcessor();
+ if (augs != null) {
+ // if we have assertions applicable to this element, store the
element reference and the assertions
+ // on it on the runtime stacks
+ List assertionList = (List)
augs.getItem(XSAssertConstants.assertList);
+ if (assertionList != null) {
+ fAssertRootStack.push(fCurrentAssertDomNode);
+ fAssertListStack.push(assertionList);
+ initXPathProcessor();
+ }
+
+ // evaluate assertions from attributes. evaluation of assertions
on attributes in startElement call,
+ // helps us setting the PSVI results for attributes appropriately.
+ if
(((Boolean)augs.getItem(XSAssertConstants.isAttrHaveAsserts)).booleanValue()) {
+ evaluateAssertsFromAttributes(element, attributes);
+ }
}
-
- // evaluate assertions from attributes. evaluation of assertions on
attributes in startElement call, helps us setting the PSVI results
- // for attributes appropriately.
- if
(((Boolean)augs.getItem(XSAssertConstants.isAttrHaveAsserts)).booleanValue()) {
- evaluateAssertsFromAttributes(element, attributes);
+ else {
+ // handling, assertions on attribute simpleType definition, with
variety list whose itemType is union
+ for (int attrIdx = 0; attrIdx < attributes.getLength(); attrIdx++)
{
+ QName attrQname = new QName();
+ attributes.getName(attrIdx, attrQname);
+ String attrValue = attributes.getValue(attrIdx);
+ Augmentations attrAugs = attributes.getAugmentations(attrIdx);
+ AttributePSVImpl attrPsvi =
(AttributePSVImpl)attrAugs.getItem(Constants.ATTRIBUTE_PSVI);
+ if (attrPsvi != null) {
+ XSSimpleTypeDefinition attrSimpleType =
(XSSimpleTypeDefinition) attrPsvi.getTypeDefinition();
+ if (attrSimpleType != null) {
+ if (attrSimpleType.getVariety() ==
XSSimpleTypeDefinition.VARIETY_LIST) {
+ XSSimpleTypeDefinition xsItemTypeDefn =
attrSimpleType.getItemType();
+ if (xsItemTypeDefn.getVariety() ==
XSSimpleTypeDefinition.VARIETY_UNION) {
+ XSObjectList memberTypes =
xsItemTypeDefn.getMemberTypes();
+ int unionTypeNoOfMembers =
memberTypes.getLength();
+ int noOfUnionAtomicTypes = 0;
+ List memberTypeList = new Vector();
+ for (int idx = 0; idx < memberTypes.getLength();
idx++) {
+ XSSimpleTypeDefinition memberType =
(XSSimpleTypeDefinition)memberTypes.get(idx);
+ if (memberType.getVariety() ==
XSSimpleTypeDefinition.VARIETY_ATOMIC) {
+ noOfUnionAtomicTypes++;
+ XSSimpleTypeDecl xsSimpleTypeDecl =
(XSSimpleTypeDecl)memberType;
+ memberTypeList.add(xsSimpleTypeDecl);
+ }
+ }
+ if (unionTypeNoOfMembers == noOfUnionAtomicTypes)
{
+ // tokenize the list value by a sequence of
white spaces
+ StringTokenizer listStrTokens = new
StringTokenizer(attrValue, " \n\t\r");
+ while (listStrTokens.hasMoreTokens()) {
+ String listItemStrValue =
listStrTokens.nextToken();
+ // iterate over all the member types of
union
+ boolean isValidationForListItemSuccessful
= false;
+ for (int idx = 0; idx <
memberTypeList.size(); idx++) {
+ XSSimpleTypeDecl xsSimpleTypeDecl =
(XSSimpleTypeDecl)memberTypeList.get(idx);
+ if
(XS11TypeHelper.isStrValueValidForASimpleType(listItemStrValue,
xsSimpleTypeDecl, Constants.SCHEMA_VERSION_1_1)) {
+ Vector assertVector =
xsSimpleTypeDecl.getAssertions();
+ if (assertVector != null) {
+ int noOfAsserts =
assertVector.size();
+ int noOfAssertSuccesses = 0;
+ for (int idx1 = 0; idx1 <
assertVector.size(); idx1++) {
+
fAssertParams.put(Constants.XPATH2_NAMESPACE_CONTEXT,
((XSAssertImpl)assertVector.get(idx1)).getXPath2NamespaceContext());
+ initXPathProcessor();
+
setXDMTypedValueOf$valueForSTVarietyAtomic(listItemStrValue,
getXercesXSDTypeCodeFor$value((XSTypeDefinition)xsSimpleTypeDecl),
+
fXpath2DynamicContext);
+ AssertionError assertError
= evaluateOneAssertion(element, (XSAssertImpl)assertVector.get(idx1),
listItemStrValue, false, true);
+ if (assertError == null) {
+ noOfAssertSuccesses++;
+ }
+ }
+ if (noOfAsserts ==
noOfAssertSuccesses) {
+
isValidationForListItemSuccessful = true;
+ break;
+ }
+ }
+ else {
+
isValidationForListItemSuccessful = true;
+ }
+ }
+
+ if (isValidationForListItemSuccessful)
{
+ break;
+ }
+ }
+
+ if (!isValidationForListItemSuccessful) {
+
fXmlSchemaValidator.reportSchemaError("cvc-datatype-valid_attr.4.1.4", new
Object[] {attrValue, element.rawname, attrQname.rawname,
+
listItemStrValue,
XS11TypeHelper.getSchemaTypeName(
+
(XSTypeDefinition)
attrSimpleType.getItemType())});
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
} // startElement
@@ -216,7 +297,8 @@ public class XMLAssertXPath2EngineImpl e
for (int assertIdx = 0; assertIdx < attrAssertList.size();
assertIdx++) {
XSAssertImpl assertImpl =
(XSAssertImpl)attrAssertList.get(assertIdx);
assertImpl.setAttrName(attrQname.localpart);
- evaluateOneAssertionFromSimpleType(element, attrValue,
attrAugs, attrSimpleType, isTypeDerivedFromList, isTypeDerivedFromUnion,
assertImpl, true, attrQname, false);
+ evaluateOneAssertionFromSimpleType(element, attrValue,
attrAugs, attrSimpleType, isTypeDerivedFromList,
+
isTypeDerivedFromUnion, assertImpl, true, attrQname, false);
// evaluate assertions on itemType of xs:list
XSSimpleTypeDefinition attrItemType =
attrSimpleType.getItemType();
if (isTypeDerivedFromList && attrItemType != null) {
@@ -229,7 +311,7 @@ public class XMLAssertXPath2EngineImpl e
} // evaluateAssertsFromAttributes
-
+
/*
* (non-Javadoc)
* @see
org.apache.xerces.xni.parser.XMLAssertAdapter#endElement(org.apache.xerces.xni.QName,
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDAssertionValidator.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDAssertionValidator.java?rev=1899980&r1=1899979&r2=1899980&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDAssertionValidator.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDAssertionValidator.java
Mon Apr 18 13:23:10 2022
@@ -146,6 +146,13 @@ public class XSDAssertionValidator {
fAttributesHaveAsserts = false;
fAssertionProcessor.startElement(element, attributes, assertAugs);
}
+ else {
+ constructAssertProcessor(null);
+ if (fAssertionProcessor != null) {
+ fAssertionProcessor.startElement(element, attributes, null);
+ fAssertionProcessor = null;
+ }
+ }
} // handleStartElement
@@ -153,20 +160,22 @@ public class XSDAssertionValidator {
private void constructAssertProcessor(List assertionList) {
// construct parameter values for the assertion processor
NamespaceSupport xpathNamespaceContext = null;
- if (assertionList instanceof XSObjectList) {
- xpathNamespaceContext = ((XSAssertImpl)((XSObjectList)
assertionList).item(0)).getXPath2NamespaceContext();
- }
- else {
- Vector assertVector = (Vector) assertionList;
- if (assertVector.get(0) instanceof XSAssertImpl) {
- xpathNamespaceContext =
((XSAssertImpl)assertVector.get(0)).getXPath2NamespaceContext();
+ if (assertionList != null) {
+ if (assertionList instanceof XSObjectList) {
+ xpathNamespaceContext = ((XSAssertImpl)((XSObjectList)
assertionList).item(0)).getXPath2NamespaceContext();
}
else {
- XSSimpleTypeDecl xsSimpleTypeDecl =
(XSSimpleTypeDecl)assertVector.get(0);
- if (xsSimpleTypeDecl.getAssertions() != null &&
xsSimpleTypeDecl.getAssertions().size() > 0) {
- xpathNamespaceContext =
((XSAssertImpl)(xsSimpleTypeDecl.getAssertions()).get(0)).
-
getXPath2NamespaceContext();
- }
+ Vector assertVector = (Vector) assertionList;
+ if (assertVector.get(0) instanceof XSAssertImpl) {
+ xpathNamespaceContext =
((XSAssertImpl)assertVector.get(0)).getXPath2NamespaceContext();
+ }
+ else {
+ XSSimpleTypeDecl xsSimpleTypeDecl =
(XSSimpleTypeDecl)assertVector.get(0);
+ if (xsSimpleTypeDecl.getAssertions() != null &&
xsSimpleTypeDecl.getAssertions().size() > 0) {
+ xpathNamespaceContext =
((XSAssertImpl)(xsSimpleTypeDecl.getAssertions()).get(0)).
+
getXPath2NamespaceContext();
+ }
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]