Author: veithen
Date: Thu Oct 20 22:08:03 2011
New Revision: 1187095
URL: http://svn.apache.org/viewvc?rev=1187095&view=rev
Log:
AXIOM-114: Added a method to OMElement that allows to get an XMLStreamReader
that strictly preserves the namespace context (by generating additional
namespace declarations on the root START_ELEMENT event).
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithPreserveNamespaceContext.java
(with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/org/apache/axiom/ts/om/element/
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/org/apache/axiom/ts/om/element/AXIOM-114.xml
(with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMStAXWrapper.java
webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/SwitchingWrapper.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/OMTestSuiteBuilder.java
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=1187095&r1=1187094&r2=1187095&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 Oct 20 22:08:03 2011
@@ -20,7 +20,9 @@
package org.apache.axiom.om;
import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
import org.apache.axiom.om.xpath.AXIOMXPath;
@@ -535,4 +537,56 @@ 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>
+ * <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">
+ * <soapenv:Body>
+ * <ns:echo xmlns:ns="urn:test">
+ * <in xsi:type="xsd:string">test</in>
+ * </ns:echo>
+ * </soapenv:Body>
+ * </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);
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMStAXWrapper.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMStAXWrapper.java?rev=1187095&r1=1187094&r2=1187095&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMStAXWrapper.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMStAXWrapper.java
Thu Oct 20 22:08:03 2011
@@ -57,7 +57,7 @@ public class OMStAXWrapper extends Strea
* @param startNode
*/
public OMStAXWrapper(OMXMLParserWrapper builder, OMContainer startNode) {
- this(builder, startNode, false);
+ this(builder, startNode, false, false);
}
/**
@@ -66,10 +66,11 @@ public class OMStAXWrapper extends Strea
* @param builder
* @param startNode
* @param cache
+ * @param preserveNamespaceContext
*/
public OMStAXWrapper(OMXMLParserWrapper builder, OMContainer startNode,
- boolean cache) {
- switchingWrapper = new SwitchingWrapper(builder, startNode, cache);
+ boolean cache, boolean preserveNamespaceContext) {
+ switchingWrapper = new SwitchingWrapper(builder, startNode, cache,
preserveNamespaceContext);
setParent(switchingWrapper);
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/SwitchingWrapper.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/SwitchingWrapper.java?rev=1187095&r1=1187094&r2=1187095&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/SwitchingWrapper.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/SwitchingWrapper.java
Thu Oct 20 22:08:03 2011
@@ -119,6 +119,13 @@ class SwitchingWrapper extends AbstractX
*/
private final boolean cache;
+ /**
+ * Specifies whether additional namespace declarations should be generated
to preserve the
+ * namespace context. See {@link OMElement#getXMLStreamReader(boolean,
boolean)} for more
+ * information about the meaning of this attribute.
+ */
+ private final boolean preserveNamespaceContext;
+
// namespaceURI interning
// default is false because most XMLStreamReader implementations don't do
interning
// due to performance impacts
@@ -178,15 +185,17 @@ class SwitchingWrapper extends AbstractX
* @param builder
* @param startNode
* @param cache
+ * @param preserveNamespaceContext
*/
public SwitchingWrapper(OMXMLParserWrapper builder, OMContainer startNode,
- boolean cache) {
+ boolean cache, boolean preserveNamespaceContext) {
// create a navigator
this.navigator = new OMNavigator(startNode);
this.builder = builder;
this.rootNode = startNode;
this.cache = cache;
+ this.preserveNamespaceContext = preserveNamespaceContext;
// initiate the next and current nodes
// Note - navigator is written in such a way that it first
@@ -489,22 +498,47 @@ class SwitchingWrapper extends AbstractX
if (namespaceCount == -1) {
namespaceCount = 0;
for (Iterator it =
((OMElement)lastNode).getAllDeclaredNamespaces(); it.hasNext(); ) {
- OMNamespace ns = (OMNamespace)it.next();
- // Axiom internally creates an OMNamespace instance for the
"xml" prefix, even
- // if it is not declared explicitly. Filter this instance out.
- if (!"xml".equals(ns.getPrefix())) {
- if (namespaceCount == namespaces.length) {
- OMNamespace[] newNamespaces = new
OMNamespace[namespaces.length*2];
- System.arraycopy(namespaces, 0, newNamespaces, 0,
namespaces.length);
- namespaces = newNamespaces;
+ addNamespace((OMNamespace)it.next());
+ }
+ if (preserveNamespaceContext && lastNode == rootNode) {
+ OMElement element = (OMElement)lastNode;
+ while (true) {
+ OMContainer container = element.getParent();
+ if (container instanceof OMElement) {
+ element = (OMElement)container;
+ decl: for (Iterator it =
element.getAllDeclaredNamespaces(); it.hasNext(); ) {
+ OMNamespace ns = (OMNamespace)it.next();
+ String prefix = ns.getPrefix();
+ for (int i=0; i<namespaceCount; i++) {
+ if (namespaces[i].getPrefix().equals(prefix)) {
+ continue decl;
+ }
+ }
+ addNamespace(ns);
+ }
+ } else {
+ break;
}
- namespaces[namespaceCount] = ns;
- namespaceCount++;
}
}
}
}
+ private void addNamespace(OMNamespace ns) {
+ // TODO: verify if this check is actually still necessary
+ // Axiom internally creates an OMNamespace instance for the "xml"
prefix, even
+ // if it is not declared explicitly. Filter this instance out.
+ if (!"xml".equals(ns.getPrefix())) {
+ if (namespaceCount == namespaces.length) {
+ OMNamespace[] newNamespaces = new
OMNamespace[namespaces.length*2];
+ System.arraycopy(namespaces, 0, newNamespaces, 0,
namespaces.length);
+ namespaces = newNamespaces;
+ }
+ namespaces[namespaceCount] = ns;
+ namespaceCount++;
+ }
+ }
+
/**
* @param i
* @return Returns String.
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=1187095&r1=1187094&r2=1187095&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 Oct 20 22:08:03 2011
@@ -688,6 +688,10 @@ public abstract class ParentNode extends
}
public XMLStreamReader getXMLStreamReader(boolean cache) {
+ return getXMLStreamReader(cache, false);
+ }
+
+ public XMLStreamReader getXMLStreamReader(boolean cache, boolean
preserveNamespaceContext) {
if ((builder == null) && !cache) {
throw new UnsupportedOperationException(
"This element was not created in a manner to be switched");
@@ -696,7 +700,7 @@ public abstract class ParentNode extends
throw new UnsupportedOperationException(
"The parser is already consumed!");
}
- return new OMStAXWrapper(builder, this, cache);
+ return new OMStAXWrapper(builder, this, cache,
preserveNamespaceContext);
}
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=1187095&r1=1187094&r2=1187095&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 Oct 20 22:08:03 2011
@@ -34,7 +34,7 @@ class OMContainerHelper {
private OMContainerHelper() {}
- public static XMLStreamReader getXMLStreamReader(OMContainer container,
boolean cache) {
+ public static XMLStreamReader getXMLStreamReader(OMContainer container,
boolean cache, boolean preserveNamespaceContext) {
OMXMLParserWrapper builder = ((OMSerializableImpl)container).builder;
if (builder != null && builder instanceof StAXOMBuilder) {
if (!container.isComplete()) {
@@ -48,7 +48,7 @@ class OMContainerHelper {
OMXMLStreamReader reader = null;
boolean done = ((OMSerializableImpl)container).done;
if ((builder == null) && done) {
- reader = new OMStAXWrapper(null, container, false);
+ reader = new OMStAXWrapper(null, container, false,
preserveNamespaceContext);
} else {
if ((builder == null) && !cache) {
throw new UnsupportedOperationException(
@@ -58,7 +58,7 @@ class OMContainerHelper {
throw new UnsupportedOperationException(
"The parser is already consumed!");
}
- reader = new OMStAXWrapper(builder, container, cache);
+ reader = new OMStAXWrapper(builder, container, cache,
preserveNamespaceContext);
}
// 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=1187095&r1=1187094&r2=1187095&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 Oct 20 22:08:03 2011
@@ -341,7 +341,7 @@ public class OMDocumentImpl extends OMSe
}
public XMLStreamReader getXMLStreamReader(boolean cache) {
- return OMContainerHelper.getXMLStreamReader(this, cache);
+ return OMContainerHelper.getXMLStreamReader(this, cache, false);
}
public SAXSource getSAXSource(boolean 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=1187095&r1=1187094&r2=1187095&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 Oct 20 22:08:03 2011
@@ -763,7 +763,11 @@ public class OMElementImpl extends OMNod
}
public XMLStreamReader getXMLStreamReader(boolean cache) {
- return OMContainerHelper.getXMLStreamReader(this, cache);
+ return OMContainerHelper.getXMLStreamReader(this, cache, false);
+ }
+
+ public XMLStreamReader getXMLStreamReader(boolean cache, boolean
preserveNamespaceContext) {
+ return OMContainerHelper.getXMLStreamReader(this, cache,
preserveNamespaceContext);
}
/**
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=1187095&r1=1187094&r2=1187095&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 Oct 20 22:08:03 2011
@@ -495,16 +495,20 @@ public class OMSourcedElementImpl extend
}
public XMLStreamReader getXMLStreamReader(boolean cache) {
+ return getXMLStreamReader(cache, false);
+ }
+
+ public XMLStreamReader getXMLStreamReader(boolean cache, boolean
preserveNamespaceContext) {
if (isDebugEnabled) {
log.debug("getting XMLStreamReader for " + getPrintableName()
+ " with cache=" + cache);
}
if (isExpanded) {
- return super.getXMLStreamReader(cache);
+ return super.getXMLStreamReader(cache, preserveNamespaceContext);
} else {
if (cache && isDestructiveRead()) {
forceExpand();
- return super.getXMLStreamReader();
+ return super.getXMLStreamReader(true,
preserveNamespaceContext);
}
return getDirectReader();
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java?rev=1187095&r1=1187094&r2=1187095&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java
Thu Oct 20 22:08:03 2011
@@ -168,6 +168,7 @@ public class OMTestSuiteBuilder extends
addTest(new
org.apache.axiom.ts.om.element.TestGetXMLStreamReaderOnNonRootElement(metaFactory,
false));
addTest(new
org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithOMSourcedElementDescendant(metaFactory));
addTest(new
org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithoutCachingPartiallyBuilt(metaFactory));
+ addTest(new
org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithPreserveNamespaceContext(metaFactory));
addTest(new
org.apache.axiom.ts.om.element.TestIsCompleteAfterAddingIncompleteChild(metaFactory));
addTest(new
org.apache.axiom.ts.om.element.TestMultipleDefaultNS(metaFactory));
addTest(new
org.apache.axiom.ts.om.element.TestResolveQNameWithDefaultNamespace(metaFactory));
Added:
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=1187095&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithPreserveNamespaceContext.java
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithPreserveNamespaceContext.java
Thu Oct 20 22:08:03 2011
@@ -0,0 +1,54 @@
+/*
+ * 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.ts.om.element;
+
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+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.ts.AxiomTestCase;
+
+/**
+ * Tests the behavior of {@link OMElement#getXMLStreamReader(boolean, boolean)}
+ * with <code>preserveNamespaceContext</code> set to <code>true</code>.
+ */
+public class TestGetXMLStreamReaderWithPreserveNamespaceContext extends
AxiomTestCase {
+ public TestGetXMLStreamReaderWithPreserveNamespaceContext(OMMetaFactory
metaFactory) {
+ super(metaFactory);
+ }
+
+ 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);
+ assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
+ assertEquals(4, reader.getNamespaceCount());
+ Set prefixes = new HashSet();
+ for (int i=0; i<4; i++) {
+ prefixes.add(reader.getNamespacePrefix(i));
+ }
+ assertEquals(new HashSet(Arrays.asList(new String[] { "soapenv",
"xsd", "xsi", "ns"} )), prefixes);
+ }
+}
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithPreserveNamespaceContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/org/apache/axiom/ts/om/element/AXIOM-114.xml
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/org/apache/axiom/ts/om/element/AXIOM-114.xml?rev=1187095&view=auto
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/org/apache/axiom/ts/om/element/AXIOM-114.xml
(added)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/org/apache/axiom/ts/om/element/AXIOM-114.xml
Thu Oct 20 22:08:03 2011
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<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">
+ <soapenv:Body>
+ <ns:echo xmlns:ns="urn:test">
+ <in xsi:type="xsd:string">test</in>
+ </ns:echo>
+ </soapenv:Body>
+</soapenv:Envelope>
Propchange:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/org/apache/axiom/ts/om/element/AXIOM-114.xml
------------------------------------------------------------------------------
svn:eol-style = native