[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xerces-cvs
Subject:    svn commit: r1086899 - in
From:       mukulg () apache ! org
Date:       2011-03-30 10:33:29
Message-ID: 20110330103329.D6E652388906 () eris ! apache ! org
[Download RAW message or body]

Author: mukulg
Date: Wed Mar 30 10:33:29 2011
New Revision: 1086899

URL: http://svn.apache.org/viewvc?rev=1086899&view=rev
Log:
committing few improvements for inheritable attributes processing.

It seems we should probably have something like following data structures,

XMLAttributes[], or
XMLSchemaValidator -> InheritableAttribute[]

in the field PSVIElementNSImpl -> fInheritedAttributes instead of the present \
XSAttributeUse[] (which only provides the attribute schema component and not the \
attribute value).

This would allow both the attribute QName and it's value for inherited attributes to \
be available in PSVI results after validation episode.

I might attempt above proposed improvement in near future.

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/XSDTypeAlternativeValidator.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/apac \
he/xerces/impl/xs/XMLSchemaValidator.java?rev=1086899&r1=1086898&r2=1086899&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 Mar 30 10:33:29 2011 @@ -2410,22 +2410,7 @@ public class XMLSchemaValidator
         // simple content of an element identifies the parent of the element
         if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
             fIDContext.setCurrentScopeToParent();
-        }
-        
-        // inheritable attributes processing
-        XSAttributeUse[] inheritedAttributesPsvi = null; // for copying into the \
                ElementPSVI
-        if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
-            fInhrAttrCountStack.push(fInheritableAttrList.size());
-            if (fInheritableAttrList.size() > 0) {
-                inheritedAttributesPsvi = new \
                XSAttributeUse[fInheritableAttrList.size()]; 
-                for (int inhrAttrIdx = 0; inhrAttrIdx < fInheritableAttrList.size(); \
                inhrAttrIdx++) {
-                    inheritedAttributesPsvi[inhrAttrIdx] = ((InheritableAttribute) \
                fInheritableAttrList.get(inhrAttrIdx)).getAttributeUse();  
-                }
-            }
-            // find attributes among the attributes of the current element, which \
                are declared inheritable and store them for later processing.
-            // one of the uses of inherited attributes is in type alternatives \
                processing.
-            saveInheritableAttributes(fCurrentElemDecl, attributes);
-        }
+        }                
 
         // call all active identity constraints
         int count = fMatcherStack.getMatcherCount();
@@ -2433,6 +2418,13 @@ public class XMLSchemaValidator
             XPathMatcher matcher = fMatcherStack.getMatcherAt(i);
             matcher.startElement( element, attributes);
         }
+        
+        // inheritable attributes processing
+        XSAttributeUse[] inheritedAttributesForPsvi = null; 
+        if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
+            fInhrAttrCountStack.push(fInheritableAttrList.size());
+            inheritedAttributesForPsvi = getInheritedAttributesForPsvi();
+        }
 
         if (fAugPSVI) {
             augs = getEmptyAugs(augs);
@@ -2447,15 +2439,16 @@ public class XMLSchemaValidator
             fCurrentPSVI.fNotation = fNotation;
             // PSVI: add nil
             fCurrentPSVI.fNil = fNil;
-            if (inheritedAttributesPsvi != null) {
-               // PSVI: add inherited attributes
-               fCurrentPSVI.fInheritedAttributes = inheritedAttributesPsvi;
-            }
-        }
-        
-        // delegate to assertions validator subcomponent
+            // PSVI: add inherited attributes
+            fCurrentPSVI.fInheritedAttributes = inheritedAttributesForPsvi;          \
 +        }                
+                
         if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
+            // find attributes among the attributes of the current element, which \
are declared inheritable and store them for later processing. +            // one of \
the uses of inherited attributes is in type alternatives processing. +            \
saveInheritableAttributes(fCurrentElemDecl, attributes);  try {
+               // delegate to assertions validator subcomponent
                fAssertionValidator.handleStartElement(element, attributes);
             }
             catch(Exception ex) {
@@ -2479,11 +2472,6 @@ public class XMLSchemaValidator
             System.out.println("==>handleEndElement:" + element);
         }
         
