Author: mukulg
Date: Tue Apr 19 04:52:38 2022
New Revision: 1900010

URL: http://svn.apache.org/viewvc?rev=1900010&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=1900010&r1=1900009&r2=1900010&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
 Tue Apr 19 04:52:38 2022
@@ -20,6 +20,7 @@ package org.apache.xerces.impl.dv.xs;
 import java.math.BigInteger;
 import java.util.AbstractList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.StringTokenizer;
@@ -36,10 +37,12 @@ import org.apache.xerces.impl.dv.XSSimpl
 import org.apache.xerces.impl.xpath.regex.RegularExpression;
 import org.apache.xerces.impl.xs.SchemaSymbols;
 import org.apache.xerces.impl.xs.XMLAssertXPath2EngineImpl;
+import org.apache.xerces.impl.xs.XMLAssertXPath2EngineImpl.AssertionError;
 import org.apache.xerces.impl.xs.assertion.XSAssertImpl;
 import org.apache.xerces.impl.xs.util.ObjectListImpl;
 import org.apache.xerces.impl.xs.util.ShortListImpl;
 import org.apache.xerces.impl.xs.util.StringListImpl;
+import org.apache.xerces.impl.xs.util.XS11TypeHelper;
 import org.apache.xerces.impl.xs.util.XSObjectListImpl;
 import org.apache.xerces.util.NamespaceSupport;
 import org.apache.xerces.util.XML11Char;
@@ -997,6 +1000,68 @@ public class XSSimpleTypeDecl implements
                                    throw new 
InvalidDatatypeFacetException(null, null);  
                                }
                            }
+                           
+                           // handling, assertions when the base simpleType 
definition, has variety list whose itemType is union
+                           if 
(((XSSimpleTypeDefinition)this.getBaseType()).getVariety() == 
XSSimpleTypeDefinition.VARIETY_LIST) {
+                               XSSimpleTypeDefinition xsItemTypeDefn = 
((XSSimpleTypeDefinition)this.getBaseType()).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(enumVal, " \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++) {                                                  
       
+                                                         
fAssertionProcessor.setXDMTypedValueOf$valueForSTVarietyAtomic(listItemStrValue,
 
fAssertionProcessor.getXercesXSDTypeCodeFor$value((XSTypeDefinition)xsSimpleTypeDecl),
 
+                                                                               
                                         
fAssertionProcessor.getDynamicContext());                                       
        
+                                                         AssertionError 
assertError = fAssertionProcessor.evaluateOneAssertion(elemQname, 
(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) {                                     
+                                             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=1900010&r1=1900009&r2=1900010&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
 Tue Apr 19 04:52:38 2022
@@ -781,7 +781,7 @@ public class XMLAssertXPath2EngineImpl e
     /*
      * Method to evaluate an assertion. Returns the evaluation error details 
in an AssertionError object.
      */
-    private AssertionError evaluateOneAssertion(QName element, XSAssertImpl 
assertImpl, String value, boolean xPathContextExists, boolean isList) {
+    public AssertionError evaluateOneAssertion(QName element, XSAssertImpl 
assertImpl, String value, boolean xPathContextExists, boolean isList) {
         
         AssertionError assertionError = null;
         
@@ -908,6 +908,9 @@ public class XMLAssertXPath2EngineImpl e
         }        
     }
     
+    public DynamicContext getDynamicContext() {
+        return fXpath2DynamicContext; 
+    }    
     
     /*
      * Method to report assertions error messages.
@@ -982,7 +985,7 @@ public class XMLAssertXPath2EngineImpl e
     /*
      * Class to store "assertion evaluation" error details.
      */
-    final class AssertionError {
+    public final class AssertionError {
         
         // instance variables        
         private final String errorCode;



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to