Author: mukulg
Date: Thu Feb 24 01:03:35 2011
New Revision: 1074003

URL: http://svn.apache.org/viewvc?rev=1074003&view=rev
Log:
committing few improvements to assertions processing, when a simpleType is 
derived from list (whose itemType has assertions). the commit also does few 
refactoring changes.

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/XSDAssertionValidator.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=1074003&r1=1074002&r2=1074003&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
 Thu Feb 24 01:03:35 2011
@@ -321,29 +321,33 @@ public class XMLAssertPsychopathXPath2Im
             if (assertImpl.getType() == XSConstants.ASSERTION) {
                 // not an assertion facet
                 xpathContextExists = true;   
-            }
-            
+            }            
             if (assertImpl.getAttrName() != null) {
                 // evaluate assertion from an attribute
                 value = assertImpl.getAttrValue();
-                XSSimpleTypeDefinition assertSimpleType = 
(XSSimpleTypeDefinition) assertImpl.getTypeDefinition();                        
        
+                XSSimpleTypeDefinition attrSimpleType = 
(XSSimpleTypeDefinition) assertImpl.getTypeDefinition();
+                final boolean isTypeDerivedFromList = ((XSSimpleType) 
attrSimpleType.getBaseType()).getVariety() == XSSimpleType.VARIETY_LIST;
+                final boolean isTypeDerivedFromUnion = ((XSSimpleType) 
attrSimpleType.getBaseType()).getVariety() == XSSimpleType.VARIETY_UNION;
                 if (assertImpl.getVariety() == 
XSSimpleTypeDefinition.VARIETY_ATOMIC) {
                     // evaluating assertions for "simpleType -> restriction" 
(not derived by union)
-                    setTypedValueFor$value(value, null, assertSimpleType, 
false);
+                    setTypedValueFor$value(value, null, attrSimpleType, false);
                     AssertionError assertError = evaluateOneAssertion(element, 
assertImpl, value, xpathContextExists, false);
                     if (assertError != null) {
                         reportAssertionsError(assertError);    
                     }
                 }
                 else if (assertImpl.getVariety() == 
XSSimpleTypeDefinition.VARIETY_LIST) {
-                    // evaluating assertions for "simpleType -> list"
-                    final boolean isTypeDerivedFromList = ((XSSimpleType) 
assertSimpleType.getBaseType()).getVariety() == XSSimpleType.VARIETY_LIST;
-                    evaluateAssertionOnSTListValue(element, value, assertImpl, 
xpathContextExists, assertSimpleType, isTypeDerivedFromList);
+                    // evaluating assertions for "simpleType -> list"          
          
+                    evaluateAssertionOnSTListValue(element, value, assertImpl, 
xpathContextExists, attrSimpleType, isTypeDerivedFromList);
                 }
                 else {
-                    // evaluating assertions for "simpleType -> union"
-                    final boolean isTypeDerivedFromUnion = ((XSSimpleType) 
assertSimpleType.getBaseType()).getVariety() == XSSimpleType.VARIETY_UNION;
-                    evaluateAssertionOnSTUnion(element, 
assertSimpleType.getMemberTypes(), isTypeDerivedFromUnion, assertImpl, value);
+                    // evaluating assertions for "simpleType -> union"         
           
+                    evaluateAssertionOnSTUnion(element, 
attrSimpleType.getMemberTypes(), isTypeDerivedFromUnion, assertImpl, value);
+                }                
+                // evaluate assertions on itemType of xs:list
+                XSSimpleTypeDefinition attrItemType = 
attrSimpleType.getItemType();
+                if (isTypeDerivedFromList && attrItemType != null) {
+                    evaluateAssertsFromItemTypeOfSTList(element, attrItemType, 
value);
                 }
             }
             else {
@@ -354,6 +358,7 @@ public class XMLAssertPsychopathXPath2Im
                 }  
             }
         }
+       
         
     } // evaluateAssertionsFromAComplexType
 
@@ -374,10 +379,11 @@ public class XMLAssertPsychopathXPath2Im
             }
         }
         
+        final boolean isTypeDerivedFromList = ((XSSimpleType) 
elemPSVI.getTypeDefinition().getBaseType()).getVariety() == 
XSSimpleType.VARIETY_LIST;
+        final boolean isTypeDerivedFromUnion = ((XSSimpleType) 
elemPSVI.getTypeDefinition().getBaseType()).getVariety() == 
XSSimpleType.VARIETY_UNION;
         // process assertions from a simple type definition           
         Vector assertList = (Vector) assertions;
-        final int assertListLength = assertList.size();
-        
+        final int assertListLength = assertList.size();        
         for (int assertIdx = 0; assertIdx < assertListLength; assertIdx++) {
             XSAssertImpl assertImpl = (XSAssertImpl) assertList.get(assertIdx);
             String xPathDefaultNamespace = 
assertImpl.getXPathDefaultNamespace(); 
@@ -393,33 +399,64 @@ public class XMLAssertPsychopathXPath2Im
                 }    
             }
             else if (itemType != null) {
-               // evaluating assertions for "simpleType -> list"
-               final boolean isTypeDerivedFromList = ((XSSimpleType) 
elemPSVI.getTypeDefinition().getBaseType()).getVariety() == 
XSSimpleType.VARIETY_LIST;
+               // evaluating assertions for "simpleType -> list"               
                evaluateAssertionOnSTListValue(element, value, assertImpl, 
false, itemType, isTypeDerivedFromList);
             }            
             else {
-               // evaluating assertions for "simpleType -> union"
-               final boolean isTypeDerivedFromUnion = ((XSSimpleType) 
elemPSVI.getTypeDefinition().getBaseType()).getVariety() == 
XSSimpleType.VARIETY_UNION;
+               // evaluating assertions for "simpleType -> union"              
 
                evaluateAssertionOnSTUnion(element, memberTypes, 
isTypeDerivedFromUnion, assertImpl, value);
             }
         }
         