-        // inheritable attributes processing
-        if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1 && \
                fInhrAttrCountStack.size() > 0) {
-            fInheritableAttrList.setSize(fInhrAttrCountStack.pop());
-        }
-        
         // if we are skipping, return
         if (fSkipValidationDepth >= 0) {
             // but if this is the top element that we are skipping,
@@ -2614,7 +2602,7 @@ public class XMLSchemaValidator
                 // update PSVI
                 fValidatedInfo.memberType = ((ElementPSVImpl) \
assertAugs.getItem(Constants.ELEMENT_PSVI)).fValue.memberType;                  } 
-            fIsAssertProcessingNeededForSTUnion = true;
+            fIsAssertProcessingNeededForSTUnion = true;            
         }
 
         // Check if we should modify the xsi:type ignore depth
@@ -2681,7 +2669,7 @@ public class XMLSchemaValidator
             fAppendBuffer = false;
             // same here.
             fUnionType = false;
-        }
+        }                
 
         return augs;
     } // handleEndElement(QName,boolean)*/
@@ -2700,6 +2688,12 @@ public class XMLSchemaValidator
             fCurrentPSVI.fNotation = this.fNotation;
             fCurrentPSVI.fValidationContext = this.fValidationRoot;
             fCurrentPSVI.fNil = this.fNil;
+            XSAttributeUse[] inheritedAttributesForPsvi = null;
+            if (fInhrAttrCountStack.size() > 0) {
+                fInheritableAttrList.setSize(fInhrAttrCountStack.pop());
+                inheritedAttributesForPsvi = getInheritedAttributesForPsvi();
+            }
+            fCurrentPSVI.fInheritedAttributes = inheritedAttributesForPsvi;
             // PSVI: validation attempted
             // nothing below or at the same level has none or partial
             // (which means this level is strictly assessed, and all chidren
@@ -4936,4 +4930,18 @@ public class XMLSchemaValidator
        
     } // class InheritableAttribute
     
+    /*
+     * Get inherited attributes for copying into an element PSVI.
+     */
+    private XSAttributeUse[] getInheritedAttributesForPsvi() {        
+        XSAttributeUse[] inheritedAttributes = null; 
+        if (fInheritableAttrList.size() > 0) {
+            inheritedAttributes = new XSAttributeUse[fInheritableAttrList.size()]; 
+            for (int inhrAttrIdx = 0; inhrAttrIdx < fInheritableAttrList.size(); \
inhrAttrIdx++) { +                inheritedAttributes[inhrAttrIdx] = \
((InheritableAttribute) fInheritableAttrList.get(inhrAttrIdx)).getAttributeUse();   + \
}   +        }
+        return inheritedAttributes; 
+    } // getInheritedAttributesForPsvi
+    
 } // class XMLSchemaValidator

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/apac \
he/xerces/impl/xs/XSDTypeAlternativeValidator.java?rev=1086899&r1=1086898&r2=1086899&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 \
Wed Mar 30 10:33:29 2011 @@ -58,7 +58,7 @@ public class XSDTypeAlternativeValidator
         
         XSTypeAlternativeImpl[] typeAlternatives = \
currentElemDecl.getTypeAlternatives();          if (typeAlternatives != null) {       \
                
-            // Construct a list of attributes needed for CTA processing. This \
includes inherited attributes as well. +            // Construct a list of attributes \
                needed for CTA processing. This includes inheritable attributes as \
                well.
             XMLAttributes ctaAttributes = getAttributesForCTA(attributes, \
                inheritableAttrList);
             for (int typeAltIdx = 0; typeAltIdx < typeAlternatives.length; \
typeAltIdx++) {  Test ctaTest = typeAlternatives[typeAltIdx].getTest();
@@ -82,7 +82,7 @@ public class XSDTypeAlternativeValidator
     
 
     /*
-     * Construct a list of attributes, needed for CTA processing. This includes \
inherited attributes as well.   +     * Construct a list of attributes, needed for \
                CTA processing. This includes inheritable attributes as well.  
      */
     private XMLAttributes getAttributesForCTA(XMLAttributes attributes, Vector \
inheritableAttrList) {  
@@ -94,7 +94,7 @@ public class XSDTypeAlternativeValidator
             ctaAttributes.addAttribute(attrQName, attributes.getType(attrIndx), \
attributes.getValue(attrIndx));     }
 
-        // Add inherited attributes to the CTA attributes list
+        // add inherited attributes to the CTA attributes list
         for (int elemIndx = inheritableAttrList.size() - 1; elemIndx > -1; \
                elemIndx--) {        
             InheritableAttribute inhAttr = (InheritableAttribute) \
                inheritableAttrList.elementAt(elemIndx);
             XSAttributeDeclaration inhrAttrDecl = \
inhAttr.getAttributeUse().getAttrDeclaration();



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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic