use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class AxiomTraverser method next.
@Override
public Event next() throws TraverserException {
if (node == null) {
if (root instanceof OMDocument) {
node = ((OMDocument) root).getFirstOMChild();
} else {
node = (OMElement) root;
}
} else if (!visited && node instanceof OMElement) {
OMNode firstChild = ((OMElement) node).getFirstOMChild();
if (firstChild != null) {
node = firstChild;
} else {
visited = true;
}
} else {
OMNode nextSibling = node.getNextOMSibling();
if (node == root) {
return null;
} else if (nextSibling != null) {
node = nextSibling;
visited = false;
} else {
OMContainer parent = node.getParent();
if (parent instanceof OMDocument) {
return null;
} else {
node = (OMElement) parent;
visited = true;
}
}
}
switch(node.getType()) {
case OMNode.DTD_NODE:
return Event.DOCUMENT_TYPE;
case OMNode.ELEMENT_NODE:
return visited ? Event.END_ELEMENT : Event.START_ELEMENT;
case OMNode.TEXT_NODE:
return Event.TEXT;
case OMNode.SPACE_NODE:
return Event.WHITESPACE;
case OMNode.ENTITY_REFERENCE_NODE:
if (expandEntityReferences) {
throw new UnsupportedOperationException();
} else {
return Event.ENTITY_REFERENCE;
}
case OMNode.COMMENT_NODE:
return Event.COMMENT;
case OMNode.CDATA_SECTION_NODE:
return Event.CDATA_SECTION;
case OMNode.PI_NODE:
return Event.PROCESSING_INSTRUCTION;
default:
throw new IllegalStateException();
}
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestWrongParent3 method runTest.
@Override
protected void runTest() throws Throwable {
SOAPFaultDetail parent = soapFactory.createSOAPFaultDetail();
OMElement child1 = soapFactory.createOMElement("child1", null, parent);
SOAPHeaderBlock hb = soapFactory.createSOAPHeaderBlock("MyHeader", soapFactory.createOMNamespace("urn:test", "p"));
try {
child1.insertSiblingBefore(hb);
fail("Expected SOAPProcessingException");
} catch (SOAPProcessingException ex) {
// Expected
}
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestClone method runTest.
@Override
protected void runTest() throws Throwable {
SOAPMessage message = soapFactory.createSOAPMessage();
message.addChild(soapFactory.getDefaultEnvelope());
OMCloneOptions options = new OMCloneOptions();
options.setPreserveModel(preserveModel);
OMInformationItem clone = message.clone(options);
if (preserveModel) {
assertTrue(clone instanceof SOAPMessage);
} else {
assertTrue(clone instanceof OMDocument);
assertFalse(clone instanceof SOAPMessage);
}
OMElement envelope = ((OMDocument) clone).getOMDocumentElement();
if (preserveModel) {
assertTrue(envelope instanceof SOAPEnvelope);
} else {
assertFalse(envelope instanceof SOAPEnvelope);
}
assertEquals("Envelope", envelope.getLocalName());
assertEquals(spec.getEnvelopeNamespaceURI(), envelope.getNamespaceURI());
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestSetOMDocumentElement method runTest.
@Override
protected void runTest() throws Throwable {
SOAPMessage message = soapFactory.createSOAPMessage();
OMElement envelope = soapFactory.getDefaultEnvelope();
message.setOMDocumentElement(envelope);
assertSame(envelope, message.getFirstOMChild());
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestSetOMDocumentElementNonSOAPEnvelope method runTest.
@Override
protected void runTest() throws Throwable {
SOAPMessage message = soapFactory.createSOAPMessage();
OMElement element = soapFactory.createOMElement(new QName("test"));
try {
message.setOMDocumentElement(element);
fail("Expected OMException");
} catch (OMException ex) {
// Expected
}
}
Aggregations