xerces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muk...@apache.org
Subject svn commit: r1023168 - in /xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs: XMLAssertPsychopathImpl.java util/XSTypeHelper.java
Date Sat, 16 Oct 2010 02:13:30 GMT
Author: mukulg
Date: Sat Oct 16 02:13:29 2010
New Revision: 1023168

URL: http://svn.apache.org/viewvc?rev=1023168&view=rev
Log:
doing little refactoring of schema 1.1 assertions code-base. this change doesn't affect the
existing functional behavior of implementation.

Modified:
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathImpl.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/XMLAssertPsychopathImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathImpl.java?rev=1023168&r1=1023167&r2=1023168&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathImpl.java
(original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathImpl.java
Sat Oct 16 02:13:29 2010
@@ -29,13 +29,10 @@ import org.apache.xerces.dom.PSVIAttrNSI
 import org.apache.xerces.dom.PSVIDocumentImpl;
 import org.apache.xerces.dom.PSVIElementNSImpl;
 import org.apache.xerces.impl.Constants;
-import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
-import org.apache.xerces.impl.dv.ValidatedInfo;
-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.assertion.XMLAssertAdapter;
 import org.apache.xerces.impl.xs.assertion.XSAssertImpl;
+import org.apache.xerces.impl.xs.util.XSTypeHelper;
 import org.apache.xerces.xni.Augmentations;
 import org.apache.xerces.xni.QName;
 import org.apache.xerces.xni.XMLAttributes;
@@ -975,13 +972,14 @@ public class XMLAssertPsychopathImpl ext
 
         XSSimpleTypeDefinition simpleTypeDefn = null;
         
-        // Inspecting the member types of union in order, to find that which
+        // Iterate the member types of union in order, to find that which
         // schema type can successfully validate an atomic value first.
         for (int memTypeIdx = 0; memTypeIdx < memberTypes.getLength(); 
                                                             memTypeIdx++) {
            XSSimpleType memSimpleType = (XSSimpleType) memberTypes.item
                                                              (memTypeIdx);
-              if (isValueValidForASimpleType(value, memSimpleType)) {
+              if (XSTypeHelper.isValueValidForASimpleType(value,
+                                                          memSimpleType)) {
                  // no more memberTypes need to be checked
                  simpleTypeDefn = memSimpleType; 
                  break; 
@@ -994,34 +992,6 @@ public class XMLAssertPsychopathImpl ext
     
     
     /*
-     * Determine if a lexical "string value" conforms to a given schema
-     * simpleType definition. Using Xerces API 'XSSimpleType.validate'
-     * for this need.
-     */
-    private boolean isValueValidForASimpleType(String value, XSSimpleType 
-                                                             simplType) {
-        
-        boolean isValueValid = true;
-        
-        try {
-            // construct necessary context objects
-            ValidatedInfo validatedInfo = new ValidatedInfo();
-            ValidationContext validationState = new ValidationState();
-            
-            // attempt to validate the "string value" with a simpleType
-            // instance.
-            simplType.validate(value, validationState, validatedInfo);
-        } 
-        catch(InvalidDatatypeValueException ex){
-            isValueValid = false;
-        }
-        
-        return isValueValid;
-        
-    } // isValueValidForASimpleType
-    
-    
-    /*
      * Class to store "assertion evaluation" error details.
      */
     class AssertionError {

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=1023168&r1=1023167&r2=1023168&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
Sat Oct 16 02:13:29 2010
@@ -17,6 +17,11 @@
 
 package org.apache.xerces.impl.xs.util;
 
+import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
+import org.apache.xerces.impl.dv.ValidatedInfo;
+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.xs.XSTypeDefinition;
 
 /**
@@ -39,9 +44,9 @@ public class XSTypeHelper {
         String type2Name = typeDefn2.getName();
         
         if (("anyType".equals(type1Name) && 
-            "anyType".equals(type2Name)) ||
+             "anyType".equals(type2Name)) ||
             ("anySimpleType".equals(type1Name) && 
-            "anySimpleType".equals(type2Name))) {
+             "anySimpleType".equals(type2Name))) {
                typesIdentical = true;  
         }
         
@@ -82,4 +87,32 @@ public class XSTypeHelper {
         
     } // uriEqual
     
+    
+    /*
+     * Determine if a lexical "string value" conforms to a given schema
+     * simpleType definition. Using Xerces API 'XSSimpleType.validate'
+     * for this need.
+     */
+    public static boolean isValueValidForASimpleType(String value,
+                                                     XSSimpleType simplType) {
+        
+        boolean isValueValid = true;
+        
+        try {
+            // construct necessary context objects
+            ValidatedInfo validatedInfo = new ValidatedInfo();
+            ValidationContext validationState = new ValidationState();
+            
+            // attempt to validate the "string value" with a simpleType
+            // instance.
+            simplType.validate(value, validationState, validatedInfo);
+        } 
+        catch(InvalidDatatypeValueException ex){
+            isValueValid = false;
+        }
+        
+        return isValueValid;
+        
+    } // isValueValidForASimpleType
+    
 }



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


Mime
View raw message