ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1053837 - in /webservices/commons/trunk/modules/axiom/modules: axiom-api/src/main/java/org/apache/axiom/om/ axiom-api/src/main/java/org/apache/axiom/om/impl/ axiom-api/src/main/java/org/apache/axiom/om/impl/builder/ axiom-api/src/test/java...
Date Thu, 30 Dec 2010 09:55:19 GMT
Author: veithen
Date: Thu Dec 30 09:55:18 2010
New Revision: 1053837

URL: http://svn.apache.org/viewvc?rev=1053837&view=rev
Log:
AXIOM-346: Make it possible to get a pull parser from any OMContainer, not only OMElements. OMDocument now also supports getXMLStreamReader.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/RootWhitespaceFilter.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMContainerHelper.java   (with props)
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMNavigator.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMStAXWrapper.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/SwitchingWrapper.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/OMNavigatorTestBase.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/OMStAXWrapperConformanceTestCase.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/xpath/AXIOMXPathTestBase.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMStAXWrapper.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentTypeImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java?rev=1053837&r1=1053836&r2=1053837&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java Thu Dec 30 09:55:18 2010
@@ -21,6 +21,7 @@ package org.apache.axiom.om;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
 
 import java.io.OutputStream;
 import java.io.Writer;
@@ -175,4 +176,120 @@ public interface OMContainer extends OMS
             throws XMLStreamException;
 
     void buildNext();
+
+    /**
+     * Get a pull parser representation of this element with caching enabled. This method has the
+     * same effect as {@link #getXMLStreamReader(boolean)} with <code>cache</code> set to
+     * <code>true</code>.
+     * 
+     * @return an {@link XMLStreamReader} representation of this element
+     */
+    XMLStreamReader getXMLStreamReader();
+
+    /**
+     * Get a pull parser representation of this element with caching disabled. This method has the
+     * same effect as {@link #getXMLStreamReader(boolean)} with <code>cache</code> set to
+     * <code>false</code>.
+     * 
+     * @return an {@link XMLStreamReader} representation of this element
+     */
+    XMLStreamReader getXMLStreamReaderWithoutCaching();
+
+    /**
+     * Get a pull parser representation of this element. This methods creates an
+     * {@link XMLStreamReader} instance that produces a sequence of StAX events for this element and
+     * its content. The sequence of events is independent of the state of this element and the value
+     * of the <code>cache</code> parameter, but the side effects of calling this method and
+     * consuming the reader are different:
+     * <p>
+     * <table border="2" rules="all" cellpadding="4" cellspacing="0">
+     * <tr>
+     * <th>State</th>
+     * <th><code>cache</code></th>
+     * <th>Side effects</th>
+     * </tr>
+     * <tr>
+     * <td rowspan="2">The element is fully built (or was created programmatically).</td>
+     * <td><code>true</code></td>
+     * <td rowspan="2">No side effects. The reader will synthesize StAX events from the object
+     * model.</td>
+     * </tr>
+     * <tr>
+     * <td><code>false</code></td>
+     * </tr>
+     * <tr>
+     * <td rowspan="2">The element is partially built, i.e. deferred parsing is taking place.</td>
+     * <td><code>true</code></td>
+     * <td>When a StAX event is requested from the reader, it will built the information item (if
+     * necessary) and synthesize the StAX event. If the caller completely consumes the reader, the
+     * element will be completely built. Otherwise it will be partially built.</td>
+     * </tr>
+     * <tr>
+     * <td><code>false</code></td>
+     * <td>The reader will delegate to the underlying parser starting from the event corresponding
+     * to the last information item that has been built. In other words, after synthesizing a number
+     * of events, the reader will switch to delegation mode. An attempt to access the object model
+     * afterwards will result in an error.</td>
+     * </tr>
+     * </table>
+     * <p>
+     * To free any resources associated with the returned reader, the caller MUST invoke the
+     * {@link XMLStreamReader#close()} method.
+     * <p>
+     * The returned reader MAY implement the extension defined by
+     * {@link org.apache.axiom.ext.stax.datahandler.DataHandlerReader} and any binary content will
+     * be reported using this extension. More precisely, if the object model contains an
+     * {@link OMText} instance with {@link OMText#isBinary()} returning <code>true</code> (or
+     * would contain such an instance after it has been fully built), then its data will always be
+     * exposed through this extension.
+     * <p>
+     * The caller MUST NOT make any other assumption about the returned reader, in particular about
+     * its runtime type.
+     * <p>
+     * <b>Note</b> (non normative): For various reasons, existing code based on Axiom versions
+     * prior to 1.2.9 makes assumptions on the returned reader that should no longer be considered
+     * valid:
+     * <ul>
+     * <li>Some code assumes that the returned reader is an instance of
+     * {@link org.apache.axiom.om.impl.OMStAXWrapper}. While it is true that Axiom internally uses
+     * this class to synthesize StAX events, it may wrap this instance in another reader
+     * implementation. E.g. depending on the log level, the reader will be wrapped using
+     * {@link org.apache.axiom.om.util.OMXMLStreamReaderValidator}. This was already the case in
+     * Axiom versions prior to 1.2.9. It should also be noted that instances of
+     * {@link OMSourcedElement} (which extends the present interface) may return a reader that is
+     * not implemented using {@link org.apache.axiom.om.impl.OMStAXWrapper}.</li>
+     * <li>Some code uses the {@link OMXMLStreamReader} interface of the returned reader to switch
+     * off MTOM inlining using {@link OMXMLStreamReader#setInlineMTOM(boolean)}. This has now been
+     * deprecated and it is recommended to use
+     * {@link org.apache.axiom.util.stax.xop.XOPEncodingStreamReader} instead.</li>
+     * <li>Some existing code uses the {@link OMAttachmentAccessor} interface of the returned
+     * reader to fetch attachments using {@link OMAttachmentAccessor#getDataHandler(String)}. There
+     * is no reason anymore to do so:</li>
+     * <ul>
+     * <li>When {@link OMXMLStreamReader#setInlineMTOM(boolean)} is used to disable MTOM inlining,
+     * {@link OMAttachmentAccessor#getDataHandler(String)} must be used to retrieve the binary
+     * content. The fact that this method is deprecated removes the need for this.</li>
+     * <li>In Axiom versions prior to 1.2.9, the sequence of events was inconsistent if the
+     * underlying stream is XOP encoded and caching is disabled (see WSCOMMONS-485). This made it
+     * necessary for the caller to (partially) handle the XOP processing and to use
+     * {@link OMAttachmentAccessor#getDataHandler(String)} to retrieve the binary content. Starting
+     * with 1.2.9 this is no longer be the case: as specified above, the sequence of events is
+     * independent of the state of the object model and the value of the <code>cache</code>
+     * parameter, and all binary content is reported through the
+     * {@link org.apache.axiom.ext.stax.datahandler.DataHandlerReader} extension.</li>
+     * <li>Finally, it should be noted that {@link OMAttachmentAccessor#getDataHandler(String)}
+     * doesn't give access to the attachments in the SwA case (neither in 1.2.9 nor in previous
+     * versions).</li>
+     * </ul>
+     * </ul>
+     * <p>
+     * Code making any of these assumptions should be fixed, so that only {@link XMLStreamReader}
+     * and {@link org.apache.axiom.ext.stax.datahandler.DataHandlerReader} are used (and if
+     * necessary, {@link org.apache.axiom.util.stax.xop.XOPEncodingStreamReader}).
+     * 
+     * @param cache
+     *            indicates if caching should be enabled
+     * @return an {@link XMLStreamReader} representation of this element
+     */
+    XMLStreamReader getXMLStreamReader(boolean cache);
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java?rev=1053837&r1=1053836&r2=1053837&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java Thu Dec 30 09:55:18 2010
@@ -21,7 +21,6 @@ package org.apache.axiom.om;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
 
 import java.io.OutputStream;
 import java.io.Writer;
