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 2012/07/11 06:45:17 UTC

svn commit: r1360009 - in /xerces/java/branches/xml-schema-1.1-dev: samples/xs/XSSerializer.java src/org/apache/xerces/impl/xs/XMLAssertPsychopathXPath2Impl.java

Author: mukulg
Date: Wed Jul 11 04:45:17 2012
New Revision: 1360009

URL: http://svn.apache.org/viewvc?rev=1360009&view=rev
Log:
doing minor refactoring and improving javadocs

Modified:
    xerces/java/branches/xml-schema-1.1-dev/samples/xs/XSSerializer.java
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLAssertPsychopathXPath2Impl.java

Modified: xerces/java/branches/xml-schema-1.1-dev/samples/xs/XSSerializer.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/samples/xs/XSSerializer.java?rev=1360009&r1=1360008&r2=1360009&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/samples/xs/XSSerializer.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/samples/xs/XSSerializer.java Wed Jul 11 04:45:17 2012
@@ -70,7 +70,7 @@ import org.xml.sax.InputSource;
 
 /**
  * XSModel serialization utility.
- * This utility serializes the Xerces XSModel into lexical, XSD syntax.
+ * This utility serializes the Xerces XSModel instance into lexical, XSD syntax.
  * 
  * @author Mukul Gandhi, IBM
  * @version $Id$
@@ -87,7 +87,7 @@ public class XSSerializer {
      * 
      * An entry point to test this utility.
      * 
-     * The XSModel could be synthesized by any means (for example, by direct
+     * The XSModel could be synthesized by various means (for example, by direct
      * API calls to Xerces Schema API, methods) -- in which case, the method
      * "serialize" will be used directly, passing in the XSModel object. 
      */

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=1360009&r1=1360008&r2=1360009&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 Wed Jul 11 04:45:17 2012
@@ -194,8 +194,8 @@ public class XMLAssertPsychopathXPath2Im
             if (attrSimpleType != null) {
                 List attrAssertList = fXmlSchemaValidator.getAssertionValidator().getAssertsFromSimpleType(attrSimpleType);
                 if (attrAssertList != null) {
-                    boolean isTypeDerivedFromList = ((XSSimpleType) attrSimpleType.getBaseType()).getVariety() == XSSimpleType.VARIETY_LIST;
-                    boolean isTypeDerivedFromUnion = ((XSSimpleType) attrSimpleType.getBaseType()).getVariety() == XSSimpleType.VARIETY_UNION;                
+                    boolean isTypeDerivedFromList = isTypeDerivedFromSTList(attrSimpleType);
+                    boolean isTypeDerivedFromUnion = isTypeDerivedFromSTUnion(attrSimpleType);                
                     for (int assertIdx = 0; assertIdx < attrAssertList.size(); assertIdx++) {
                         XSAssertImpl assertImpl = (XSAssertImpl)attrAssertList.get(assertIdx);
                         assertImpl.setAttrName(attrQname.localpart);
@@ -345,8 +345,8 @@ public class XMLAssertPsychopathXPath2Im
     private void evaluateAssertionsFromASimpleType(QName element, List assertions, String value, Augmentations augs) throws Exception {  
               
         XSSimpleTypeDefinition simpleTypeDefn = (XSSimpleTypeDefinition) ((ElementPSVI) augs.getItem(Constants.ELEMENT_PSVI)).getTypeDefinition();
-        boolean isTypeDerivedFromList = ((XSSimpleType) simpleTypeDefn.getBaseType()).getVariety() == XSSimpleType.VARIETY_LIST;
-        boolean isTypeDerivedFromUnion = ((XSSimpleType) simpleTypeDefn.getBaseType()).getVariety() == XSSimpleType.VARIETY_UNION;
+        boolean isTypeDerivedFromList = isTypeDerivedFromSTList(simpleTypeDefn);
+        boolean isTypeDerivedFromUnion = isTypeDerivedFromSTUnion(simpleTypeDefn);
         
         Vector assertList = (Vector) assertions;
         for (int assertIdx = 0; assertIdx < assertList.size(); assertIdx++) {
@@ -546,8 +546,8 @@ public class XMLAssertPsychopathXPath2Im
                     // reassign value to simple type instance
                     simpleTypeDefn = (XSSimpleTypeDefinition)complexTypeDef.getBaseType(); 
                 }
-                boolean isTypeDerivedFromList = ((XSSimpleType) simpleTypeDefn.getBaseType()).getVariety() == XSSimpleType.VARIETY_LIST;
-                boolean isTypeDerivedFromUnion = ((XSSimpleType) simpleTypeDefn.getBaseType()).getVariety() == XSSimpleType.VARIETY_UNION;
+                boolean isTypeDerivedFromList = isTypeDerivedFromSTList(simpleTypeDefn);
+                boolean isTypeDerivedFromUnion = isTypeDerivedFromSTUnion(simpleTypeDefn);
                 restorePsviInfoForXPathContext(elemPsvi);
                 evaluateOneAssertionFromSimpleType(element, value, augs, simpleTypeDefn, isTypeDerivedFromList, isTypeDerivedFromUnion, assertImpl, false, null);
                 savePsviInfoWithUntypingOfAssertRoot(elemPsvi, true);
@@ -813,4 +813,20 @@ public class XMLAssertPsychopathXPath2Im
         
     } // class AssertionError
     
+
+    /*
+     * Check if a simple type definition has a base type whose variety is simpleType->list.
+     */
+    private boolean isTypeDerivedFromSTList(XSSimpleTypeDefinition simpleTypeDefn) {
+        return ((XSSimpleType) simpleTypeDefn.getBaseType()).getVariety() == XSSimpleType.VARIETY_LIST;
+    }
+    
+    
+    /*
+     * Check if a simple type definition has a base type whose variety is simpleType->union.
+     */
+    private boolean isTypeDerivedFromSTUnion(XSSimpleTypeDefinition simpleTypeDefn) {
+        return ((XSSimpleType) simpleTypeDefn.getBaseType()).getVariety() == XSSimpleType.VARIETY_UNION;
+    }
+    
 } // class XMLAssertPsychopathXPath2Impl



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