Author: mukulg
Date: Tue May 31 04:00:04 2011
New Revision: 1129482

URL: http://svn.apache.org/viewvc?rev=1129482&view=rev
Log:
improving [type alternative] PSVI implementation a little bit. we don't seem to 
need another Augmentations object, just for this need. readjusting the logic a 
little bit has probably made the design for this better.

Modified:
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/Constants.java
    
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/XSDTypeAlternativeValidator.java

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/Constants.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/Constants.java?rev=1129482&r1=1129481&r2=1129482&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/Constants.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/Constants.java
 Tue May 31 04:00:04 2011
@@ -450,9 +450,6 @@ public final class Constants {
     /** Attribute PSVI is stored in augmentations using string 
"ATTRIBUTE_PSVI" */
     public final static String ATTRIBUTE_PSVI = "ATTRIBUTE_PSVI";
     
-    /** [type alternative] PSVI is stored in augmentations using string 
"TYPE_ALTERNATIVE" */
-    public final static String TYPE_ALTERNATIVE = "TYPE_ALTERNATIVE";
-    
     /** 
      * Boolean indicating whether an attribute is declared in the DTD is 
stored 
      * in augmentations using the string "ATTRIBUTE_DECLARED". The absence of 
this

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=1129482&r1=1129481&r2=1129482&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
 Tue May 31 04:00:04 2011
@@ -2206,12 +2206,10 @@ public class XMLSchemaValidator
 
         //process type alternatives
         if (fTypeAlternativesChecking && fCurrentElemDecl != null) {
-           Augmentations typeAltAugs = new AugmentationsImpl();
-           XSTypeDefinition currentType = 
fTypeAlternativeValidator.getCurrentType(fCurrentElemDecl, element, attributes, 
fInheritableAttrList, typeAltAugs);           
-           if (currentType != null) {
-               fCurrentType = currentType;    
+           fTypeAlternative = 
fTypeAlternativeValidator.getTypeAlternative(fCurrentElemDecl, element, 
attributes, fInheritableAttrList);           
+           if (fTypeAlternative != null) {
+               fCurrentType = fTypeAlternative.getTypeDefinition();
            }
-           fTypeAlternative = 
(XSTypeAlternative)typeAltAugs.getItem(Constants.TYPE_ALTERNATIVE);
         }
 
         // check if we should be ignoring xsi:type on this element

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDTypeAlternativeValidator.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDTypeAlternativeValidator.java?rev=1129482&r1=1129481&r2=1129482&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDTypeAlternativeValidator.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDTypeAlternativeValidator.java
 Tue May 31 04:00:04 2011
@@ -19,18 +19,15 @@ package org.apache.xerces.impl.xs;
 
 import java.util.Vector;
 
-import org.apache.xerces.impl.Constants;
 import org.apache.xerces.impl.xs.alternative.Test;
 import org.apache.xerces.impl.xs.alternative.XSTypeAlternativeImpl;
 import org.apache.xerces.impl.xs.util.XSTypeHelper;
 import org.apache.xerces.util.XMLAttributesImpl;
-import org.apache.xerces.xni.Augmentations;
 import org.apache.xerces.xni.QName;
 import org.apache.xerces.xni.XMLAttributes;
 import org.apache.xerces.xs.AttributePSVI;
 import org.apache.xerces.xs.XSAttributeDeclaration;
 import org.apache.xerces.xs.XSTypeAlternative;
-import org.apache.xerces.xs.XSTypeDefinition;
 
 /**
  * An XML Schema validator subcomponent handling "type alternative" processing.
@@ -53,12 +50,11 @@ public class XSDTypeAlternativeValidator
     
     
     /*
-     * Determine the schema type applicable for an element declaration, using 
type alternative information.
+     * Determine the schema type applicable (represented as XSTypeAlternative 
component) for an element declaration, using type alternative information.
      */
-    public XSTypeDefinition getCurrentType(XSElementDecl currentElemDecl, 
QName element, XMLAttributes attributes, Vector inheritableAttrList, 
Augmentations typeAltAugs) {
+    public XSTypeAlternative getTypeAlternative(XSElementDecl currentElemDecl, 
QName element, XMLAttributes attributes, Vector inheritableAttrList) {
         
-        XSTypeDefinition currentType = null; 
-        XSTypeAlternative typeAlternativeAugmentation = null;
+        XSTypeAlternative selectedTypeAlternative = null; 
         
         XSTypeAlternativeImpl[] typeAlternatives = 
currentElemDecl.getTypeAlternatives();        
         if (typeAlternatives != null) {              
@@ -67,28 +63,19 @@ public class XSDTypeAlternativeValidator
             for (int typeAltIdx = 0; typeAltIdx < typeAlternatives.length; 
typeAltIdx++) {
                 Test ctaTest = typeAlternatives[typeAltIdx].getTest();
                 if (ctaTest != null && ctaTest.evaluateTest(element, 
ctaAttributes)) {
-                    currentType = 
typeAlternatives[typeAltIdx].getTypeDefinition();
-                    typeAlternativeAugmentation = 
typeAlternatives[typeAltIdx]; 
+                    selectedTypeAlternative = typeAlternatives[typeAltIdx]; 
                     break;
                 }
             }
-            //if a type is not selected by xs:alternative components, try to 
assign the default type
-            if (currentType == null) {
-                XSTypeAlternativeImpl defType = 
currentElemDecl.getDefaultTypeDefinition();
-                if (defType != null) {
-                    currentType = defType.getTypeDefinition();
-                    if (typeAlternativeAugmentation == null) {
-                        typeAlternativeAugmentation = defType;  
-                    }
-                }
+            //if a type alternative is not selected by xs:alternative 
components, try to assign the default type
+            if (selectedTypeAlternative == null) {
+                selectedTypeAlternative = 
currentElemDecl.getDefaultTypeDefinition();
             }
         }
         
-        typeAltAugs.putItem(Constants.TYPE_ALTERNATIVE, 
typeAlternativeAugmentation);
-        
-        return currentType;
+        return selectedTypeAlternative;
         
-    } // getCurrentType
+    } // getTypeAlternative
     
 
     /*



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

Reply via email to