Author: veithen
Date: Sun May 12 09:17:04 2013
New Revision: 1481499
URL: http://svn.apache.org/r1481499
Log:
* AXIOM-201: Ensure that getXMLStreamReader expands OMSourcedElements only if
strictly necessary.
* AXIOM-431: Fully support the scenario (getting an XMLStreamReader from a
programmatically created element with an incomplete descendant) with
cache=false.
Modified:
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerHelper.java
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/SwitchingWrapper.java
webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
webservices/axiom/trunk/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java
Modified:
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerHelper.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerHelper.java?rev=1481499&r1=1481498&r2=1481499&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerHelper.java
(original)
+++
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerHelper.java
Sun May 12 09:17:04 2013
@@ -64,10 +64,6 @@ public final class OMContainerHelper {
if ((builder == null) && done) {
reader = new OMStAXWrapper(null, container, cache,
configuration.isPreserveNamespaceContext());
} 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!");
Modified:
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/SwitchingWrapper.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/SwitchingWrapper.java?rev=1481499&r1=1481498&r2=1481499&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/SwitchingWrapper.java
(original)
+++
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/SwitchingWrapper.java
Sun May 12 09:17:04 2013
@@ -896,14 +896,6 @@ class SwitchingWrapper extends AbstractX
private OMNode _getFirstChild(OMContainer node) {
if (cache) {
return node.getFirstOMChild();
- } else if (node.getBuilder() != rootNode.getBuilder()) {
- // TODO: We have a problem if the tree has parts constructed by
different builders; this is related to AXIOM-201 and AXIOM-431
- OMNode first = node.getFirstOMChild();
- OMNode sibling = first;
- while (sibling != null) {
- sibling = sibling.getNextOMSibling();
- }
- return first;
} else {
return ((IContainer)node).getFirstOMChildIfAvailable();
}
@@ -958,7 +950,7 @@ class SwitchingWrapper extends AbstractX
if (nextSibling != null) {
nextNode = nextSibling;
visited = false;
- } else if (parent.isComplete()) {
+ } else if (parent.isComplete() || parent.getBuilder() ==
null) { // TODO: review this condition
nextNode = parent;
visited = true;
} else {
@@ -994,17 +986,19 @@ class SwitchingWrapper extends AbstractX
} else {
container = (OMContainer)node;
}
+ StAXOMBuilder builder =
(StAXOMBuilder)container.getBuilder();
int depth = 1;
- // Find the root node for the builder
+ // Find the root node for the builder (i.e. the topmost
node having the same
+ // builder as the current node)
while (container != rootNode && container instanceof
OMElement) {
- OMElement element = (OMElement)container;
- if (element.getBuilder() != builder) {
+ OMContainer parent =
((OMElement)container).getParent();
+ if (parent.getBuilder() != builder) {
break;
}
- container = element.getParent();
+ container = parent;
depth++;
}
- PullThroughWrapper wrapper = new
PullThroughWrapper(streamSwitch, this, (StAXOMBuilder)builder, container,
((StAXOMBuilder)builder).disableCaching(), depth);
+ PullThroughWrapper wrapper = new
PullThroughWrapper(streamSwitch, this, builder, container,
builder.disableCaching(), depth);
streamSwitch.setParent(wrapper);
node = container;
visited = true;
Modified:
webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java?rev=1481499&r1=1481498&r2=1481499&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
(original)
+++
webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
Sun May 12 09:17:04 2013
@@ -28,7 +28,6 @@ import org.apache.axiom.ts.om.container.
import org.apache.axiom.ts.om.document.TestClone;
import org.apache.axiom.ts.om.document.TestDigest;
import org.apache.axiom.ts.om.element.TestGetChildrenWithName4;
-import
org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithIncompleteDescendant;
import
org.apache.axiom.ts.om.element.TestSerializationWithTwoNonBuiltOMElements;
import org.apache.axiom.ts.om.node.TestInsertSiblingAfterOnChild;
import org.apache.axiom.ts.om.node.TestInsertSiblingBeforeOnChild;
@@ -57,9 +56,6 @@ public class OMImplementationTest extend
// TODO
builder.exclude(TestSerializationWithTwoNonBuiltOMElements.class);
- // TODO: this is not supported yet
- builder.exclude(TestGetXMLStreamReaderWithIncompleteDescendant.class,
"(cache=false)");
-
// TODO: not yet working
builder.exclude(TestGetSAXSourceWithPushOMDataSource.class,
"(|(scenario=writeDataHandler)(scenario=writeDataHandlerProvider))");
// TODO: need to evaluate if the test case is correct
Modified:
webservices/axiom/trunk/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java?rev=1481499&r1=1481498&r2=1481499&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java
(original)
+++
webservices/axiom/trunk/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java
Sun May 12 09:17:04 2013
@@ -27,7 +27,6 @@ import org.apache.axiom.ts.om.builder.Te
import org.apache.axiom.ts.om.container.TestSerialize;
import org.apache.axiom.ts.om.document.TestClone;
import org.apache.axiom.ts.om.document.TestDigest;
-import
org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithIncompleteDescendant;
import org.apache.axiom.ts.om.node.TestInsertSiblingAfterOnChild;
import org.apache.axiom.ts.om.node.TestInsertSiblingBeforeOnChild;
import
org.apache.axiom.ts.om.sourcedelement.TestGetSAXSourceWithPushOMDataSource;
@@ -39,10 +38,6 @@ public class OMImplementationTest extend
builder.exclude(TestInsertSiblingAfterOnChild.class);
builder.exclude(TestInsertSiblingBeforeOnChild.class);
- // TODO: this is not supported yet
- builder.exclude(TestGetXMLStreamReaderWithIncompleteDescendant.class,
"(cache=false)");
-
builder.exclude(org.apache.axiom.ts.om.sourcedelement.TestSerialize.class,
"(&(expand=partially)(serializationStrategy=XMLStreamReader)(cache=false)(serializeParent=true))");
-
// TODO: this case is not working because Axiom generates an XML
declaration
// but uses another charset encoding to serialize the document
builder.exclude(TestSerialize.class,
"(&(file=iso-8859-1.xml)(container=document))");