Author: mukulg
Date: Mon May 30 04:47:00 2011
New Revision: 1128992

URL: http://svn.apache.org/viewvc?rev=1128992&view=rev
Log:
committing implementation of [type alternative] schema 1.1 PSVI property.

Modified:
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/PSVIElementNSImpl.java
    
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/ElementPSVImpl.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
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/alternative/XSTypeAlternativeImpl.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/ElementPSVI.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSTypeAlternative.java

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/PSVIElementNSImpl.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/PSVIElementNSImpl.java?rev=1128992&r1=1128991&r2=1128992&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/PSVIElementNSImpl.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/PSVIElementNSImpl.java
 Mon May 30 04:47:00 2011
@@ -35,6 +35,7 @@ import org.apache.xerces.xs.XSElementDec
 import org.apache.xerces.xs.XSModel;
 import org.apache.xerces.xs.XSNotationDeclaration;
 import org.apache.xerces.xs.XSSimpleTypeDefinition;
+import org.apache.xerces.xs.XSTypeAlternative;
 import org.apache.xerces.xs.XSTypeDefinition;
 import org.apache.xerces.xs.XSValue;
 import org.apache.xerces.xs.datatypes.ObjectList;
@@ -114,6 +115,9 @@ public class PSVIElementNSImpl extends E
     /** failed assertions */
     protected ObjectList fFailedAssertions = null;
     
+    /** type alternative **/
+    protected XSTypeAlternative fTypeAlternative = null;
+    
     //
     // ElementPSVI methods
     //
@@ -300,6 +304,14 @@ public class PSVIElementNSImpl extends E
         return ObjectListImpl.EMPTY_LIST;
     }
     
+    /*
+     * (non-Javadoc)
+     * @see org.apache.xerces.xs.ElementPSVI#getTypeAlternative()
+     */
+    public XSTypeAlternative getTypeAlternative() {
+        return fTypeAlternative;
+    }
+    
     /**
      * Copy PSVI properties from another psvi item.
      * 
@@ -325,8 +337,9 @@ public class PSVIElementNSImpl extends E
         }
         this.fSpecified = elem.getIsSchemaSpecified();
         this.fNil = elem.getNil();
+        this.fTypeAlternative = elem.getTypeAlternative();
         this.fInheritedAttributes = elem.getInheritedAttributes();
-        this.fFailedAssertions = elem.getFailedAssertions();
+        this.fFailedAssertions = elem.getFailedAssertions();        
     }
 
     /* (non-Javadoc)

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=1128992&r1=1128991&r2=1128992&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
 Mon May 30 04:47:00 2011
@@ -450,6 +450,9 @@ 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/ElementPSVImpl.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/ElementPSVImpl.java?rev=1128992&r1=1128991&r2=1128992&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/ElementPSVImpl.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/ElementPSVImpl.java
 Mon May 30 04:47:00 2011
@@ -28,6 +28,7 @@ import org.apache.xerces.xs.XSElementDec
 import org.apache.xerces.xs.XSModel;
 import org.apache.xerces.xs.XSNotationDeclaration;
 import org.apache.xerces.xs.XSSimpleTypeDefinition;
+import org.apache.xerces.xs.XSTypeAlternative;
 import org.apache.xerces.xs.XSTypeDefinition;
 import org.apache.xerces.xs.XSValue;
 import org.apache.xerces.xs.datatypes.ObjectList;
@@ -96,6 +97,9 @@ public class ElementPSVImpl implements E
     /** failed assertions **/
     protected ObjectList fFailedAssertions = null;
     
