use of org.apache.axiom.om.OMProcessingInstruction in project webservices-axiom by apache.
the class TestGetDescendants method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMContainer root = containerFactory.create(factory);
OMElement child1 = factory.createOMElement("child", null, root);
OMProcessingInstruction child2 = factory.createOMProcessingInstruction(root, "test", "data");
OMText grandchild1 = factory.createOMText(child1, "text");
OMComment grandchild2 = factory.createOMComment(child1, "text");
Iterator<? extends OMSerializable> it = root.getDescendants(includeSelf);
if (includeSelf) {
assertThat(it.hasNext()).isTrue();
assertThat(it.next()).isEqualTo(root);
}
assertThat(it.hasNext()).isTrue();
assertThat(it.next()).isEqualTo(child1);
assertThat(it.hasNext()).isTrue();
assertThat(it.next()).isEqualTo(grandchild1);
assertThat(it.hasNext()).isTrue();
assertThat(it.next()).isEqualTo(grandchild2);
assertThat(it.hasNext()).isTrue();
assertThat(it.next()).isEqualTo(child2);
assertThat(it.hasNext()).isFalse();
}
use of org.apache.axiom.om.OMProcessingInstruction in project webservices-axiom by apache.
the class WriteProcessingInstruction2Scenario method validate.
@Override
public void validate(OMElement element, boolean dataHandlersPreserved) throws Throwable {
OMNode child = element.getFirstOMChild();
Assert.assertTrue(child instanceof OMProcessingInstruction);
OMProcessingInstruction pi = (OMProcessingInstruction) child;
Assert.assertEquals("target", pi.getTarget());
Assert.assertEquals("data", pi.getValue());
}
use of org.apache.axiom.om.OMProcessingInstruction in project webservices-axiom by apache.
the class WriteProcessingInstruction1Scenario method validate.
@Override
public void validate(OMElement element, boolean dataHandlersPreserved) throws Throwable {
OMNode child = element.getFirstOMChild();
Assert.assertTrue(child instanceof OMProcessingInstruction);
OMProcessingInstruction pi = (OMProcessingInstruction) child;
Assert.assertEquals("target", pi.getTarget());
Assert.assertEquals("", pi.getValue());
}
use of org.apache.axiom.om.OMProcessingInstruction in project webservices-axiom by apache.
the class OMXMLReader method generateEventsForChildren.
private void generateEventsForChildren(OMContainer parent) throws SAXException {
for (Iterator it = parent.getChildren(); it.hasNext(); ) {
OMNode node = (OMNode) it.next();
switch(node.getType()) {
case OMNode.DTD_NODE:
if (lexicalHandler != null) {
OMDocType doctype = (OMDocType) node;
lexicalHandler.startDTD(doctype.getRootName(), doctype.getPublicId(), doctype.getSystemId());
lexicalHandler.endDTD();
}
break;
case OMNode.ELEMENT_NODE:
generateEvents((OMElement) node);
break;
case OMNode.TEXT_NODE:
generateEvents((OMText) node, false);
break;
case OMNode.SPACE_NODE:
generateEvents((OMText) node, true);
break;
case OMNode.CDATA_SECTION_NODE:
if (lexicalHandler != null) {
lexicalHandler.startCDATA();
}
generateEvents((OMText) node, false);
if (lexicalHandler != null) {
lexicalHandler.endCDATA();
}
break;
case OMNode.COMMENT_NODE:
if (lexicalHandler != null) {
char[] ch = ((OMComment) node).getValue().toCharArray();
lexicalHandler.comment(ch, 0, ch.length);
}
break;
case OMNode.PI_NODE:
OMProcessingInstruction pi = (OMProcessingInstruction) node;
contentHandler.processingInstruction(pi.getTarget(), pi.getValue());
break;
case OMNode.ENTITY_REFERENCE_NODE:
contentHandler.skippedEntity(((OMEntityReference) node).getName());
break;
default:
throw new IllegalStateException("Unrecognized node type " + node.getType());
}
}
}
Aggregations