@@ -293,122 +292,6 @@ public interface OMElement extends OMNod
     OMElement getFirstElement();
 
 
-    /**
-     * Get a pull parser representation of this element with caching enabled. This method has the
-     * same effect as {@link #getXMLStreamReader(boolean)} with <code>cache</code> set to
-     * <code>true</code>.
-     * 
-     * @return an {@link XMLStreamReader} representation of this element
-     */
-    XMLStreamReader getXMLStreamReader();
-
-    /**
-     * Get a pull parser representation of this element with caching disabled. This method has the
-     * same effect as {@link #getXMLStreamReader(boolean)} with <code>cache</code> set to
-     * <code>false</code>.
-     * 
-     * @return an {@link XMLStreamReader} representation of this element
-     */
-    XMLStreamReader getXMLStreamReaderWithoutCaching();
-
-    /**
-     * Get a pull parser representation of this element. This methods creates an
-     * {@link XMLStreamReader} instance that produces a sequence of StAX events for this element and
-     * its content. The sequence of events is independent of the state of this element and the value
-     * of the <code>cache</code> parameter, but the side effects of calling this method and
-     * consuming the reader are different:
-     * <p>
-     * <table border="2" rules="all" cellpadding="4" cellspacing="0">
-     * <tr>
-     * <th>State</th>
-     * <th><code>cache</code></th>
-     * <th>Side effects</th>
-     * </tr>
-     * <tr>
-     * <td rowspan="2">The element is fully built (or was created programmatically).</td>
-     * <td><code>true</code></td>
-     * <td rowspan="2">No side effects. The reader will synthesize StAX events from the object
-     * model.</td>
-     * </tr>
-     * <tr>
-     * <td><code>false</code></td>
-     * </tr>
-     * <tr>
-     * <td rowspan="2">The element is partially built, i.e. deferred parsing is taking place.</td>
-     * <td><code>true</code></td>
-     * <td>When a StAX event is requested from the reader, it will built the information item (if
-     * necessary) and synthesize the StAX event. If the caller completely consumes the reader, the
-     * element will be completely built. Otherwise it will be partially built.</td>
-     * </tr>
-     * <tr>
-     * <td><code>false</code></td>
-     * <td>The reader will delegate to the underlying parser starting from the event corresponding
-     * to the last information item that has been built. In other words, after synthesizing a number
-     * of events, the reader will switch to delegation mode. An attempt to access the object model
-     * afterwards will result in an error.</td>
-     * </tr>
-     * </table>
-     * <p>
-     * To free any resources associated with the returned reader, the caller MUST invoke the
-     * {@link XMLStreamReader#close()} method.
-     * <p>
-     * The returned reader MAY implement the extension defined by
-     * {@link org.apache.axiom.ext.stax.datahandler.DataHandlerReader} and any binary content will
-     * be reported using this extension. More precisely, if the object model contains an
-     * {@link OMText} instance with {@link OMText#isBinary()} returning <code>true</code> (or
-     * would contain such an instance after it has been fully built), then its data will always be
-     * exposed through this extension.
-     * <p>
-     * The caller MUST NOT make any other assumption about the returned reader, in particular about
-     * its runtime type.
-     * <p>
-     * <b>Note</b> (non normative): For various reasons, existing code based on Axiom versions
-     * prior to 1.2.9 makes assumptions on the returned reader that should no longer be considered
-     * valid:
-     * <ul>
-     * <li>Some code assumes that the returned reader is an instance of
-     * {@link org.apache.axiom.om.impl.OMStAXWrapper}. While it is true that Axiom internally uses
-     * this class to synthesize StAX events, it may wrap this instance in another reader
-     * implementation. E.g. depending on the log level, the reader will be wrapped using
-     * {@link org.apache.axiom.om.util.OMXMLStreamReaderValidator}. This was already the case in
-     * Axiom versions prior to 1.2.9. It should also be noted that instances of
-     * {@link OMSourcedElement} (which extends the present interface) may return a reader that is
-     * not implemented using {@link org.apache.axiom.om.impl.OMStAXWrapper}.</li>
-     * <li>Some code uses the {@link OMXMLStreamReader} interface of the returned reader to switch
-     * off MTOM inlining using {@link OMXMLStreamReader#setInlineMTOM(boolean)}. This has now been
-     * deprecated and it is recommended to use
-     * {@link org.apache.axiom.util.stax.xop.XOPEncodingStreamReader} instead.</li>
-     * <li>Some existing code uses the {@link OMAttachmentAccessor} interface of the returned
-     * reader to fetch attachments using {@link OMAttachmentAccessor#getDataHandler(String)}. There
-     * is no reason anymore to do so:</li>
-     * <ul>
-     * <li>When {@link OMXMLStreamReader#setInlineMTOM(boolean)} is used to disable MTOM inlining,
-     * {@link OMAttachmentAccessor#getDataHandler(String)} must be used to retrieve the binary
-     * content. The fact that this method is deprecated removes the need for this.</li>
-     * <li>In Axiom versions prior to 1.2.9, the sequence of events was inconsistent if the
-     * underlying stream is XOP encoded and caching is disabled (see WSCOMMONS-485). This made it
-     * necessary for the caller to (partially) handle the XOP processing and to use
-     * {@link OMAttachmentAccessor#getDataHandler(String)} to retrieve the binary content. Starting
-     * with 1.2.9 this is no longer be the case: as specified above, the sequence of events is
-     * independent of the state of the object model and the value of the <code>cache</code>
-     * parameter, and all binary content is reported through the
-     * {@link org.apache.axiom.ext.stax.datahandler.DataHandlerReader} extension.</li>
-     * <li>Finally, it should be noted that {@link OMAttachmentAccessor#getDataHandler(String)}
-     * doesn't give access to the attachments in the SwA case (neither in 1.2.9 nor in previous
-     * versions).</li>
-     * </ul>
-     * </ul>
-     * <p>
-     * Code making any of these assumptions should be fixed, so that only {@link XMLStreamReader}
-     * and {@link org.apache.axiom.ext.stax.datahandler.DataHandlerReader} are used (and if
-     * necessary, {@link org.apache.axiom.util.stax.xop.XOPEncodingStreamReader}).
-     * 
-     * @param cache
-     *            indicates if caching should be enabled
-     * @return an {@link XMLStreamReader} representation of this element
-     */
-    XMLStreamReader getXMLStreamReader(boolean cache);
-
     /** @param text  */
     void setText(String text);
 

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMNavigator.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMNavigator.java?rev=1053837&r1=1053836&r2=1053837&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMNavigator.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMNavigator.java Thu Dec 30 09:55:18 2010
@@ -22,8 +22,8 @@ package org.apache.axiom.om.impl;
 import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMDocument;
