You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2012/02/23 20:40:47 UTC

svn commit: r1292920 - in /webservices/commons/trunk/modules/axiom/modules: axiom-api/src/main/java/org/apache/axiom/om/ axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/ axiom-testsuite/src/m...

Author: veithen
Date: Thu Feb 23 19:40:46 2012
New Revision: 1292920

URL: http://svn.apache.org/viewvc?rev=1292920&view=rev
Log:
Refactored the API introduced by AXIOM-114. Adding getXMLStreamReader methods with various arguments is not going to scale well. Instead, introduced an OMXMLStreamReaderConfiguration class that can be used to specify advanced options. That class can be extended more easily.

Note that AXIOM-114 has not been included in any release yet, so that we don't need to preserve the old API.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLStreamReaderConfiguration.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-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMContainerHelper.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/OMSourcedElementImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithPreserveNamespaceContext.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=1292920&r1=1292919&r2=1292920&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 Feb 23 19:40:46 2012
@@ -255,7 +255,7 @@ public interface OMContainer extends OMS
     XMLStreamReader getXMLStreamReaderWithoutCaching();
 
     /**
-     * Get a pull parser representation of this element. This methods creates an
+     * Get a pull parser representation of this information item. 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
@@ -348,11 +348,27 @@ public interface OMContainer extends OMS
      * 
      * @param cache
      *            indicates if caching should be enabled
-     * @return an {@link XMLStreamReader} representation of this element
+     * @return an {@link XMLStreamReader} representation of this information item
      */
     XMLStreamReader getXMLStreamReader(boolean cache);
     
     /**
+     * Get a pull parser representation of this information item. This method is similar to
+     * {@link #getXMLStreamReader(boolean)}, but accepts an {@link OMXMLStreamReaderConfiguration}
+     * object that allows to specify additional options and to customize the behavior of the
+     * returned reader.
+     * 
+     * @param cache
+     *            indicates if caching should be enabled
+     * @param configuration
+     *            additional configuration options; see the Javadoc of
+     *            {@link OMXMLStreamReaderConfiguration} for more information about the available
+     *            options
+     * @return an {@link XMLStreamReader} representation of this information item
+     */
+    XMLStreamReader getXMLStreamReader(boolean cache, OMXMLStreamReaderConfiguration configuration);
+    
+    /**
      * Get a {@link SAXSource} representation for this node. This method can be used to integrate
      * Axiom with APIs and third party libraries that don't support StAX. In particular it can be
      * used with the {@link Transformer} API.

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=1292920&r1=1292919&r2=1292920&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 Feb 23 19:40:46 2012
@@ -21,7 +21,6 @@ package org.apache.axiom.om;
 
 import javax.xml.namespace.NamespaceContext;
 import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
@@ -683,56 +682,4 @@ public interface OMElement extends OMNod
     //       warning when using the method on an OMElement.
     void serializeAndConsume(Writer writer, OMOutputFormat format)
             throws XMLStreamException;
-    
-    /**
-     * Get a pull parser representation of this element, optionally preserving the namespace context
-     * determined by the ancestors of the element. This method is similar to
-     * {@link OMContainer#getXMLStreamReader(boolean)} but supports an additional feature that
-     * allows to strictly preserve the namespace context. When this feature is enabled, the
-     * {@link XMLStreamReader#getNamespaceCount()}, {@link XMLStreamReader#getNamespacePrefix(int)}
-     * and {@link XMLStreamReader#getNamespaceURI(int)} will report additional namespace
-     * declarations for the {@link XMLStreamConstants#START_ELEMENT} event corresponding to the
-     * element on which this method is called, i.e. the root element of the resulting stream. These
-     * namespace declarations correspond to namespaces declared by the ancestors of the element and
-     * that are visible in the context of the element.
-     * <p>
-     * More precisely, if this feature is enabled, then the namespace declarations reported for the
-     * first {@link XMLStreamConstants#START_ELEMENT} event in the returned stream will be the same
-     * as the declarations that would be returned by {@link #getNamespacesInScope()}, with the
-     * exception that a <tt>xmlns=""</tt> declaration present on the element will be preserved.
-     * <p>
-     * This feature is useful for code that relies on the namespace declarations reported by the
-     * {@link XMLStreamReader} to reconstruct the namespace context (instead of using the namespace
-     * context provided by {@link XMLStreamReader#getNamespaceContext()}). An example helps to
-     * illustrate how this works. Consider the following XML message:
-     * 
-     * <pre>
-     * &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
-     *                   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
-     *                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-     *   &lt;soapenv:Body>
-     *     &lt;ns:echo xmlns:ns="urn:test">
-     *       &lt;in xsi:type="xsd:string">test&lt;/in>
-     *     &lt;/ns:echo>
-     *   &lt;/soapenv:Body>
-     * &lt;/soapenv:Envelope>
-     * </pre>
-     * <p>
-     * When {@link OMContainer#getXMLStreamReader(boolean)} is invoked on the {@link OMElement}
-     * corresponding to <tt>ns:echo</tt>, only the namespace declaration for the <tt>ns</tt> prefix
-     * will be reported. This may cause a problem when the caller attempts to resolve the QName
-     * value <tt>xsd:string</tt> of the <tt>xsi:type</tt> attribute. If namespace context
-     * preservation is enabled, then the {@link XMLStreamReader} returned by this method will
-     * generate additional namespace declarations for the <tt>soapenv</tt>, <tt>xsd</tt> and
-     * <tt>xsi</tt> prefixes. They are reported for the {@link XMLStreamConstants#START_ELEMENT}
-     * event representing the <tt>ns:echo</tt> element.
-     * 
-     * @param cache
-     *            indicates if caching should be enabled
-     * @param preserveNamespaceContext
-     *            indicates if additional namespace declarations should be generated to preserve the
-     *            namespace context of the element
-     * @return an {@link XMLStreamReader} representation of this element
-     */
-    XMLStreamReader getXMLStreamReader(boolean cache, boolean preserveNamespaceContext);
 }

Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLStreamReaderConfiguration.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLStreamReaderConfiguration.java?rev=1292920&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLStreamReaderConfiguration.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLStreamReaderConfiguration.java Thu Feb 23 19:40:46 2012
@@ -0,0 +1,91 @@
+/*
+ * 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;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * Defines additional configuration options for
+ * {@link OMContainer#getXMLStreamReader(boolean, OMXMLStreamReaderConfiguration)}.
+ */
+public class OMXMLStreamReaderConfiguration {
+    private boolean preserveNamespaceContext;
+
+    /**
+     * Determines whether strict namespace preservation is enabled. See
+     * {@link #setPreserveNamespaceContext(boolean)} for more information about this option.
+     * 
+     * @return the current value of this option
+     */
+    public boolean isPreserveNamespaceContext() {
+        return preserveNamespaceContext;
+    }
+
+    /**
+     * Specify whether the namespace context determined by the ancestors of the element should be
+     * preserved. This option only applies to {@link OMElement} instances and is disabled by
+     * default.
+     * <p>
+     * When this option is enabled, the {@link XMLStreamReader#getNamespaceCount()},
+     * {@link XMLStreamReader#getNamespacePrefix(int)} and
+     * {@link XMLStreamReader#getNamespaceURI(int)} will report additional namespace declarations
+     * for the {@link XMLStreamConstants#START_ELEMENT} event corresponding to the element on which
+     * this method is called, i.e. the root element of the resulting stream. These namespace
+     * declarations correspond to namespaces declared by the ancestors of the element and that are
+     * visible in the context of the element.
+     * <p>
+     * More precisely, if this option is enabled, then the namespace declarations reported for the
+     * first {@link XMLStreamConstants#START_ELEMENT} event in the returned stream will be the same
+     * as the declarations that would be returned by {@link #getNamespacesInScope()}, with the
+     * exception that a <tt>xmlns=""</tt> declaration present on the element will be preserved.
+     * <p>
+     * This feature is useful for code that relies on the namespace declarations reported by the
+     * {@link XMLStreamReader} to reconstruct the namespace context (instead of using the namespace
+     * context provided by {@link XMLStreamReader#getNamespaceContext()}). An example helps to
+     * illustrate how this works. Consider the following XML message:
+     * 
+     * <pre>
+     * &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+     *                   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+     *                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+     *   &lt;soapenv:Body>
+     *     &lt;ns:echo xmlns:ns="urn:test">
+     *       &lt;in xsi:type="xsd:string">test&lt;/in>
+     *     &lt;/ns:echo>
+     *   &lt;/soapenv:Body>
+     * &lt;/soapenv:Envelope>
+     * </pre>
+     * <p>
+     * When {@link OMContainer#getXMLStreamReader(boolean)} is invoked on the {@link OMElement}
+     * corresponding to <tt>ns:echo</tt>, only the namespace declaration for the <tt>ns</tt> prefix
+     * will be reported. This may cause a problem when the caller attempts to resolve the QName
+     * value <tt>xsd:string</tt> of the <tt>xsi:type</tt> attribute. If namespace context
+     * preservation is enabled, then the {@link XMLStreamReader} returned by this method will
+     * generate additional namespace declarations for the <tt>soapenv</tt>, <tt>xsd</tt> and
+     * <tt>xsi</tt> prefixes. They are reported for the {@link XMLStreamConstants#START_ELEMENT}
+     * event representing the <tt>ns:echo</tt> element.
+     * 
+     * @param preserveNamespaceContext
+     *            the value to set for this option
+     */
+    public void setPreserveNamespaceContext(boolean preserveNamespaceContext) {
+        this.preserveNamespaceContext = preserveNamespaceContext;
+    }
+}

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

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=1292920&r1=1292919&r2=1292920&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 Feb 23 19:40:46 2012
@@ -29,6 +29,7 @@ import org.apache.axiom.om.OMProcessingI
 import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.OMText;
 import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.OMXMLStreamReaderConfiguration;
 import org.apache.axiom.om.impl.OMContainerEx;
 import org.apache.axiom.om.impl.OMNodeEx;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
