Author: knoaman
Date: Thu Dec 17 21:49:05 2009
New Revision: 891932

URL: http://svn.apache.org/viewvc?rev=891932&view=rev
Log:
update parent information (part of the scope) of local element/attribute 
declarations

Modified:
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeDecl.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSElementDecl.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeGroupTraverser.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAttributeDeclaration.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSElementDeclaration.java

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeDecl.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeDecl.java?rev=891932&r1=891931&r2=891932&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeDecl.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSAttributeDecl.java
 Thu Dec 17 21:49:05 2009
@@ -27,6 +27,7 @@
 import org.apache.xerces.xs.XSComplexTypeDefinition;
 import org.apache.xerces.xs.XSConstants;
 import org.apache.xerces.xs.XSNamespaceItem;
+import org.apache.xerces.xs.XSObject;
 import org.apache.xerces.xs.XSObjectList;
 import org.apache.xerces.xs.XSSimpleTypeDefinition;
 
@@ -58,8 +59,8 @@
     short fConstraintType = XSConstants.VC_NONE;
     // scope
     short fScope = XSConstants.SCOPE_ABSENT;
-    // enclosing complex type, when the scope is local
-    XSComplexTypeDecl fEnclosingCT = null;
+    // enclosing complex type or attribute group definition, when the scope is 
local
+    XSObject fEnclosingParent = null;
     // optional annotations
     XSObjectList fAnnotations = null;    
     // value constraint value
@@ -72,7 +73,7 @@
 
     public void setValues(String name, String targetNamespace,
             XSSimpleType simpleType, short constraintType, short scope,
-            ValidatedInfo valInfo, XSComplexTypeDecl enclosingCT,
+            ValidatedInfo valInfo, XSObject enclosingParent,
             XSObjectList annotations, boolean inheritable) {
         fName = name;
         fTargetNamespace = targetNamespace;
@@ -80,7 +81,7 @@
         fConstraintType = constraintType;
         fScope = scope;
         fDefault = valInfo;
-        fEnclosingCT = enclosingCT;
+        fEnclosingParent = enclosingParent;
         fAnnotations = annotations;
         fInheritable = inheritable;
     }