-import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMSerializable;
 import org.apache.axiom.om.OMSourcedElement;
 
 /**
@@ -32,19 +32,19 @@ import org.apache.axiom.om.OMSourcedElem
  */
 public class OMNavigator {
     /** Field node */
-    protected OMNode node;
+    protected OMSerializable node;
 
     /** Field visited */
     private boolean visited;
 
     /** Field next */
-    private OMNode next;
+    private OMSerializable next;
 
     // root is the starting element. Once the navigator comes back to the
     // root, the traversal is terminated
 
     /** Field root */
-    private OMNode root;
+    private OMSerializable root;
 
     /** Field backtracked */
     private boolean backtracked;
@@ -70,7 +70,7 @@ public class OMNavigator {
      *
      * @param node
      */
-    public OMNavigator(OMNode node) {
+    public OMNavigator(OMSerializable node) {
         init(node);
     }
 
@@ -79,7 +79,7 @@ public class OMNavigator {
      *
      * @param node
      */
-    public void init(OMNode node) {
+    public void init(OMSerializable node) {
         next = node;
         root = node;
         backtracked = false;
@@ -96,13 +96,13 @@ public class OMNavigator {
     }
 
     /**
-     * Gets the next node.
-     *
-     * @return Returns OMNode in the sequence of preorder traversal. Note however that an element
-     *         node is treated slightly differently. Once the element is passed it returns the same
-     *         element in the next encounter as well.
+     * Get the next information item.
+     * 
+     * @return the next information item in the sequence of preorder traversal. Note however that a
+     *         container (document or element) is treated slightly differently. Once the container
+     *         is passed it returns the same item in the next encounter as well.
      */
-    public OMNode next() {
+    public OMSerializable getNext() {
         if (next == null) {
             return null;
         }
@@ -121,11 +121,23 @@ public class OMNavigator {
         }
         return node;
     }
+    
+    /**
+     * Get the next node. This method only exists for compatibility with existing code. It may throw
+     * a {@link ClassCastException} if an attempt is made to use it on a navigator that was created
+     * from an {@link OMDocument}.
+     * 
+     * @return the next node
+     * @see #getNext()
+     */
+    public OMNode next() {
+        return (OMNode)getNext();
+    }
 
     /** Private method to encapsulate the searching logic. */
     private void updateNextNode() {
         if (!isLeaf(next) && !visited) {
-            OMNode firstChild = _getFirstChild((OMElement) next);
+            OMNode firstChild = _getFirstChild((OMContainer) next);
             if (firstChild != null) {
                 next = firstChild;
             } else if (next.isComplete()) {
@@ -134,15 +146,20 @@ public class OMNavigator {
                 next = null;
             }
         } else {
-            OMContainer parent = next.getParent();
-            OMNode nextSibling = getNextSibling(next);
-            if (nextSibling != null) {
-                next = nextSibling;
-            } else if ((parent != null) && parent.isComplete() && !(parent instanceof OMDocument)) {
-                next = (OMNode) parent;
-                backtracked = true;
-            } else {
+            if (next instanceof OMDocument) {
                 next = null;
+            } else {
+                OMNode nextNode = (OMNode)next;
+                OMContainer parent = nextNode.getParent();
+                OMNode nextSibling = getNextSibling(nextNode);
+                if (nextSibling != null) {
+                    next = nextSibling;
+                } else if ((parent != null) && parent.isComplete()) {
+                    next = parent;
+                    backtracked = true;
+                } else {
+                    next = null;
+                }
             }
         }
     }
@@ -151,8 +168,8 @@ public class OMNavigator {
      * @param n OMNode
      * @return true if this OMNode should be considered a leaf node
      */
-    private boolean isLeaf(OMNode n) {
-        if (n instanceof OMElement) {
+    private boolean isLeaf(OMSerializable n) {
+        if (n instanceof OMContainer) {
             if (this.isDataSourceALeaf && (n instanceof OMSourcedElement) && n != root) {
                 OMDataSource ds = null;
                 try {
@@ -174,7 +191,7 @@ public class OMNavigator {
      * @param node
      * @return first child or null
      */
-    private OMNode _getFirstChild(OMElement node) {
+    private OMNode _getFirstChild(OMContainer node) {
         if (node instanceof OMSourcedElement) {
             OMNode first = node.getFirstOMChild();
             OMNode sibling = first;

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMStAXWrapper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMStAXWrapper.java?rev=1053837&r1=1053836&r2=1053837&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMStAXWrapper.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMStAXWrapper.java Thu Dec 30 09:55:18 2010
@@ -26,6 +26,7 @@ import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.util.StreamReaderDelegate;
 
 import org.apache.axiom.om.OMAttachmentAccessor;
+import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
@@ -57,7 +58,7 @@ public class OMStAXWrapper extends Strea
      * @param builder
      * @param startNode
      */
-    public OMStAXWrapper(OMXMLParserWrapper builder, OMElement startNode) {
+    public OMStAXWrapper(OMXMLParserWrapper builder, OMContainer startNode) {
         this(builder, startNode, false);
     }
 
@@ -68,7 +69,7 @@ public class OMStAXWrapper extends Strea
      * @param startNode
      * @param cache
      */
-    public OMStAXWrapper(OMXMLParserWrapper builder, OMElement startNode,
+    public OMStAXWrapper(OMXMLParserWrapper builder, OMContainer startNode,
                          boolean cache) {
         switchingWrapper = new SwitchingWrapper(builder, startNode, cache);
         setParent(switchingWrapper);

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/SwitchingWrapper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/SwitchingWrapper.java?rev=1053837&r1=1053836&r2=1053837&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/SwitchingWrapper.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/SwitchingWrapper.java Thu Dec 30 09:55:18 2010
@@ -43,11 +43,14 @@ import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMComment;
 import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.om.OMDocType;
 import org.apache.axiom.om.OMDocument;
 import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMProcessingInstruction;
+import org.apache.axiom.om.OMSerializable;
 import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.OMText;
 import org.apache.axiom.om.OMXMLParserWrapper;
@@ -89,7 +92,7 @@ class SwitchingWrapper extends AbstractX
     private boolean _releaseParserOnClose = false;  // Defaults to legacy behavior, which is keep the reference
 
     /** Field rootNode */
-    private OMNode rootNode;
+    private OMContainer rootNode;
 
     /** Field isFirst */
     private boolean isFirst = true;
@@ -133,18 +136,18 @@ class SwitchingWrapper extends AbstractX
     // returns a null
 
     /** Field nextNode */
-    private OMNode nextNode = null;
+    private OMSerializable nextNode = null;
 
     // holder for the current node. Needs this to generate events from the
     // current node
 
     /** Field currentNode */
-    private OMNode currentNode = null;
+    private OMSerializable currentNode = null;
 
     // needs this to refer to the last known node
 
     /** Field lastNode */
-    private OMNode lastNode = null;
+    private OMSerializable lastNode = null;
 
     /** Track depth to ensure we stop generating events when we are done with the root node. */
     int depth = 0;
@@ -200,15 +203,14 @@ class SwitchingWrapper extends AbstractX
      * @param startNode
      * @param cache
      */
-    public SwitchingWrapper(OMXMLParserWrapper builder, OMElement startNode,
+    public SwitchingWrapper(OMXMLParserWrapper builder, OMContainer startNode,
                             boolean cache) {
 
         // create a navigator
         this.navigator = new OMNavigator(startNode);
         this.builder = builder;
         this.rootNode = startNode;
-        if (rootNode != null && rootNode.getParent() != null &&
-                rootNode.getParent() instanceof OMDocument) {
+        if (rootNode instanceof OMElement && ((OMElement)rootNode).getParent() instanceof OMDocument) {
             needToThrowEndDocument = true;
         }
 
@@ -229,12 +231,20 @@ class SwitchingWrapper extends AbstractX
             }
         } catch(Throwable t) {}
         
-        currentNode = navigator.next();
+        currentNode = navigator.getNext();
         updateNextNode();
         if (resetCache) {
             builder.setCache(cache); 
         }
         switchingAllowed = !cache;
+        
+        if (startNode instanceof OMDocument) {
+            try {
+                next();
+            } catch (XMLStreamException ex) {
+                throw new OMException(ex);
+            }
+        }
     }
 
     /**
@@ -350,6 +360,9 @@ class SwitchingWrapper extends AbstractX
     public int getTextLength() {
         if (parser != null) {
             return parser.getTextLength();
+        } else if (currentEvent == DTD) {
+            // Not sure if that conforms to the StAX spec, but it is what Woodstox does
+            throw new IllegalStateException();
         } else {
             return getTextFromNode().length();
         }
@@ -363,7 +376,10 @@ class SwitchingWrapper extends AbstractX
         if (parser != null) {
             return parser.getTextStart();
         } else {
-            if (hasText()) {
+            if (currentEvent == DTD) {
+                // Not sure if that conforms to the StAX spec, but it is what Woodstox does
+                throw new IllegalStateException();
+            } else if (hasText()) {
                 // getTextCharacters always returns a new char array and the start
                 // index is therefore always 0
                 return 0;
@@ -391,10 +407,15 @@ class SwitchingWrapper extends AbstractX
                 throw new OMStreamingException(e);
             }
         } else {
-            String text = getTextFromNode();
-            int copied = Math.min(length, text.length()-sourceStart);
-            text.getChars(sourceStart, sourceStart + copied, target, targetStart);
-            return copied;
+            if (currentEvent == DTD) {
+                // Not sure if that conforms to the StAX spec, but it is what Woodstox does
+                throw new IllegalStateException();
+            } else {
+                String text = getTextFromNode();
+                int copied = Math.min(length, text.length()-sourceStart);
+                text.getChars(sourceStart, sourceStart + copied, target, targetStart);
+                return copied;
+            }
         }
     }
 
@@ -405,6 +426,9 @@ class SwitchingWrapper extends AbstractX
     public char[] getTextCharacters() {
         if (parser != null) {
             return parser.getTextCharacters();
+        } else if (currentEvent == DTD) {
+            // Not sure if that conforms to the StAX spec, but it is what Woodstox does
+            throw new IllegalStateException();
         } else {
             return getTextFromNode().toCharArray();
         }
@@ -430,6 +454,8 @@ class SwitchingWrapper extends AbstractX
                 return ((OMText)lastNode).getText();
             case COMMENT:
                 return ((OMComment)lastNode).getValue();
+            case DTD:
+                return ((OMDocType)lastNode).getValue();
             default:
                 throw new IllegalStateException();
         }
@@ -1084,7 +1110,7 @@ class SwitchingWrapper extends AbstractX
     /** Method updateNextNode. */
     private void updateNextNode() {
         if (navigator.isNavigable()) {
-            nextNode = navigator.next();
+            nextNode = navigator.getNext();
         } else {
             if (!switchingAllowed) {
                 if (navigator.isCompleted() || builder == null || builder.isCompleted()) {
@@ -1097,7 +1123,7 @@ class SwitchingWrapper extends AbstractX
                 } else {
                     builder.next();
                     navigator.step();
-                    nextNode = navigator.next();
+                    nextNode = navigator.getNext();
                 }
             } else {
                 //at this point check whether the navigator is done
@@ -1123,6 +1149,8 @@ class SwitchingWrapper extends AbstractX
             if (rootNode == currentNode) {
                 if (isFirst) {
                     isFirst = false;
+                } else if (currentEvent == END_DOCUMENT) {
+                    state = DOCUMENT_COMPLETE;
                 } else {
                     state = COMPLETED;
                 }
@@ -1368,40 +1396,36 @@ class SwitchingWrapper extends AbstractX
      * @param node
      * @return Returns int.
      */
-    private int generateEvents(OMNode node) {
+    private int generateEvents(OMSerializable node) {
         if (node == null) {
             if (log.isDebugEnabled()) {
                 log.debug("Node is null...returning END_DOCUMENT");
             }
             return END_DOCUMENT;
         }
-        int nodeType = node.getType();
-        if (nodeType == OMNode.ELEMENT_NODE) {
-            OMElement element = (OMElement) node;
-            return generateElementEvents(element);
+        if (node instanceof OMDocument) {
+            return generateContainerEvents((OMDocument)node, true);
         } else {
-            return nodeType;
+            int nodeType = ((OMNode)node).getType();
+            if (nodeType == OMNode.ELEMENT_NODE) {
+                return generateContainerEvents((OMElement)node, false);
+            } else {
+                return nodeType;
+            }
         }
     }
 
-    /**
-     * Method generateElementEvents.
-     *
-     * @param elt
-     * @return Returns int.
-     */
-    private int generateElementEvents(OMElement elt) {
+    private int generateContainerEvents(OMContainer container, boolean isDocument) {
         if (nodeStack == null) {
             nodeStack = new Stack();
         }
-        int returnValue = START_ELEMENT;
-        if (!nodeStack.isEmpty() && nodeStack.peek().equals(elt)) {
-            returnValue = END_ELEMENT;
+        if (!nodeStack.isEmpty() && nodeStack.peek().equals(container)) {
             nodeStack.pop();
+            return isDocument ? END_DOCUMENT : END_ELEMENT;
         } else {
-            nodeStack.push(elt);
+            nodeStack.push(container);
+            return isDocument ? START_DOCUMENT : START_ELEMENT;
         }
-        return returnValue;
     }
 
     /*
@@ -1440,7 +1464,7 @@ class SwitchingWrapper extends AbstractX
                 parser == null ? null : XMLStreamReaderUtils.getDataHandlerReader(parser);
     }
 
-    private Map getAllNamespaces(OMNode contextNode) {
+    private Map getAllNamespaces(OMSerializable contextNode) {
         if (contextNode == null) {
             return Collections.EMPTY_MAP;
         }
@@ -1448,7 +1472,7 @@ class SwitchingWrapper extends AbstractX
         if (contextNode instanceof OMContainer) {
             context = (OMContainer)contextNode;
         } else {
-            context = contextNode.getParent();
+            context = ((OMNode)contextNode).getParent();
         }
         Map nsMap = new LinkedHashMap();
         while (context != null && !(context instanceof OMDocument)) {

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java?rev=1053837&r1=1053836&r2=1053837&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java Thu Dec 30 09:55:18 2010
@@ -265,6 +265,9 @@ public class StAXOMBuilder extends StAXB
                     case XMLStreamConstants.SPACE:
                         try {
                             lastNode = createOMText(XMLStreamConstants.SPACE);
+                            if (lastNode == null) {
+                                continue;
+                            }
                         } catch (OMHierarchyException ex) {
                             // The OM implementation doesn't allow text nodes at the current
                             // position in the tree. Since it is only whitespace, we can safely

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/OMNavigatorTestBase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/OMNavigatorTestBase.java?rev=1053837&r1=1053836&r2=1053837&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/OMNavigatorTestBase.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/OMNavigatorTestBase.java Thu Dec 30 09:55:18 2010
@@ -22,7 +22,7 @@ package org.apache.axiom.om.impl;
 import org.apache.axiom.om.AbstractTestCase;
 import org.apache.axiom.om.OMConstants;
 import org.apache.axiom.om.OMMetaFactory;
-import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMSerializable;
 import org.apache.axiom.om.TestConstants;
 import org.apache.axiom.om.impl.OMNavigator;
 import org.apache.axiom.om.util.StAXUtils;
@@ -64,7 +64,7 @@ public class OMNavigatorTestBase extends
 
         //now the OM is fully created -> test the navigation
         OMNavigator navigator = new OMNavigator(envelope);
-        OMNode node = null;
+        OMSerializable node = null;
         while (navigator.isNavigable()) {
             node = navigator.next();
             assertNotNull(node);
@@ -75,7 +75,7 @@ public class OMNavigatorTestBase extends
         assertNotNull(envelope);
         //now the OM is not fully created. Try to navigate it
         OMNavigator navigator = new OMNavigator(envelope);
-        OMNode node = null;
+        OMSerializable node = null;
         while (navigator.isNavigable()) {
             node = navigator.next();
             assertNotNull(node);
@@ -87,7 +87,7 @@ public class OMNavigatorTestBase extends
 
         //now the OM is not fully created
         OMNavigator navigator = new OMNavigator(envelope);
-        OMNode node = null;
+        OMSerializable node = null;
         while (!navigator.isCompleted()) {
             if (navigator.isNavigable()) {
                 node = navigator.next();

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/OMStAXWrapperConformanceTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/OMStAXWrapperConformanceTestCase.java?rev=1053837&r1=1053836&r2=1053837&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/OMStAXWrapperConformanceTestCase.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/OMStAXWrapperConformanceTestCase.java Thu Dec 30 09:55:18 2010
@@ -29,7 +29,6 @@ import org.apache.axiom.om.OMMetaFactory
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.util.StAXUtils;
 import org.apache.axiom.testutils.stax.XMLStreamReaderComparator;
-import org.apache.axiom.util.stax.XMLFragmentStreamReader;
 
 /**
  * Test comparing the output of {@link OMStAXWrapper} with that of a native StAX parser.
@@ -52,16 +51,12 @@ public class OMStAXWrapperConformanceTes
         try {
             XMLStreamReader expected = StAXUtils.createXMLStreamReader(in1);
             try {
-                // Skip to document element. Note that nextTag is not appropriate here because
-                // there could be a DTD event.
-                while (expected.next() != XMLStreamReader.START_ELEMENT) {
-                    // just loop
-                }
                 StAXOMBuilder builder = new StAXOMBuilder(omMetaFactory.getOMFactory(),
                         StAXUtils.createXMLStreamReader(in2));
                 try {
-                    XMLStreamReader actual = builder.getDocumentElement().getXMLStreamReader();
-                    new XMLStreamReaderComparator(new XMLFragmentStreamReader(expected), actual).compare();
+                    XMLStreamReader actual = builder.getDocument().getXMLStreamReader();
+                    new XMLStreamReaderComparator(new RootWhitespaceFilter(expected),
+                            new RootWhitespaceFilter(actual)).compare();
                 } finally {
                     builder.close();
                 }

Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/RootWhitespaceFilter.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/RootWhitespaceFilter.java?rev=1053837&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/RootWhitespaceFilter.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/RootWhitespaceFilter.java Thu Dec 30 09:55:18 2010
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.om.impl;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper;
+
+public class RootWhitespaceFilter extends XMLStreamReaderWrapper {
+    private int depth;
+    
+    public RootWhitespaceFilter(XMLStreamReader parent) {
+        super(parent);
+    }
+
+    public int next() throws XMLStreamException {
+        int event;
+        loop: while (true) {
+            event = super.next();
+            switch (event) {
+                case XMLStreamConstants.START_ELEMENT:
+                    depth++;
+                    break loop;
+                case XMLStreamConstants.END_ELEMENT:
+                    depth--;
+                    break loop;
+                case XMLStreamConstants.CHARACTERS:
+                case XMLStreamConstants.SPACE:
+                    if (depth > 0) {
+                        break loop;
+                    } else {
+                        continue loop;
+                    }
+                default:
+                    break loop;
+            }
+        }
+        return event;
+    }
+}
\ No newline at end of file

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/RootWhitespaceFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/xpath/AXIOMXPathTestBase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/xpath/AXIOMXPathTestBase.java?rev=1053837&r1=1053836&r2=1053837&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/xpath/AXIOMXPathTestBase.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/xpath/AXIOMXPathTestBase.java Thu Dec 30 09:55:18 2010
@@ -21,52 +21,17 @@ package org.apache.axiom.om.xpath;
 
 import java.io.InputStream;
 
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
 import org.apache.axiom.om.OMDocument;
 import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.impl.RootWhitespaceFilter;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.util.StAXUtils;
 import org.apache.axiom.test.jaxen.JaxenXPathTestBase;
-import org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper;
 import org.jaxen.Navigator;
 
 public class AXIOMXPathTestBase extends JaxenXPathTestBase {
-    static class RootWhitespaceFilter extends XMLStreamReaderWrapper {
-        private int depth;
-        
-        public RootWhitespaceFilter(XMLStreamReader parent) {
-            super(parent);
-        }
-
-        public int next() throws XMLStreamException {
-            int event;
-            loop: while (true) {
-                event = super.next();
-                switch (event) {
-                    case XMLStreamConstants.START_ELEMENT:
-                        depth++;
-                        break loop;
-                    case XMLStreamConstants.END_ELEMENT:
-                        depth--;
-                        break loop;
-                    case XMLStreamConstants.CHARACTERS:
-                    case XMLStreamConstants.SPACE:
-                        if (depth > 0) {
-                            break loop;
-                        } else {
-                            continue loop;
-                        }
-                    default:
-                        break loop;
-                }
-            }
-            return event;
-        }
-    }
-    
     final OMMetaFactory omMetaFactory;
     
     public AXIOMXPathTestBase(String name, OMMetaFactory omMetaFactory) {

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMStAXWrapper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMStAXWrapper.java?rev=1053837&r1=1053836&r2=1053837&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMStAXWrapper.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMStAXWrapper.java Thu Dec 30 09:55:18 2010
@@ -19,7 +19,7 @@
 
 package org.apache.axiom.om.impl.dom;
 
-import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.OMStAXWrapper;
 
@@ -36,7 +36,7 @@ public class DOMStAXWrapper extends OMSt
      * @param builder
      * @param startNode
      */
-    public DOMStAXWrapper(OMXMLParserWrapper builder, OMElement startNode) {
+    public DOMStAXWrapper(OMXMLParserWrapper builder, OMContainer startNode) {
         super(builder, startNode);
     }
 
@@ -47,7 +47,7 @@ public class DOMStAXWrapper extends OMSt
      * @param startNode
      * @param cache
      */
-    public DOMStAXWrapper(OMXMLParserWrapper builder, OMElement startNode,
+    public DOMStAXWrapper(OMXMLParserWrapper builder, OMContainer startNode,
                           boolean cache) {
         super(builder, startNode, cache);
     }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentTypeImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentTypeImpl.java?rev=1053837&r1=1053836&r2=1053837&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentTypeImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentTypeImpl.java Thu Dec 30 09:55:18 2010
@@ -29,6 +29,8 @@ import org.w3c.dom.DocumentType;
 import org.w3c.dom.NamedNodeMap;
 
 public class DocumentTypeImpl extends ChildNode implements DocumentType, OMDocType {
+    private String value;
+    
     public DocumentTypeImpl(DocumentImpl ownerDocument, OMFactory factory) {
         super(ownerDocument, factory);
         done = true;
@@ -80,9 +82,10 @@ public class DocumentTypeImpl extends Ch
     }
 
     public String getValue() {
-        return null;
+        return value;
     }
 
     public void setValue(String text) {
+        value = text;
     }
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=1053837&r1=1053836&r2=1053837&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java Thu Dec 30 09:55:18 2010
@@ -19,7 +19,6 @@
 
 package org.apache.axiom.om.impl.dom;
 
-
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMConstants;
 import org.apache.axiom.om.OMElement;
@@ -49,7 +48,6 @@ import org.w3c.dom.TypeInfo;
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 import java.io.ByteArrayOutputStream;
 import java.util.ArrayList;
@@ -1119,41 +1117,6 @@ public class ElementImpl extends ParentN
         }
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.apache.axiom.om.OMElement#getXMLStreamReaderWithoutCaching()
-     */
-    public XMLStreamReader getXMLStreamReaderWithoutCaching() {
-        return getXMLStreamReader(false);
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.apache.axiom.om.OMElement#getXMLStreamReader()
-     */
-    public XMLStreamReader getXMLStreamReader() {
-        return getXMLStreamReader(true);
-    }
-
-    /**
-     * getXMLStreamReader
-     *
-     * @return Returns reader.
-     */
-    public XMLStreamReader getXMLStreamReader(boolean cache) {
-        if ((builder == null) && !cache) {
-            throw new UnsupportedOperationException(
-                    "This element was not created in a manner to be switched");
-        }
-        if (builder != null && builder.isCompleted() && !cache) {
-            throw new UnsupportedOperationException(
-                    "The parser is already consumed!");
-        }
-        return new DOMStAXWrapper(builder, this, cache);
-    }
-
     public String toStringWithConsume() throws XMLStreamException {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         this.serializeAndConsume(baos);

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java?rev=1053837&r1=1053836&r2=1053837&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java Thu Dec 30 09:55:18 2010
@@ -42,6 +42,8 @@ import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
 import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+
 import java.util.Iterator;
 
 public abstract class ParentNode extends ChildNode implements OMContainerEx {
@@ -667,4 +669,24 @@ public abstract class ParentNode extends
             addChild(factory.createOMText(textContent));
         }
     }
+
+    public XMLStreamReader getXMLStreamReaderWithoutCaching() {
+        return getXMLStreamReader(false);
+    }
+
+    public XMLStreamReader getXMLStreamReader() {
+        return getXMLStreamReader(true);
+    }
+
+    public XMLStreamReader getXMLStreamReader(boolean cache) {
+        if ((builder == null) && !cache) {
+            throw new UnsupportedOperationException(
+                    "This element was not created in a manner to be switched");
+        }
+        if (builder != null && builder.isCompleted() && !cache) {
+            throw new UnsupportedOperationException(
+                    "The parser is already consumed!");
+        }
+        return new DOMStAXWrapper(builder, this, cache);
+    }
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java?rev=1053837&r1=1053836&r2=1053837&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java Thu Dec 30 09:55:18 2010
@@ -372,6 +372,7 @@ public class OMDOMFactory implements OMF
 
     public OMDocType createOMDocType(OMContainer parent, String content) {
         DocumentTypeImpl docType = new DocumentTypeImpl(this.getDocument(), this);
+        docType.setValue(content);
         parent.addChild(docType);
         return docType;
     }

Added: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMContainerHelper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMContainerHelper.java?rev=1053837&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMContainerHelper.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMContainerHelper.java Thu Dec 30 09:55:18 2010
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.om.impl.llom;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.OMXMLStreamReader;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.util.OMXMLStreamReaderValidator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+class OMContainerHelper {
+    private static final Log log = LogFactory.getLog(OMContainerHelper.class);
+    private static boolean DEBUG_ENABLED = log.isDebugEnabled();
+    
+    private OMContainerHelper() {}
+    
+    public static XMLStreamReader getXMLStreamReader(OMContainer container, boolean cache) {
+        OMXMLParserWrapper builder = ((OMSerializableImpl)container).builder;
+        if (builder != null && builder instanceof StAXOMBuilder) {
+            if (!container.isComplete()) {
+                if (((StAXOMBuilder) builder).isLookahead()) {
+                    container.buildNext();
+                }
+            }
+        }
+        
+        // The om tree was built by hand and is already complete
+        OMXMLStreamReader reader = null;
+        boolean done = ((OMSerializableImpl)container).done;
+        if ((builder == null) && done) {
+            reader =  new OMStAXWrapper(null, container, false);
+        } else {
+            if ((builder == null) && !cache) {
+                throw new UnsupportedOperationException(
+                "This element was not created in a manner to be switched");
+            }
+            if (builder != null && builder.isCompleted() && !cache && !done) {
+                throw new UnsupportedOperationException(
+                "The parser is already consumed!");
+            }
+            reader = new OMStAXWrapper(builder, container, cache);
+        }
+        
+        // If debug is enabled, wrap the OMXMLStreamReader in a validator.
+        // The validator will check for mismatched events to help determine if the OMStAXWrapper
+        // is functioning correctly.  All problems are reported as debug.log messages
+        
+        if (DEBUG_ENABLED) {
+            reader = 
+                new OMXMLStreamReaderValidator(reader, // delegate to actual reader
+                     false); // log problems (true will cause exceptions to be thrown)
+        }
+        
+        return reader;
+    }
+    
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMContainerHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java?rev=1053837&r1=1053836&r2=1053837&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java Thu Dec 30 09:55:18 2010
@@ -36,6 +36,7 @@ import org.apache.axiom.om.impl.traverse
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 import java.util.Iterator;
 
@@ -310,4 +311,16 @@ public class OMDocumentImpl extends OMSe
     public void internalSerialize(XMLStreamWriter writer) throws XMLStreamException {
         internalSerialize(writer, true);
     }
+    
+    public XMLStreamReader getXMLStreamReader() {
+        return getXMLStreamReader(true);
+    }
+
+    public XMLStreamReader getXMLStreamReaderWithoutCaching() {
+        return getXMLStreamReader(false);
+    }
+
+    public XMLStreamReader getXMLStreamReader(boolean cache) {
+        return OMContainerHelper.getXMLStreamReader(this, cache);
+    }
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java?rev=1053837&r1=1053836&r2=1053837&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java Thu Dec 30 09:55:18 2010
@@ -49,7 +49,6 @@ import org.apache.axiom.om.impl.traverse
 import org.apache.axiom.om.impl.util.EmptyIterator;
 import org.apache.axiom.om.impl.util.OMSerializerUtil;
 import org.apache.axiom.om.util.ElementHelper;
-import org.apache.axiom.om.util.OMXMLStreamReaderValidator;
 import org.apache.axiom.om.util.StAXUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -725,65 +724,16 @@ public class OMElementImpl extends OMNod
 
     }
 
-    /**
-     * Method getXMLStreamReader.
-     *
-     * @see OMElement#getXMLStreamReader()
-     */
     public XMLStreamReader getXMLStreamReader() {
         return getXMLStreamReader(true);
     }
 
-    /**
-     * Method getXMLStreamReaderWithoutCaching.
-     *
-     * @see OMElement#getXMLStreamReaderWithoutCaching()
-     */
     public XMLStreamReader getXMLStreamReaderWithoutCaching() {
         return getXMLStreamReader(false);
     }
 
-    /**
-     * Method getXMLStreamReader.
-     *
-     * @return Returns reader.
-     */
     public XMLStreamReader getXMLStreamReader(boolean cache) {
-        if (builder != null && this.builder instanceof StAXOMBuilder) {
-            if (!isComplete()) {
-                if (((StAXOMBuilder) builder).isLookahead()) {
-                    this.buildNext();
-                }
-            }
-        }
-        
-        // The om tree was built by hand and is already complete
-        OMXMLStreamReader reader = null;
-        if ((builder == null) && done) {
-            reader =  new OMStAXWrapper(null, this, false);
-        } else {
-            if ((builder == null) && !cache) {
-                throw new UnsupportedOperationException(
-                "This element was not created in a manner to be switched");
-            }
-            if (builder != null && builder.isCompleted() && !cache && !done) {
-                throw new UnsupportedOperationException(
-                "The parser is already consumed!");
-            }
-            reader = new OMStAXWrapper(builder, this, cache);
-        }
-        
-        // If debug is enabled, wrap the OMXMLStreamReader in a validator.
-        // The validator will check for mismatched events to help determine if the OMStAXWrapper
-        // is functioning correctly.  All problems are reported as debug.log messages
-        
-        if (DEBUG_ENABLED) {
-            reader = 
-                new OMXMLStreamReaderValidator(reader, // delegate to actual reader
-                     false); // log problems (true will cause exceptions to be thrown)
-        }
-        
-        return reader;
+        return OMContainerHelper.getXMLStreamReader(this, cache);
     }
 
     /**

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java?rev=1053837&r1=1053836&r2=1053837&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java Thu Dec 30 09:55:18 2010
@@ -19,7 +19,7 @@
 
 package org.apache.axiom.om.impl.llom;
 
-import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMXMLParserWrapper;
 
 /**
@@ -36,7 +36,7 @@ public class OMStAXWrapper extends org.a
      * @param builder
      * @param startNode
      */
-    public OMStAXWrapper(OMXMLParserWrapper builder, OMElement startNode) {
+    public OMStAXWrapper(OMXMLParserWrapper builder, OMContainer startNode) {
         super(builder, startNode);
     }
 
@@ -47,7 +47,7 @@ public class OMStAXWrapper extends org.a
      * @param startNode
      * @param cache
      */
-    public OMStAXWrapper(OMXMLParserWrapper builder, OMElement startNode,
+    public OMStAXWrapper(OMXMLParserWrapper builder, OMContainer startNode,
                          boolean cache) {
         super(builder, startNode, cache);
     }



Mime
View raw message