+    /** type alternative **/
+    protected XSTypeAlternative fTypeAlternative = null;
+    
     public ElementPSVImpl() {}
     
     public ElementPSVImpl(boolean isConstant, ElementPSVI elementPSVI) {
@@ -108,8 +112,9 @@ public class ElementPSVImpl implements E
         fValidationAttempted = elementPSVI.getValidationAttempted();
         fValidity = elementPSVI.getValidity();
         fValidationContext = elementPSVI.getValidationContext();
+        fTypeAlternative = elementPSVI.getTypeAlternative();
         fInheritedAttributes = elementPSVI.getInheritedAttributes();
-        fFailedAssertions = elementPSVI.getFailedAssertions(); 
+        fFailedAssertions = elementPSVI.getFailedAssertions();         
         if (elementPSVI instanceof ElementPSVImpl) {
             final ElementPSVImpl elementPSVIImpl = (ElementPSVImpl) 
elementPSVI;
             fErrors = (elementPSVIImpl.fErrors != null) ?
@@ -353,6 +358,14 @@ public class ElementPSVImpl implements E
         return ObjectListImpl.EMPTY_LIST;
     }
     
+    /*
+     * (non-Javadoc)
+     * @see org.apache.xerces.xs.ElementPSVI#getTypeAlternative()
+     */
+    public XSTypeAlternative getTypeAlternative() {
+        return fTypeAlternative;
+    }
+    
     /**
      * Reset() should be called in validator startElement(..) method.
      */
@@ -367,8 +380,9 @@ public class ElementPSVImpl implements E
         fErrors = null;
         fValidationContext = null;
         fValue.reset();
+        fTypeAlternative = null;
         fInheritedAttributes = null;
-        fFailedAssertions = null;
+        fFailedAssertions = null;        
     }
     
     public void copySchemaInformationTo(ElementPSVImpl target) {

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=1128992&r1=1128991&r2=1128992&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
 Mon May 30 04:47:00 2011
@@ -88,6 +88,7 @@ import org.apache.xerces.xs.XSAttributeU
 import org.apache.xerces.xs.XSConstants;
 import org.apache.xerces.xs.XSObjectList;
 import org.apache.xerces.xs.XSSimpleTypeDefinition;
+import org.apache.xerces.xs.XSTypeAlternative;
 import org.apache.xerces.xs.XSTypeDefinition;
 import org.apache.xerces.xs.datatypes.ObjectList;
 import org.xml.sax.SAXNotRecognizedException;
@@ -1275,6 +1276,9 @@ public class XMLSchemaValidator
     
     /** Failed assertions. */
     private ObjectList fFailedAssertions;
+    
+    /** Type Alternative augmentation information. */
+    private XSTypeAlternative fTypeAlternative;
 
     /** type stack. */
     private XSTypeDefinition[] fTypeStack = new 
XSTypeDefinition[INITIAL_STACK_SIZE];
@@ -2202,10 +2206,12 @@ public class XMLSchemaValidator
 
         //process type alternatives
         if (fTypeAlternativesChecking && fCurrentElemDecl != null) {
-           XSTypeDefinition currentType = 
fTypeAlternativeValidator.getCurrentType(fCurrentElemDecl, element, attributes, 
fInheritableAttrList);           
+           Augmentations typeAltAugs = new AugmentationsImpl();
+           XSTypeDefinition currentType = 
fTypeAlternativeValidator.getCurrentType(fCurrentElemDecl, element, attributes, 
fInheritableAttrList, typeAltAugs);           
            if (currentType != null) {
                fCurrentType = currentType;    
            }
+           fTypeAlternative = 
(XSTypeAlternative)typeAltAugs.getItem(Constants.TYPE_ALTERNATIVE);
         }
 
         // check if we should be ignoring xsi:type on this element
@@ -2449,11 +2455,13 @@ public class XMLSchemaValidator
             // PSVI: add nil
             fCurrentPSVI.fNil = fNil;
             if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
+               // PSVI: add type alternative
+               fCurrentPSVI.fTypeAlternative = fTypeAlternative;
                // PSVI: add inherited attributes
                fInhrAttrCountStack.push(fInheritableAttrList.size());
                fCurrentPSVI.fInheritedAttributes = 
getInheritedAttributesForPSVI();               
                // PSVI: add failed assertions
-               fCurrentPSVI.fFailedAssertions = fFailedAssertions;
+               fCurrentPSVI.fFailedAssertions = fFailedAssertions;             
  
             }
         }                
                 
@@ -2723,13 +2731,16 @@ public class XMLSchemaValidator
             fCurrentPSVI.fNotation = this.fNotation;
             fCurrentPSVI.fValidationContext = this.fValidationRoot;
             fCurrentPSVI.fNil = this.fNil;
-            ObjectList inheritedAttributesForPsvi = null;
-            if (fInhrAttrCountStack.size() > 0) {
-                fInheritableAttrList.setSize(fInhrAttrCountStack.pop());
-                inheritedAttributesForPsvi = getInheritedAttributesForPSVI();
+            if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
+                fCurrentPSVI.fTypeAlternative = this.fTypeAlternative;
+                ObjectList inheritedAttributesForPsvi = null;
+                if (fInhrAttrCountStack.size() > 0) {
+                    fInheritableAttrList.setSize(fInhrAttrCountStack.pop());
+                    inheritedAttributesForPsvi = 
getInheritedAttributesForPSVI();
+                }
+                fCurrentPSVI.fInheritedAttributes = inheritedAttributesForPsvi;
+                fCurrentPSVI.fFailedAssertions = this.fFailedAssertions;
             }