@@ -694,10 +695,10 @@ public abstract class ParentNode extends
     }
 
     public XMLStreamReader getXMLStreamReader(boolean cache) {
-        return getXMLStreamReader(cache, false);
+        return getXMLStreamReader(cache, new OMXMLStreamReaderConfiguration());
     }
     
-    public XMLStreamReader getXMLStreamReader(boolean cache, boolean preserveNamespaceContext) {
+    public XMLStreamReader getXMLStreamReader(boolean cache, OMXMLStreamReaderConfiguration configuration) {
         if ((builder == null) && !cache) {
             throw new UnsupportedOperationException(
                     "This element was not created in a manner to be switched");
@@ -706,7 +707,7 @@ public abstract class ParentNode extends
             throw new UnsupportedOperationException(
                     "The parser is already consumed!");
         }
-        return new OMStAXWrapper(builder, this, cache, preserveNamespaceContext);
+        return new OMStAXWrapper(builder, this, cache, configuration.isPreserveNamespaceContext());
     }
 
     public SAXSource getSAXSource(boolean cache) {

Modified: 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=1292920&r1=1292919&r2=1292920&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMContainerHelper.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMContainerHelper.java Thu Feb 23 19:40:46 2012
@@ -23,6 +23,7 @@ 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.OMXMLStreamReaderConfiguration;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.impl.common.OMStAXWrapper;
 import org.apache.axiom.om.util.OMXMLStreamReaderValidator;
@@ -32,9 +33,15 @@ import org.apache.commons.logging.LogFac
 class OMContainerHelper {
     private static final Log log = LogFactory.getLog(OMContainerHelper.class);
     
+    private static final OMXMLStreamReaderConfiguration defaultReaderConfiguration = new OMXMLStreamReaderConfiguration();
+    
     private OMContainerHelper() {}
     
-    public static XMLStreamReader getXMLStreamReader(OMContainer container, boolean cache, boolean preserveNamespaceContext) {
+    public static XMLStreamReader getXMLStreamReader(OMContainer container, boolean cache) {
+        return getXMLStreamReader(container, cache, defaultReaderConfiguration);
+    }
+    
+    public static XMLStreamReader getXMLStreamReader(OMContainer container, boolean cache, OMXMLStreamReaderConfiguration configuration) {
         OMXMLParserWrapper builder = ((OMSerializableImpl)container).builder;
         if (builder != null && builder instanceof StAXOMBuilder) {
             if (!container.isComplete()) {
@@ -48,7 +55,7 @@ class OMContainerHelper {
         OMXMLStreamReader reader = null;
         boolean done = ((OMSerializableImpl)container).done;
         if ((builder == null) && done) {
-            reader =  new OMStAXWrapper(null, container, false, preserveNamespaceContext);
+            reader = new OMStAXWrapper(null, container, false, configuration.isPreserveNamespaceContext());
         } else {
             if ((builder == null) && !cache) {
                 throw new UnsupportedOperationException(
@@ -58,7 +65,7 @@ class OMContainerHelper {
                 throw new UnsupportedOperationException(
                 "The parser is already consumed!");
             }
-            reader = new OMStAXWrapper(builder, container, cache, preserveNamespaceContext);
+            reader = new OMStAXWrapper(builder, container, cache, configuration.isPreserveNamespaceContext());
         }
         
         // If debug is enabled, wrap the OMXMLStreamReader in a validator.

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=1292920&r1=1292919&r2=1292920&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 Feb 23 19:40:46 2012
@@ -26,6 +26,7 @@ import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.OMXMLStreamReaderConfiguration;
 import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
 import org.apache.axiom.om.impl.OMContainerEx;
 import org.apache.axiom.om.impl.OMNodeEx;
@@ -346,7 +347,11 @@ public class OMDocumentImpl extends OMSe
     }
 
     public XMLStreamReader getXMLStreamReader(boolean cache) {
-        return OMContainerHelper.getXMLStreamReader(this, cache, false);
+        return OMContainerHelper.getXMLStreamReader(this, cache);
+    }
+
+    public XMLStreamReader getXMLStreamReader(boolean cache, OMXMLStreamReaderConfiguration configuration) {
+        return OMContainerHelper.getXMLStreamReader(this, cache, configuration);
     }
 
     void notifyChildComplete() {

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=1292920&r1=1292919&r2=1292920&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 Feb 23 19:40:46 2012
@@ -30,6 +30,7 @@ import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.OMText;
 import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.OMXMLStreamReaderConfiguration;
 import org.apache.axiom.om.impl.OMContainerEx;
 import org.apache.axiom.om.impl.OMElementEx;
 import org.apache.axiom.om.impl.OMNodeEx;
@@ -788,11 +789,11 @@ public class OMElementImpl extends OMNod
     }
 
     public XMLStreamReader getXMLStreamReader(boolean cache) {
-        return OMContainerHelper.getXMLStreamReader(this, cache, false);
+        return OMContainerHelper.getXMLStreamReader(this, cache);
     }
 
-    public XMLStreamReader getXMLStreamReader(boolean cache, boolean preserveNamespaceContext) {
-        return OMContainerHelper.getXMLStreamReader(this, cache, preserveNamespaceContext);
+    public XMLStreamReader getXMLStreamReader(boolean cache, OMXMLStreamReaderConfiguration configuration) {
+        return OMContainerHelper.getXMLStreamReader(this, cache, configuration);
     }
 
     /**

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java?rev=1292920&r1=1292919&r2=1292920&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java Thu Feb 23 19:40:46 2012
@@ -31,6 +31,7 @@ import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.OMXMLStreamReaderConfiguration;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.impl.common.OMNamespaceImpl;
 import org.apache.axiom.om.util.StAXUtils;
@@ -462,20 +463,20 @@ public class OMSourcedElementImpl extend
     }
 
     public XMLStreamReader getXMLStreamReader(boolean cache) {
-        return getXMLStreamReader(cache, false);
+        return getXMLStreamReader(cache, new OMXMLStreamReaderConfiguration());
     }
     
-    public XMLStreamReader getXMLStreamReader(boolean cache, boolean preserveNamespaceContext) {
+    public XMLStreamReader getXMLStreamReader(boolean cache, OMXMLStreamReaderConfiguration configuration) {
         if (log.isDebugEnabled()) {
             log.debug("getting XMLStreamReader for " + getPrintableName()
                     + " with cache=" + cache);
         }
         if (isExpanded) {
-            return super.getXMLStreamReader(cache, preserveNamespaceContext);
+            return super.getXMLStreamReader(cache, configuration);
         } else {
             if (cache && isDestructiveRead()) {
                 forceExpand();
-                return super.getXMLStreamReader(true, preserveNamespaceContext);
+                return super.getXMLStreamReader(true, configuration);
             }
             return getDirectReader();
         }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithPreserveNamespaceContext.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithPreserveNamespaceContext.java?rev=1292920&r1=1292919&r2=1292920&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithPreserveNamespaceContext.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithPreserveNamespaceContext.java Thu Feb 23 19:40:46 2012
@@ -28,11 +28,13 @@ import javax.xml.stream.XMLStreamReader;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMXMLStreamReaderConfiguration;
 import org.apache.axiom.ts.AxiomTestCase;
 
 /**
- * Tests the behavior of {@link OMElement#getXMLStreamReader(boolean, boolean)}
- * with <code>preserveNamespaceContext</code> set to <code>true</code>.
+ * Tests the behavior of
+ * {@link OMElement#getXMLStreamReader(boolean, OMXMLStreamReaderConfiguration)} with
+ * {@link OMXMLStreamReaderConfiguration#isPreserveNamespaceContext()} set to <code>true</code>.
  */
 public class TestGetXMLStreamReaderWithPreserveNamespaceContext extends AxiomTestCase {
     public TestGetXMLStreamReaderWithPreserveNamespaceContext(OMMetaFactory metaFactory) {
@@ -42,7 +44,9 @@ public class TestGetXMLStreamReaderWithP
     protected void runTest() throws Throwable {
         InputStream in = TestGetXMLStreamReaderWithPreserveNamespaceContext.class.getResourceAsStream("AXIOM-114.xml");
         OMElement root = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), in).getDocumentElement();
-        XMLStreamReader reader = root.getFirstElement().getFirstElement().getXMLStreamReader(true, true);
+        OMXMLStreamReaderConfiguration configuration = new OMXMLStreamReaderConfiguration();
+        configuration.setPreserveNamespaceContext(true);
+        XMLStreamReader reader = root.getFirstElement().getFirstElement().getXMLStreamReader(true, configuration);
         assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
         assertEquals(4, reader.getNamespaceCount());
         Set prefixes = new HashSet();