@@ -145,7 +146,17 @@
      * property.
      */
     public XSComplexTypeDefinition getEnclosingCTDefinition() {
-        return fEnclosingCT;
+        return (fEnclosingParent instanceof XSComplexTypeDecl)
+                    ? (XSComplexTypeDecl)fEnclosingParent : null;
+    }
+
+    /**
+     * Locally scoped declarations are available for use only within the
+     * complex type definition or attribute group definition identified
+     * by the <code>scope</code> property.
+     */
+    public XSObject getParent() {
+        return fEnclosingParent;
     }
 
     /**

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSElementDecl.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSElementDecl.java?rev=891932&r1=891931&r2=891932&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSElementDecl.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSElementDecl.java
 Thu Dec 17 21:49:05 2009
@@ -30,6 +30,7 @@
 import org.apache.xerces.xs.XSElementDeclaration;
 import org.apache.xerces.xs.XSNamedMap;
 import org.apache.xerces.xs.XSNamespaceItem;
+import org.apache.xerces.xs.XSObject;
 import org.apache.xerces.xs.XSObjectList;
 import org.apache.xerces.xs.XSTypeDefinition;
 
@@ -60,8 +61,8 @@
     // misc flag of the element: nillable/abstract/fixed
     short fMiscFlags = 0;
     public short fScope = XSConstants.SCOPE_ABSENT;
-    // enclosing complex type, when the scope is local
-    XSComplexTypeDecl fEnclosingCT = null;
+    // enclosing parent, when the scope is local
+    XSObject fEnclosingParent = null;
     // block set (disallowed substitutions) of the element
     public short fBlock = XSConstants.DERIVATION_NONE;
     // final set (substitution group exclusions) of the element
@@ -105,9 +106,9 @@
     public void setIsGlobal() {
         fScope = SCOPE_GLOBAL;
     }
-    public void setIsLocal(XSComplexTypeDecl enclosingCT) {
+    public void setIsLocal(XSObject enclosingParent) {
         fScope = SCOPE_LOCAL;
-        fEnclosingCT = enclosingCT;
+        fEnclosingParent = enclosingParent;
     }
 
     public void addIDConstraint(IdentityConstraint idc) {
@@ -305,7 +306,17 @@
      * property.
      */
     public XSComplexTypeDefinition getEnclosingCTDefinition() {
-        return fEnclosingCT;
+        return (fEnclosingParent instanceof XSComplexTypeDecl) 
+                    ? (XSComplexTypeDecl)fEnclosingParent : null;
+    }
+
+    /**
+     * Locally scoped declarations are available for use only within the
+     * complex type definition or model group definition identified by the
+     * <code>scope</code> property.
+     */
+    public XSObject getParent() {
+        return fEnclosingParent;
     }
 
     /**

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java?rev=891932&r1=891931&r2=891932&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
 Thu Dec 17 21:49:05 2009
@@ -46,6 +46,7 @@
 import org.apache.xerces.xs.XSAttributeUse;
 import org.apache.xerces.xs.XSConstants;
 import org.apache.xerces.xs.XSMultiValueFacet;
+import org.apache.xerces.xs.XSObject;
 import org.apache.xerces.xs.XSObjectList;
 import org.apache.xerces.xs.XSSimpleTypeDefinition;
 import org.apache.xerces.xs.XSTypeDefinition;
@@ -771,7 +772,7 @@
     //
     Element traverseAttrsAndAttrGrps(Element firstAttr, XSAttributeGroupDecl 
attrGrp,
             XSDocumentInfo schemaDoc, SchemaGrammar grammar,
-            XSComplexTypeDecl enclosingCT) {
+            XSObject enclosingParent) {
         
         Element child=null;
         XSAttributeGroupDecl tempAttrGrp = null;
@@ -785,7 +786,7 @@
                 tempAttrUse = 
fSchemaHandler.fAttributeTraverser.traverseLocal(child,
                         schemaDoc,
                         grammar,
-                        enclosingCT);
+                        enclosingParent);
                 if (tempAttrUse == null) continue;
                 if (tempAttrUse.fUse == SchemaSymbols.USE_PROHIBITED) {
                     attrGrp.addAttributeUse(tempAttrUse);
@@ -798,14 +799,14 @@
                     String idName = attrGrp.addAttributeUse(tempAttrUse);
                     // Only applies to XML Schema 1.0
                     if (fSchemaHandler.fSchemaVersion < 
Constants.SCHEMA_VERSION_1_1 && idName != null) {
-                        String code = (enclosingCT == null) ? 
"ag-props-correct.3" : "ct-props-correct.5";
-                        String name = (enclosingCT == null) ? attrGrp.fName : 
enclosingCT.getName();
+                        String code = (enclosingParent instanceof 
XSAttributeGroupDecl) ? "ag-props-correct.3" : "ct-props-correct.5";
+                        String name = enclosingParent.getName();
                         reportSchemaError(code, new Object[]{name, 
tempAttrUse.fAttrDecl.getName(), idName}, child);
                     }
                 }
                 else if (otherUse != tempAttrUse) {
-                    String code = (enclosingCT == null) ? "ag-props-correct.2" 
: "ct-props-correct.4";
-                    String name = (enclosingCT == null) ? attrGrp.fName : 
enclosingCT.getName();
+                    String code = (enclosingParent instanceof 
XSAttributeGroupDecl) ? "ag-props-correct.2" : "ct-props-correct.4";
+                    String name = enclosingParent.getName();
                     reportSchemaError(code, new Object[]{name, 
tempAttrUse.fAttrDecl.getName()}, child);
                 }
             }
@@ -830,14 +831,14 @@
                         String idName = attrGrp.addAttributeUse(oneAttrUse);
                         // Only applies to XML Schema 1.0
                         if (fSchemaHandler.fSchemaVersion < 
Constants.SCHEMA_VERSION_1_1 && idName != null) {
-                            String code = (enclosingCT == null) ? 
"ag-props-correct.3" : "ct-props-correct.5";
-                            String name = (enclosingCT == null) ? 
attrGrp.fName : enclosingCT.getName();
+                            String code = (enclosingParent instanceof 
XSAttributeGroupDecl) ? "ag-props-correct.3" : "ct-props-correct.5";
+                            String name = enclosingParent.getName();
                             reportSchemaError(code, new Object[]{name, 
oneAttrUse.fAttrDecl.getName(), idName}, child);
                         }
                     }
                     else if (oneAttrUse != otherUse) {
-                        String code = (enclosingCT == null) ? 
"ag-props-correct.2" : "ct-props-correct.4";
-                        String name = (enclosingCT == null) ? attrGrp.fName : 
enclosingCT.getName();
+                        String code = (enclosingParent instanceof 
XSAttributeGroupDecl) ? "ag-props-correct.2" : "ct-props-correct.4";
+                        String name = enclosingParent.getName();
                         reportSchemaError(code, new Object[]{name, 
oneAttrUse.fAttrDecl.getName()}, child);
                     }
                 }
@@ -851,8 +852,8 @@
                         attrGrp.fAttributeWC = fSchemaHandler.fXSConstraints.
                         performIntersectionWith(attrGrp.fAttributeWC, 
tempAttrGrp.fAttributeWC, attrGrp.fAttributeWC.fProcessContents);
                         if (attrGrp.fAttributeWC == null) {
-                            String code = (enclosingCT == null) ? 
"src-attribute_group.2" : "src-ct.4";
-                            String name = (enclosingCT == null) ? 
attrGrp.fName : enclosingCT.getName();
+                            String code = (enclosingParent instanceof 
XSAttributeGroupDecl) ? "src-attribute_group.2" : "src-ct.4";
+                            String name = enclosingParent.getName();
                             reportSchemaError(code, new Object[]{name}, child);
                         }
                     }
@@ -875,8 +876,8 @@
                     attrGrp.fAttributeWC = fSchemaHandler.fXSConstraints.
                     performIntersectionWith(tempAttrWC, attrGrp.fAttributeWC, 
tempAttrWC.fProcessContents);
                     if (attrGrp.fAttributeWC == null) {
-                        String code = (enclosingCT == null) ? 
"src-attribute_group.2" : "src-ct.4";
-                        String name = (enclosingCT == null) ? attrGrp.fName : 
enclosingCT.getName();
+                        String code = (enclosingParent instanceof 
XSAttributeGroupDecl) ? "src-attribute_group.2" : "src-ct.4";
+                        String name = enclosingParent.getName();
                         reportSchemaError(code, new Object[]{name}, child);
                     }
                 }

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeGroupTraverser.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeGroupTraverser.java?rev=891932&r1=891931&r2=891932&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeGroupTraverser.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeGroupTraverser.java
 Thu Dec 17 21:49:05 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.xerces.impl.xs.traversers;
 
+import org.apache.xerces.impl.Constants;
 import org.apache.xerces.impl.xs.SchemaGrammar;
 import org.apache.xerces.impl.xs.SchemaSymbols;
 import org.apache.xerces.impl.xs.XSAnnotationImpl;
@@ -139,7 +140,7 @@
         // Traverse the attribute and attribute group elements and fill in the 
         // attributeGroup structure
         
-        Element nextNode = traverseAttrsAndAttrGrps(child, attrGrp, schemaDoc, 
grammar, null);
+        Element nextNode = traverseAttrsAndAttrGrps(child, attrGrp, schemaDoc, 
grammar,attrGrp);
         if (nextNode!=null) {
             // An invalid element was found...
             Object[] args = new Object [] {nameAttr, "(annotation?, 
((attribute | attributeGroup)*, anyAttribute?))", 
DOMUtil.getLocalName(nextNode)};

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java?rev=891932&r1=891931&r2=891932&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java
 Thu Dec 17 21:49:05 2009
@@ -33,6 +33,7 @@
 import org.apache.xerces.util.XMLSymbols;
 import org.apache.xerces.xni.QName;
 import org.apache.xerces.xs.XSConstants;
+import org.apache.xerces.xs.XSObject;
 import org.apache.xerces.xs.XSObjectList;
 import org.apache.xerces.xs.XSTypeDefinition;
 import org.w3c.dom.Element;
@@ -70,7 +71,7 @@
     protected XSAttributeUseImpl traverseLocal(Element attrDecl,
             XSDocumentInfo schemaDoc,
             SchemaGrammar grammar,
-            XSComplexTypeDecl enclosingCT) {
+            XSObject enclosingParent) {
         
         // General Attribute Checking
         Object[] attrValues = fAttrChecker.checkAttributes(attrDecl, false, 
schemaDoc);
@@ -110,7 +111,7 @@
                 attribute = null;
             }
         } else {
-            attribute = traverseNamedAttr(attrDecl, attrValues, schemaDoc, 
grammar, false, enclosingCT);
+            attribute = traverseNamedAttr(attrDecl, attrValues, schemaDoc, 
grammar, false, enclosingParent);
         }
         
         // get 'value constraint'
@@ -247,7 +248,7 @@
             XSDocumentInfo schemaDoc,
             SchemaGrammar grammar,
             boolean isGlobal,
-            XSComplexTypeDecl enclosingCT) {
+            XSObject enclosingParent) {
         
         String  defaultAtt     = (String) 
attrValues[XSAttributeChecker.ATTIDX_DEFAULT];
         String  fixedAtt       = (String) 
attrValues[XSAttributeChecker.ATTIDX_FIXED];
@@ -272,15 +273,22 @@
         // get 'target namespace'
         String tnsAtt = null;
         XSComplexTypeDecl enclCT = null;
+        XSObject enclParent = null;
         short scope = XSAttributeDecl.SCOPE_ABSENT;
         if (isGlobal) {
             tnsAtt = schemaDoc.fTargetNamespace;
             scope = XSAttributeDecl.SCOPE_GLOBAL;
         }
         else {
-            if (enclosingCT != null) {
-                enclCT = enclosingCT;
-                scope = XSAttributeDecl.SCOPE_LOCAL;
+            if (enclosingParent != null) {
+                if (fSchemaHandler.fSchemaVersion == 
Constants.SCHEMA_VERSION_1_1) {
+                    enclParent = enclosingParent;
+                    scope = XSAttributeDecl.SCOPE_LOCAL;
+                }
+                else if (enclosingParent instanceof XSComplexTypeDecl) {
+                    enclCT = (XSComplexTypeDecl) enclosingParent;
+                    scope = XSAttributeDecl.SCOPE_LOCAL;
+                }
             }
             if (targetNsAtt != null) {
                 // XML Schema 1.1, set the target namespace to be the value of 
the targetNamespace attribute if one is defined
@@ -369,7 +377,7 @@
         }
         
         attribute.setValues(nameAtt, tnsAtt, attrType, constraintType, scope,
-                attDefault, enclCT, annotations, inheritable);
+                attDefault, enclParent, annotations, inheritable);
         
         // Step 3: check against schema for schemas
         
@@ -450,7 +458,7 @@
                 attDefault = null;
                 constraintType = XSConstants.VC_NONE;
                 attribute.setValues(nameAtt, tnsAtt, attrType, constraintType, 
scope,
-                        attDefault, enclCT, annotations, inheritable);
+                        attDefault, enclParent, annotations, inheritable);
             }
         }
         
@@ -464,7 +472,7 @@
                 attDefault = null;
                 constraintType = XSConstants.VC_NONE;
                 attribute.setValues(nameAtt, tnsAtt, attrType, constraintType, 
scope,
-                        attDefault, enclCT, annotations, inheritable);
+                        attDefault, enclParent, annotations, inheritable);
             }
         }
         

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java?rev=891932&r1=891931&r2=891932&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java
 Thu Dec 17 21:49:05 2009
@@ -290,8 +290,12 @@
             element.setIsGlobal();
         }
         else {
-            if (parent instanceof XSComplexTypeDecl)
-                element.setIsLocal((XSComplexTypeDecl)parent);
+            // Sanity check, parent should not be null
+            if (parent != null) {
+                if (parent instanceof XSComplexTypeDecl || 
fSchemaHandler.fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
+                    element.setIsLocal(parent);
+                }
+            }
             
             if (targetNsAtt!=null) {
                 // XML Schema 1.1, set the target namespace to be the value of 
the targetNamespace attribute if one is defined

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAttributeDeclaration.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAttributeDeclaration.java?rev=891932&r1=891931&r2=891932&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAttributeDeclaration.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAttributeDeclaration.java
 Thu Dec 17 21:49:05 2009
@@ -36,11 +36,22 @@
     /**
      * The complex type definition for locally scoped declarations (see 
      * <code>scope</code>), otherwise <code>null</code> if no such 
-     * definition exists. 
+     * definition exists.
+     * 
+     * NOTE: deprecated for XML Schema 1.1
      */
     public XSComplexTypeDefinition getEnclosingCTDefinition();
 
     /**
+     * XML Schema 1.1
+     * 
+     * The complex type definition or attribute group definition for
+     * locally scoped declarations (see  <code>scope</code>), otherwise
+     * <code>null</code> if no such definition exists. 
+     */
+    public XSObject getParent();
+
+    /**
      * Value constraint: one of <code>VC_NONE, VC_DEFAULT, VC_FIXED</code>. 
      */
     public short getConstraintType();

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSElementDeclaration.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSElementDeclaration.java?rev=891932&r1=891931&r2=891932&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSElementDeclaration.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSElementDeclaration.java
 Thu Dec 17 21:49:05 2009
@@ -38,8 +38,19 @@
      * The complex type definition for locally scoped declarations (see 
      * <code>scope</code>), otherwise <code>null</code> if no such 
      * definition exists. 
+     * 
+     * NOTE: deprecated for XML Schema 1.1
      */
     public XSComplexTypeDefinition getEnclosingCTDefinition();
+    
+    /**
+     * XML Schema 1.1
+     *
+     * The complex type definition or model group definition for
+     * locally scoped declarations (see  <code>scope</code>), otherwise
+     * <code>null</code> if no such definition exists.
+     */
+    public XSObject getParent();
 
     /**
      * [Value constraint]: one of <code>VC_NONE, VC_DEFAULT, VC_FIXED</code>. 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to