-            fCurrentPSVI.fInheritedAttributes = inheritedAttributesForPsvi;
-            fCurrentPSVI.fFailedAssertions = this.fFailedAssertions;
             // PSVI: validation attempted
             // nothing below or at the same level has none or partial
             // (which means this level is strictly assessed, and all chidren

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=1128992&r1=1128991&r2=1128992&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
 Mon May 30 04:47:00 2011
@@ -19,14 +19,17 @@ 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;
 
 /**
@@ -52,9 +55,10 @@ public class XSDTypeAlternativeValidator
     /*
      * Determine the schema type applicable for an element declaration, using 
type alternative information.
      */
-    public XSTypeDefinition getCurrentType(XSElementDecl currentElemDecl, 
QName element, XMLAttributes attributes, Vector inheritableAttrList) {
+    public XSTypeDefinition getCurrentType(XSElementDecl currentElemDecl, 
QName element, XMLAttributes attributes, Vector inheritableAttrList, 
Augmentations typeAltAugs) {
         
-        XSTypeDefinition currentType = null;        
+        XSTypeDefinition currentType = null; 
+        XSTypeAlternative typeAlternativeAugmentation = null;
         
         XSTypeAlternativeImpl[] typeAlternatives = 
currentElemDecl.getTypeAlternatives();        
         if (typeAlternatives != null) {              
@@ -64,6 +68,7 @@ public class XSDTypeAlternativeValidator
                 Test ctaTest = typeAlternatives[typeAltIdx].getTest();
                 if (ctaTest != null && ctaTest.evaluateTest(element, 
ctaAttributes)) {
                     currentType = 
typeAlternatives[typeAltIdx].getTypeDefinition();
+                    typeAlternativeAugmentation = 
typeAlternatives[typeAltIdx]; 
                     break;
                 }
             }
@@ -72,10 +77,15 @@ public class XSDTypeAlternativeValidator
                 XSTypeAlternativeImpl defType = 
currentElemDecl.getDefaultTypeDefinition();
                 if (defType != null) {
                     currentType = defType.getTypeDefinition();
+                    if (typeAlternativeAugmentation == null) {
+                        typeAlternativeAugmentation = defType;  
+                    }
                 }
             }
         }
         
+        typeAltAugs.putItem(Constants.TYPE_ALTERNATIVE, 
typeAlternativeAugmentation);
+        
         return currentType;
         
     } // getCurrentType

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/alternative/XSTypeAlternativeImpl.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/alternative/XSTypeAlternativeImpl.java?rev=1128992&r1=1128991&r2=1128992&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/alternative/XSTypeAlternativeImpl.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/alternative/XSTypeAlternativeImpl.java
 Mon May 30 04:47:00 2011
@@ -25,7 +25,7 @@ import org.apache.xerces.xs.XSTypeAltern
 import org.apache.xerces.xs.XSTypeDefinition;
 
 /**
- * XML schema type alternative component
+ * XML schema type alternative component.
  * 
  * @xerces.internal
  * 

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/ElementPSVI.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/ElementPSVI.java?rev=1128992&r1=1128991&r2=1128992&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/ElementPSVI.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/ElementPSVI.java
 Mon May 30 04:47:00 2011
@@ -55,5 +55,10 @@ public interface ElementPSVI extends Ite
      * [failed assertions]: failed assertions.
      */
     public ObjectList getFailedAssertions();
+    
+    /**
+     * [type alternative]: type alternative.
+     */
+    public XSTypeAlternative getTypeAlternative();
 
 }

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSTypeAlternative.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSTypeAlternative.java?rev=1128992&r1=1128991&r2=1128992&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSTypeAlternative.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSTypeAlternative.java
 Mon May 30 04:47:00 2011
@@ -19,12 +19,12 @@ package org.apache.xerces.xs;
 
 /**
  * This interface represents the XML schema type alternative
- * component. Tyepe alternative component was first introduced
+ * component. Type alternative component was first introduced
  * in the XML schema structures 1.1 specification as a means
  * of implementing conditional type assignment.
  *  
  * @author Hiranya Jayathilaka, University of Moratuwa
- * @version $Id:$
+ * @version $Id$
  */
 public interface XSTypeAlternative extends XSObject {
 



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

Reply via email to