You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mu...@apache.org on 2010/11/03 01:22:18 UTC

svn commit: r1030300 - in /xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs: XMLSchemaValidator.java opti/SchemaConditionalIncludeHelper.java opti/SchemaDOMParser.java util/XSTypeHelper.java

Author: mukulg
Date: Wed Nov  3 00:22:17 2010
New Revision: 1030300

URL: http://svn.apache.org/viewvc?rev=1030300&view=rev
Log:
doing little refactoring and slight corrections in implementation.

Modified:
    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/opti/SchemaConditionalIncludeHelper.java
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaDOMParser.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/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=1030300&r1=1030299&r2=1030300&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 Nov  3 00:22:17 2010
@@ -52,6 +52,7 @@ import org.apache.xerces.impl.xs.identit
 import org.apache.xerces.impl.xs.models.CMBuilder;
 import org.apache.xerces.impl.xs.models.CMNodeFactory;
 import org.apache.xerces.impl.xs.models.XSCMValidator;
+import org.apache.xerces.impl.xs.util.XSTypeHelper;
 import org.apache.xerces.util.AugmentationsImpl;
 import org.apache.xerces.util.IntStack;
 import org.apache.xerces.util.SymbolTable;
@@ -3240,11 +3241,11 @@ public class XMLSchemaValidator
         try {
             actualValue = attDV.validate(attrValue, fValidationState, fValidatedInfo);
             
-            // additional check for assertions processing, for simple type 
+            // additional check for assertions processing, for simple type having  
             // variety 'union'.
             if (attDV.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION) {
-                if (isAtomicValueValidForAnUnion(attDV.getMemberTypes(), 
-                                                  attrValue, null)) {
+                if (XSTypeHelper.isAtomicValueValidForAnUnion(attDV.getMemberTypes(), 
+                                                              attrValue, null)) {
                     fisAtomicValueValid = false; 
                 }
             }
@@ -3395,11 +3396,11 @@ public class XMLSchemaValidator
                     fValidationState.setFacetChecking(false);
                     attDV.validate(fValidationState, defaultValue);
                     
-                    // additional check for assertions processing, for simple type 
+                    // additional check for assertions processing, for simple type having 
                     // variety 'union'.
                     if (attDV.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION) {
-                        if (isAtomicValueValidForAnUnion(attDV.getMemberTypes(), 
-                                                         null, defaultValue)) {
+                        if (XSTypeHelper.isAtomicValueValidForAnUnion(attDV.getMemberTypes(), 
+                                                                      null, defaultValue)) {
                             fisAtomicValueValid = false; 
                         }
                     }
@@ -3608,12 +3609,12 @@ public class XMLSchemaValidator
                     }
                     retValue = dv.validate(textContent, fValidationState, fValidatedInfo);
                     
-                    // additional check for assertions processing, for simple type 
+                    // additional check for assertions processing, for simple type having 
                     // variety 'union'.
                     if (dv.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION) {
-                        if (isAtomicValueValidForAnUnion(dv.getMemberTypes(), 
-                                                     String.valueOf(textContent), 
-                                                     null)) {
+                        if (XSTypeHelper.isAtomicValueValidForAnUnion(dv.getMemberTypes(), 
+                                                              String.valueOf(textContent), 
+                                                              null)) {
                             fisAtomicValueValid = false; 
                         }
                     }
@@ -3658,12 +3659,12 @@ public class XMLSchemaValidator
                     }
                     actualValue = dv.validate(textContent, fValidationState, fValidatedInfo);
                     
-                    // additional check for assertions processing, for simple type 
+                    // additional check for assertions processing, for simple type having 
                     // variety 'union'.
                     if (dv.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION) {
-                        if (isAtomicValueValidForAnUnion(dv.getMemberTypes(), 
-                                                         String.valueOf(textContent), 
-                                                         null)) {
+                        if (XSTypeHelper.isAtomicValueValidForAnUnion(dv.getMemberTypes(), 
+                                                              String.valueOf(textContent), 
+                                                              null)) {
                             fisAtomicValueValid = false; 
                         }
                     }
@@ -4824,49 +4825,6 @@ public class XMLSchemaValidator
                 fData = newdata;
             }
         }
-    }
-    
-    
-    /*
-     * Determine if an atomic value is valid with respect to any of the 
-     * union's built-in schema types. If this method returns 'true', then
-     * the value is valid with respect to an union schema component. 
-     */
-    private boolean isAtomicValueValidForAnUnion(XSObjectList
-                                              memberTypes, String content,
-                                              ValidatedInfo validatedInfo) {
-        
-        boolean isValid = false;
-        
-        // check the union member types in sequence, to check for validity of
-        // an 'atomic value'. the validity of 'atomic value' wrt to 1st type
-        // in this sequence, 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())) {
-                try {
-                   if (validatedInfo != null) {
-                       simpleTypeDv.validate(fValidationState, validatedInfo); 
-                   }
-                   else {                       
-                       simpleTypeDv.validate(content, fValidationState, 
-                                             fValidatedInfo);
-                   }
-                   isValid = true;
-                   break;
-                }
-                catch(InvalidDatatypeValueException idve) {
-                   isValid = false;  
-                }
-            }
-        }
-        
-        return isValid;
-        
-    } // isAtomicValueValidForAnUnion    
+    }    
     
-} // class SchemaValidator
+} // class XMLSchemaValidator

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaConditionalIncludeHelper.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaConditionalIncludeHelper.java?rev=1030300&r1=1030299&r2=1030300&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaConditionalIncludeHelper.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaConditionalIncludeHelper.java Wed Nov  3 00:22:17 2010
@@ -26,8 +26,10 @@ import org.apache.xerces.impl.xs.SchemaS
 import org.apache.xerces.xni.QName;
 
 /**
- * This class provides supporting functionality for XML Schema conditional
- * include pre-processing (newly introduced in XML Schema 1.1).
+ * @xerces.internal
+ * 
+ * This class provides supporting functionality for XML Schema conditional include
+ * pre-processing (newly introduced in XML Schema 1.1).
  * 
  * 
  * ref: http://www.w3.org/TR/xmlschema11-1/#cip
@@ -215,16 +217,18 @@ public class SchemaConditionalIncludeHel
     } // initSupportedFacets
     
     
-    /* Method to check if a schema type specified by method arguments (the
+    /* 
+     * Method to check if a schema type specified by method arguments (the
      * QName components of the schema type) is supported by Xerces-J natively.
+     * 
      */
     public boolean isTypeSupported(String localName, String uri) {
        boolean typeSupported = false;
        
        for (Iterator iter = typesSupported.iterator(); iter.hasNext(); ) {
           QName typeQname = (QName) iter.next();
-          if (localName.equals(typeQname.localpart) &&
-              uri.equals(typeQname.uri)) {
+          if (localName.equals(typeQname.localpart) && uri.equals
+                                                        (typeQname.uri)) {
                 typeSupported = true;
                 break;
           }
@@ -235,16 +239,18 @@ public class SchemaConditionalIncludeHel
     } // isTypeSupported 
     
     
-    /* Method to check if a schema facet specified by method arguments (the
+    /* 
+     * Method to check if a schema facet specified by method arguments (the
      * QName components of a schema facet) is supported by Xerces-J natively.
+     * 
      */
     public boolean isFacetSupported(String localName, String uri) {
         boolean facetSupported = false;
         
         for (Iterator iter = facetsSupported.iterator(); iter.hasNext(); ) {
            QName typeQname = (QName) iter.next();
-           if (localName.equals(typeQname.localpart) &&
-               uri.equals(typeQname.uri)) {
+           if (localName.equals(typeQname.localpart) && uri.equals
+                                                          (typeQname.uri)) {
                  facetSupported = true;
                  break;
            }
@@ -254,4 +260,4 @@ public class SchemaConditionalIncludeHel
         
     } // isFacetSupported
 
-}
+} // class SchemaConditionalIncludeHelper

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaDOMParser.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaDOMParser.java?rev=1030300&r1=1030299&r2=1030300&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaDOMParser.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaDOMParser.java Wed Nov  3 00:22:17 2010
@@ -44,7 +44,7 @@ import org.apache.xerces.xs.datatypes.XS
 import org.w3c.dom.Document;
 
 /**
- * @xerces.internal  
+ * @xerces.internal
  * 
  * @author Rahul Srivastava, Sun Microsystems Inc.
  * @author Sandy Gao, IBM
@@ -709,7 +709,7 @@ public class SchemaDOMParser extends Def
                                                          Constants.IS_FACET,
                                                          Constants.TYPE_AND_FACET_UNAVAILABILITY);
         
-        if (minMaxSchemaVerAllowsIgnore || typeAvlAllowsIgnore || typeUnavlAllowsIgnore | 
+        if (minMaxSchemaVerAllowsIgnore || typeAvlAllowsIgnore || typeUnavlAllowsIgnore || 
             facetAvlAllowsIgnore || facetUnavlAllowsIgnore) {
             ignoreSchemaComponent =  true;  
         }

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=1030300&r1=1030299&r2=1030300&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 Nov  3 00:22:17 2010
@@ -22,10 +22,14 @@ import org.apache.xerces.impl.dv.Validat
 import org.apache.xerces.impl.dv.ValidationContext;
 import org.apache.xerces.impl.dv.XSSimpleType;
 import org.apache.xerces.impl.validation.ValidationState;
+import org.apache.xerces.impl.xs.SchemaSymbols;
+import org.apache.xerces.xs.XSObjectList;
 import org.apache.xerces.xs.XSTypeDefinition;
 
 /**
- * Class defining utility/helper methods related to schema types.
+ * @xerces.internal
+ * 
+ * Class defining utility/helper methods related to XML schema types.
  * 
  * @author Mukul Gandhi, IBM
  * @version $Id$
@@ -52,8 +56,8 @@ public class XSTypeHelper {
         
         if (!typesIdentical) {                        
             if (uriEqual(typeDefn1.getNamespace(), typeDefn2.getNamespace())) {
-                // if targetNamespace of types are same, then check for 
-                // equality of type names and of the base type.
+                // 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))
                           && (schemaTypesIdentical(typeDefn1.getBaseType(),
@@ -89,9 +93,42 @@ public class XSTypeHelper {
     
     
     /*
-     * Determine if a lexical "string value" conforms to a given schema
-     * simpleType definition. Using Xerces API 'XSSimpleType.validate'
-     * for this need.
+     * Determine if an atomic value is valid with respect to any of the union's
+     * member types. 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) {
+        
+        boolean isValid = false;
+        
+        // check the union member types in order to check for validity of an 'atomic value'.
+        // the validity of 'atomic value' wrt to the 1st available type in this sequence,
+        // 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())) {                
+                if (XSTypeHelper.isValueValidForASimpleType(content, 
+                                                            simpleTypeDv)) {
+                    isValid = true;
+                    break;  
+                }
+            }
+        }
+        
+        return isValid;
+        
+    } // isAtomicValueValidForAnUnion
+    
+    
+    /*
+     * Determine if a lexical "string value" belongs to the value space (i.e is valid
+     * according to the type) of a given schema simpleType definition. Using Xerces API
+     * 'XSSimpleType.validate' for this need.
      */
     public static boolean isValueValidForASimpleType(String value,
                                                      XSSimpleType simplType) {
@@ -113,6 +150,6 @@ public class XSTypeHelper {
         
         return isValueValid;
         
-    } // isValueValidForASimpleType
+    } // isValueValidForASimpleType    
     
-}
+} // class XSTypeHelper



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org