You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2007/01/22 01:29:29 UTC

svn commit: r498500 - in /xerces/java/trunk/src/org/apache/xerces: dom/DeferredDocumentImpl.java parsers/AbstractDOMParser.java

Author: mrglavas
Date: Sun Jan 21 16:29:28 2007
New Revision: 498500

URL: http://svn.apache.org/viewvc?view=rev&rev=498500
Log:
Fixing JIRA Bug #1223:
http://issues.apache.org/jira/browse/XERCESJ-1223

When the type of an element is a union, the [member type definition] will not be available 
until the end of the element (the exception being if the element is empty). When building
a deferred DOM the TypeInfo [1] was being set in startElement. To get the member type it 
needs to be set in endElement. Should be fixed now.

[1] http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo

Modified:
    xerces/java/trunk/src/org/apache/xerces/dom/DeferredDocumentImpl.java
    xerces/java/trunk/src/org/apache/xerces/parsers/AbstractDOMParser.java

Modified: xerces/java/trunk/src/org/apache/xerces/dom/DeferredDocumentImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/dom/DeferredDocumentImpl.java?view=diff&rev=498500&r1=498499&r2=498500
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/DeferredDocumentImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/DeferredDocumentImpl.java Sun Jan 21 16:29:28 2007
@@ -318,7 +318,13 @@
             setChunkValue(fNodeURI, encoding, echunk, eindex);
         }
     }
-
+    
+    // DOM Level 3: sets element TypeInfo
+    public void setTypeInfo(int elementNodeIndex, Object type) {
+        int elementChunk     = elementNodeIndex >> CHUNK_SHIFT;
+        int elementIndex     = elementNodeIndex & CHUNK_MASK;
+        setChunkValue(fNodeValue, type, elementChunk, elementIndex);
+    }
 
     /**
      * DOM Internal 
@@ -357,7 +363,10 @@
     } // createDeferredEntityReference(String):int
 
 
-    /** Creates an element node with a URI in the table and type information. */
+    /** 
+     * Creates an element node with a URI in the table and type information.
+     * @deprecated
+     */
     public int createDeferredElement(String elementURI, String elementName, 
                                       Object type) {
 
@@ -372,7 +381,7 @@
         // return node index
         return elementNodeIndex;
 
-    } // createDeferredElement(String,String):int
+    } // createDeferredElement(String,String,Object):int
 
     /** 
      * Creates an element node in the table.
@@ -383,8 +392,7 @@
     }
 
     /** 
-     * Creates an element node with a URI in the table.
-     * @deprecated  
+     * Creates an element node with a URI in the table. 
      */
     public int createDeferredElement(String elementURI, String elementName) {
 

Modified: xerces/java/trunk/src/org/apache/xerces/parsers/AbstractDOMParser.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/parsers/AbstractDOMParser.java?view=diff&rev=498500&r1=498499&r2=498500
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/parsers/AbstractDOMParser.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/parsers/AbstractDOMParser.java Sun Jan 21 16:29:28 2007
@@ -1044,26 +1044,14 @@
             fCurrentNode = el;
         }
         else {
+            int el = fDeferredDocumentImpl.createDeferredElement (fNamespaceAware ?
+                    element.uri : null, element.rawname);
             Object type = null;
-            if (augs != null) {
-                ElementPSVI elementPSVI = (ElementPSVI)augs.getItem (Constants.ELEMENT_PSVI);
-                if (elementPSVI != null) {
-                    type = elementPSVI.getMemberTypeDefinition ();
-                    if (type == null) {
-                        type = elementPSVI.getTypeDefinition ();
-                    }
-                }
-            }
-
-            int el =
-            fDeferredDocumentImpl.createDeferredElement (fNamespaceAware ?
-            element.uri : null,
-            element.rawname,
-            type);
             int attrCount = attributes.getLength ();
             // Need to loop in reverse order so that the attributes
             // are processed in document order when the DOM is expanded.
             for (int i = attrCount - 1; i >= 0; --i) {
+                
                 // set type information
                 AttributePSVI attrPSVI = (AttributePSVI)attributes.getAugmentations (i).getItem (Constants.ATTRIBUTE_PSVI);
                 boolean id = false;
@@ -1364,8 +1352,21 @@
 
         }
         else {
+            if (augs != null) {
+                ElementPSVI elementPSVI = (ElementPSVI) augs.getItem(Constants.ELEMENT_PSVI);
+                if (elementPSVI != null) {
+                    // Setting TypeInfo. If the declared type is a union the
+                    // [member type definition] will only be available at the
+                    // end of an element.
+                    XSTypeDefinition type = elementPSVI.getMemberTypeDefinition();
+                    if (type == null) {
+                        type = elementPSVI.getTypeDefinition();
+                    }
+                    fDeferredDocumentImpl.setTypeInfo(fCurrentNodeIndex, type);
+                }
+            }
             fCurrentNodeIndex =
-            fDeferredDocumentImpl.getParentNode (fCurrentNodeIndex, false);
+                fDeferredDocumentImpl.getParentNode (fCurrentNodeIndex, false);
         }
 
 



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