+        // evaluate assertions on itemType of xs:list
+        if (isTypeDerivedFromList && itemType != null) {
+            evaluateAssertsFromItemTypeOfSTList(element, itemType, value); 
+        }
+        
     } // evaluateAssertionsFromASimpleType
     
     
     /*
+     * Evaluate assertions from itemType (having variety 'atomic') of xs:list. 
This method is used to evaluate assertions from elements
+     * with simple content, and simpleType definitions from attributes.
+     */
+    private void evaluateAssertsFromItemTypeOfSTList(QName element, 
XSSimpleTypeDefinition listItemType, String value) throws Exception{
+        
+        Vector itemTypeAsserts = 
XSTypeHelper.getAssertsFromSimpleType(listItemType);
+        if (listItemType.getVariety() ==  
XSSimpleTypeDefinition.VARIETY_ATOMIC && itemTypeAsserts.size() > 0) {
+            for (int assertIdx = 0; assertIdx < itemTypeAsserts.size(); 
assertIdx++) {
+                XSAssertImpl itemTypeAssert = (XSAssertImpl) 
itemTypeAsserts.get(assertIdx);
+                StringTokenizer listStrTokens = new StringTokenizer(value, " 
\n\t\r");
+                while (listStrTokens.hasMoreTokens()) {
+                    String listItemStrValue = listStrTokens.nextToken();
+                    setValueOf$valueForSTVarietyList(listItemStrValue, 
listItemType, false);                        
+                    AssertionError assertError = evaluateOneAssertion(element, 
itemTypeAssert, listItemStrValue, false, true);                        
+                    if (assertError != null) {
+                        assertError.setIsTypeDerivedFromList(false);
+                        reportAssertionsError(assertError);    
+                    }
+                }
+            }
+        }
+        
+    } // evaluateAssertsFromItemTypeOfSTList
+    
+    
+    /*
      * Evaluate assertion on a simpleType xs:list value.
      */
     private void evaluateAssertionOnSTListValue(QName element, String 
listStrValue, XSAssertImpl assertImpl, boolean xpathContextExists,
                                                 XSSimpleTypeDefinition 
itemType, boolean isTypeDerivedFromList) throws Exception {
         
+        AssertionError assertError = null;
+        
         if (isTypeDerivedFromList) {
             setValueOf$valueForSTVarietyList(listStrValue, itemType, 
isTypeDerivedFromList);
-            AssertionError assertError = evaluateOneAssertion(element, 
assertImpl, listStrValue, xpathContextExists, true);
+            assertError = evaluateOneAssertion(element, assertImpl, 
listStrValue, xpathContextExists, true);
             if (assertError != null) {
                 assertError.setIsTypeDerivedFromList(isTypeDerivedFromList);
                 reportAssertionsError(assertError);    
-            }
+            }            
         }
         else {
             // evaluate assertion on all of list items
@@ -428,7 +465,7 @@ public class XMLAssertPsychopathXPath2Im
             while (listStrTokens.hasMoreTokens()) {
                 String listItemStrValue = listStrTokens.nextToken();
                 setValueOf$valueForSTVarietyList(listItemStrValue, itemType, 
isTypeDerivedFromList);                        
-                AssertionError assertError = evaluateOneAssertion(element, 
assertImpl, listItemStrValue, xpathContextExists, true);
+                assertError = evaluateOneAssertion(element, assertImpl, 
listItemStrValue, xpathContextExists, true);
                 if (assertError != null) {
                     reportAssertionsError(assertError);    
                 }
@@ -660,20 +697,19 @@ public class XMLAssertPsychopathXPath2Im
     
     
     /*
-     * Set a typed value of XPath2 context variable $value if an atomic value 
on which assertion is been evaluated, is an item
-     * of schema component xs:list.
+     * Set a typed value of XPath2 context variable $value, if the simpleType 
context is xs:list.
      */
-    private void setValueOf$valueForSTVarietyList(String listItemStrValue, 
XSSimpleTypeDefinition itemType, boolean isTypeDerivedFromList) throws 
Exception {
+    private void setValueOf$valueForSTVarietyList(String listStrValue, 
XSSimpleTypeDefinition itemType, boolean isTypeDerivedFromList) throws 
Exception {
         
         XSObjectList memberTypes = itemType.getMemberTypes();
         if (memberTypes.getLength() > 0) {
             // the list's item type has variety 'union'
-            XSSimpleTypeDefinition actualListItemType = 
getActualListItemTypeForVarietyUnion(memberTypes, listItemStrValue);
+            XSSimpleTypeDefinition actualListItemType = 
getActualListItemTypeForVarietyUnion(memberTypes, listStrValue);
             // set a schema 'typed value' to variable $value
-            setTypedValueFor$value(listItemStrValue, actualListItemType, null, 
false);
+            setTypedValueFor$value(listStrValue, actualListItemType, null, 
false);
         } 
         else {
-            setTypedValueFor$value(listItemStrValue, itemType, null, 
isTypeDerivedFromList); 
+            setTypedValueFor$value(listStrValue, itemType, null, 
isTypeDerivedFromList); 
         }
 
     } // setValueOf$valueForSTVarietyList

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=1074003&r1=1074002&r2=1074003&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
 Thu Feb 24 01:03:35 2011
@@ -27,6 +27,7 @@ import org.apache.xerces.impl.xs.asserti
 import org.apache.xerces.impl.xs.assertion.XSAssert;
 import org.apache.xerces.impl.xs.assertion.XSAssertImpl;
 import org.apache.xerces.impl.xs.util.XSObjectListImpl;
+import org.apache.xerces.impl.xs.util.XSTypeHelper;
 import org.apache.xerces.util.AugmentationsImpl;
 import org.apache.xerces.util.NamespaceSupport;
 import org.apache.xerces.xni.Augmentations;
@@ -152,18 +153,17 @@ public class XSDAssertionValidator {
         
        XSTypeDefinition typeDef = 
xmlSchemaValidator.fCurrentPSVI.getTypeDefinition();
 
-       List assertionList = null;
-            
+       List assertionList = null;            
        if (typeDef.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
            // if element's schema type is a "complex type"               
-           XSObjectListImpl complexTypeAsserts = 
getAssertsFromComplexType(typeDef, attributes);
+           XSObjectListImpl complexTypeAsserts = 
getAssertsFromComplexType((XSComplexTypeDefinition) typeDef, attributes);
            if (complexTypeAsserts.size() > 0) {
                assertionList = complexTypeAsserts;             
            }
        }
        else if (typeDef.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
            // if element's schema type is a "simple type"
-           assertionList = getAssertsFromSimpleType(typeDef);            
+           assertionList = getAssertsFromSimpleType((XSSimpleTypeDefinition) 
typeDef);            
        }
                
        return assertionList;
@@ -174,32 +174,24 @@ public class XSDAssertionValidator {
     /*
      * Accumulate assertions from a complex type.
      */
-    private XSObjectListImpl getAssertsFromComplexType(XSTypeDefinition 
typeDef, XMLAttributes attributes) {
+    private XSObjectListImpl getAssertsFromComplexType(XSComplexTypeDefinition 
complexTypeDef, XMLAttributes attributes) {
         
         XSObjectListImpl complexTypeAsserts = new XSObjectListImpl();
 
-        XSComplexTypeDefinition complexTypeDef = (XSComplexTypeDefinition) 
typeDef;
-
         XSObjectList primaryAssertions = complexTypeDef.getAssertions();
         if (primaryAssertions.getLength() > 0) {
-            for (int i = 0; i < primaryAssertions.getLength(); i++) {
-                complexTypeAsserts.addXSObject((XSAssert) 
primaryAssertions.get(i));
+            for (int assertIdx = 0; assertIdx < primaryAssertions.getLength(); 
assertIdx++) {
+                complexTypeAsserts.addXSObject((XSAssert) 
primaryAssertions.get(assertIdx));
             }
         }
 
         // add assertion facets from "complexType -> simpleContent -> 
restriction"
         XSSimpleTypeDefinition simpleContentType = 
complexTypeDef.getSimpleType();
-        if (simpleContentType != null) {
-            XSObjectList complexTypeFacets = 
simpleContentType.getMultiValueFacets();
-            for (int i = 0; i < complexTypeFacets.getLength(); i++) {
-                XSMultiValueFacet facet = (XSMultiValueFacet) 
complexTypeFacets.item(i);
-                if (facet.getFacetKind() == 
XSSimpleTypeDefinition.FACET_ASSERT) {
-                    Vector simpleContentAsserts = facet.getAsserts();
-                    for (int simpleAssertIdx = 0; simpleAssertIdx < 
simpleContentAsserts.size(); simpleAssertIdx++) {
-                        XSAssert simpleContentAssert = (XSAssert) 
simpleContentAsserts.get(simpleAssertIdx);
-                        complexTypeAsserts.addXSObject(simpleContentAssert);
-                    }
-                }
+        if (simpleContentType != null) {            
+            Vector simpleContentAsserts = 
XSTypeHelper.getAssertsFromSimpleType(simpleContentType);
+            for (int assertIdx = 0; assertIdx < simpleContentAsserts.size(); 
assertIdx++) {
+                XSAssert simpleContentAssert = (XSAssert) 
simpleContentAsserts.get(assertIdx);
+                complexTypeAsserts.addXSObject(simpleContentAssert);
             }
         }
 
@@ -227,19 +219,19 @@ public class XSDAssertionValidator {
             XSSimpleTypeDefinition attrType = (XSSimpleTypeDefinition) 
attrPSVI.getTypeDefinition();
             if (attrType != null) {
                 // this accumulates assertions only for "simpleType -> 
restriction"
-                XSObjectList facets = attrType.getMultiValueFacets();
-
+                XSObjectList facetList = attrType.getMultiValueFacets();
                 // simpleType variety is 'unknown/absent' at the moment        
            
                 short attrTypeVariety = XSSimpleTypeDefinition.VARIETY_ABSENT;
-
-                if (facets.getLength() == 0 && attrType.getItemType() != null) 
{
+                if (attrType.getItemType() != null) {
                     // facets for "simpleType -> list"
                     attrTypeVariety = XSSimpleTypeDefinition.VARIETY_LIST;
-                    facets = (XSObjectListImpl) 
attrType.getItemType().getMultiValueFacets();    
+                    if (facetList.getLength() == 0) {
+                       facetList = (XSObjectListImpl) 
attrType.getItemType().getMultiValueFacets();  
+                    }
                 }
                 else if (attrType.getVariety() == 
XSSimpleTypeDefinition.VARIETY_UNION) {
                     attrTypeVariety = XSSimpleTypeDefinition.VARIETY_UNION;
-                    // Special handling for assertions on "simpleType -> 
union" cases. Adding an assertion here,
+                    // Special handling for assertions on "simpleType -> 
union" cases. Adding an assertion here
                     // for determining the XSModel NamespaceContext. This 
particular assertion object is not 
                     // actually evaluated. For simpleType's with variety 
union, assertions are later again determined 
                     // in XMLAssertPsychopathImpl, which are evaluated to 
determine validity of an XML instance.               
@@ -256,10 +248,9 @@ public class XSDAssertionValidator {
                     attrTypeVariety = XSSimpleTypeDefinition.VARIETY_ATOMIC;   
                 }
 
-                // iterate all the schema facets for attributes having the 
simpleType variety "atomic | list", and
-                // accumulate assertions from them.
-                for (int facetIdx = 0; facetIdx < facets.getLength(); 
facetIdx++) {
-                    XSMultiValueFacet facet = (XSMultiValueFacet) 
facets.item(facetIdx);
+                // iterate all the schema facets for attributes having the 
simpleType variety "atomic | list", and accumulate assertions from them
+                for (int facetIdx = 0; facetIdx < facetList.getLength(); 
facetIdx++) {
+                    XSMultiValueFacet facet = (XSMultiValueFacet) 
facetList.item(facetIdx);
                     if (facet.getFacetKind() == 
XSSimpleTypeDefinition.FACET_ASSERT) {
                         Vector attrAsserts = facet.getAsserts();
                         for (int assertIdx = 0; assertIdx < 
attrAsserts.size(); assertIdx++) {                             
@@ -273,8 +264,7 @@ public class XSDAssertionValidator {
                             
attrAssert.setAttrName(attributes.getLocalName(attrIndx));
                             
attrAssert.setAttrValue(attributes.getValue(attrIndx));                         
                                   
                             attrAssertList.addXSObject(attrAssert);
-                        }
-                        // break from the for loop
+                        }                        
                         break;
                     }
                 }                
@@ -289,21 +279,17 @@ public class XSDAssertionValidator {
     /*
      * Get assertions from a simpleType.
      */
-    private List getAssertsFromSimpleType(XSTypeDefinition typeDef) {
+    private List getAssertsFromSimpleType(XSSimpleTypeDefinition 
simpleTypeDef) {
         
         List simpleTypeAsserts = null;
-
-        XSSimpleTypeDefinition simpleTypeDef = (XSSimpleTypeDefinition) 
typeDef;                     
-
-        XSObjectListImpl facets = (XSObjectListImpl) 
simpleTypeDef.getMultiValueFacets();
-
-        if (facets.getLength() == 0 && simpleTypeDef.getItemType() != null) {
+                   
+        XSObjectListImpl facetList = (XSObjectListImpl) 
simpleTypeDef.getMultiValueFacets();
+        if (facetList.getLength() == 0 && simpleTypeDef.getItemType() != null) 
{
             // facets for "simpleType -> list"
-            facets = (XSObjectListImpl) 
simpleTypeDef.getItemType().getMultiValueFacets();    
+            facetList = (XSObjectListImpl) 
simpleTypeDef.getItemType().getMultiValueFacets();    
         }
         else if (simpleTypeDef.getVariety() == 
XSSimpleTypeDefinition.VARIETY_UNION) {
-            // Special handling for assertions on "simpleType -> union" cases. 
Adding an assertion here,
-            // for determining the NamespaceContext.
+            // special handling for assertions on "simpleType -> union" cases. 
Adding an assertion here, for determining the NamespaceContext
             XSAssertImpl assertImpl = 
getFirstAssertFromUnionMemberTypes(simpleTypeDef.getMemberTypes());
             if (assertImpl != null) {
                 simpleTypeAsserts = new Vector();
@@ -311,10 +297,9 @@ public class XSDAssertionValidator {
             }
         }
 
-        // iterate all the schema facets having the simpleType variety "atomic 
| list", and accumulate assertions
-        // from them.
-        for (int facetIdx = 0; facetIdx < facets.getLength(); facetIdx++) {
-            XSMultiValueFacet facet = (XSMultiValueFacet) 
facets.item(facetIdx);
+        // iterate all the schema facets having the simpleType variety "atomic 
| list", and accumulate assertions from them
+        for (int facetIdx = 0; facetIdx < facetList.getLength(); facetIdx++) {
+            XSMultiValueFacet facet = (XSMultiValueFacet) 
facetList.item(facetIdx);
             if (facet.getFacetKind() == XSSimpleTypeDefinition.FACET_ASSERT) {
                 if (simpleTypeAsserts == null) {
                     simpleTypeAsserts = new Vector();   
@@ -332,28 +317,18 @@ public class XSDAssertionValidator {
      * Get the 1st assertion from the member types of simpleType having 
variety union. Needed to get an schema
      * "namespace context" which is available for example, in the 1st 
assertion in the assertions list.
      */
-    private XSAssertImpl getFirstAssertFromUnionMemberTypes(XSObjectList 
memberTypes) {
+    private XSAssertImpl getFirstAssertFromUnionMemberTypes(XSObjectList 
unionMemberTypes) {
         
-        XSAssertImpl assertImpl = null;
+         XSAssertImpl assertImpl = null;
         
-        for (int memberTypeIdx = 0; memberTypeIdx < memberTypes.getLength(); 
memberTypeIdx++) {
-            boolean isAssertFound = false;
-            XSSimpleTypeDefinition memType = (XSSimpleTypeDefinition) 
memberTypes.item(memberTypeIdx);
-            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();
-                        assertImpl = (XSAssertImpl) assertFacets.get(0);       
                 
-                        // return the 1st assertion that's found
-                        isAssertFound = true;
-                        break;
-                    }
-                 }
-             }
-             if (isAssertFound) {
-                break;  
+         for (int memberTypeIdx = 0; memberTypeIdx < 
unionMemberTypes.getLength(); memberTypeIdx++) {
+             XSSimpleTypeDefinition unionMemberType = (XSSimpleTypeDefinition) 
unionMemberTypes.item(memberTypeIdx);
+             if 
(!SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(unionMemberType.getNamespace())) {
+                Vector memberTypeAsserts = 
XSTypeHelper.getAssertsFromSimpleType(unionMemberType);
+                if (memberTypeAsserts.size() > 0) {
+                   assertImpl = (XSAssertImpl) memberTypeAsserts.get(0);
+                   break;
+                }                
              }
          }
         

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=1074003&r1=1074002&r2=1074003&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
 Thu Feb 24 01:03:35 2011
@@ -17,6 +17,8 @@
 
 package org.apache.xerces.impl.xs.util;
 
+import java.util.Vector;
+
 import org.apache.xerces.impl.XMLErrorReporter;
 import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
 import org.apache.xerces.impl.dv.ValidatedInfo;
@@ -27,7 +29,9 @@ import org.apache.xerces.impl.xs.SchemaS
 import org.apache.xerces.impl.xs.XSMessageFormatter;
 import org.apache.xerces.util.XMLChar;
 import org.apache.xerces.xni.NamespaceContext;
+import org.apache.xerces.xs.XSMultiValueFacet;
 import org.apache.xerces.xs.XSObjectList;
+import org.apache.xerces.xs.XSSimpleTypeDefinition;
 import org.apache.xerces.xs.XSTypeDefinition;
 
 /**
@@ -63,8 +67,7 @@ public class XSTypeHelper {
             if (isURIEqual(typeDefn1.getNamespace(), 
typeDefn2.getNamespace())) {
                 // if targetNamespace of types are same, then check for  
equality of type names and of the base type
                 if ((type1Name == null && type2Name == null) ||
-                    (type1Name != null && type1Name.equals(type2Name))
-                          && (isSchemaTypesIdentical(typeDefn1.getBaseType(), 
typeDefn2.getBaseType()))) {
+                    (type1Name != null && type1Name.equals(type2Name)) && 
(isSchemaTypesIdentical(typeDefn1.getBaseType(), typeDefn2.getBaseType()))) {
                      typesIdentical = true;   
                 }
             }
@@ -74,12 +77,14 @@ public class XSTypeHelper {
         
     } // isSchemaTypesIdentical
     
+    
     /*
      * Check if two URI values are equal.
      */
     public static boolean isURIEqual(String uri1, String uri2) {
         return (uri1 == uri2 || (uri1 != null && uri1.equals(uri2)));
-    } // isURIEqual   
+    } // isURIEqual  
+    
     
     /*
      * Determine if an atomic value is valid with respect to any of the 
union's member types (those that are in XML Schema namespace). 
@@ -166,4 +171,24 @@ public class XSTypeHelper {
         
     } // validateQNameValue
     
+    
+    /*
+     * Get assertions list of a simpleType definition.
+     */
+    public static Vector getAssertsFromSimpleType(XSSimpleTypeDefinition 
simplType) {
+
+        Vector simpleTypeAsserts = new Vector();
+        
+        XSObjectListImpl facetList = (XSObjectListImpl) 
simplType.getMultiValueFacets();         
+        for (int facetIdx = 0; facetIdx < facetList.getLength(); facetIdx++) {
+            XSMultiValueFacet facet = (XSMultiValueFacet) 
facetList.item(facetIdx);
+            if (facet.getFacetKind() == XSSimpleTypeDefinition.FACET_ASSERT) {
+                simpleTypeAsserts = facet.getAsserts();
+            }
+        }
+        
+        return simpleTypeAsserts;
+        
+    } // getAssertsFromSimpleType
+    
 } // class XSTypeHelper



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

Reply via email to