use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestInsertSiblingAfterFromForeignDocument method runTest.
@Override
protected void runTest() throws Throwable {
DocumentBuilder db = ((DOMMetaFactory) metaFactory).newDocumentBuilderFactory().newDocumentBuilder();
Document document1 = db.newDocument();
Element element1 = document1.createElementNS(null, "element1");
Text text = document1.createTextNode("test");
element1.appendChild(text);
Document document2 = db.newDocument();
Element element2 = document2.createElementNS(null, "element2");
((OMNode) text).insertSiblingAfter((OMElement) element2);
// Assert that the new child is not a copy, but the original element
assertSame(element2, element1.getLastChild());
// Assert that the owner document of element2 was changed
assertSame(document1, element2.getOwnerDocument());
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class WriteEmptyElementScenario method validate.
@Override
public void validate(OMElement element, boolean dataHandlersPreserved) throws Throwable {
OMElement child = element.getFirstElement();
Assert.assertEquals("p", child.getPrefix());
Assert.assertEquals("urn:test", child.getNamespaceURI());
Assert.assertEquals("child", child.getLocalName());
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestRemoveAttributeNSNamespaceDeclaration method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement element = factory.createOMElement("test", null);
element.declareNamespace("urn:test", "ns");
((Element) element).removeAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "ns");
assertFalse(element.getAllDeclaredNamespaces().hasNext());
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class WriteStartElementAutoPrefixScenario method validate.
@Override
public void validate(OMElement element, boolean dataHandlersPreserved) throws Throwable {
OMElement child = element.getFirstElement();
Assert.assertEquals("p", child.getPrefix());
Assert.assertEquals("urn:test", child.getNamespaceURI());
Assert.assertEquals("child", child.getLocalName());
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class SAXResultContentHandler method processAttribute.
@Override
public void processAttribute(String namespaceURI, String localName, String prefix, String value, String type, boolean specified) {
OMElement element = (OMElement) target;
OMNamespace ns;
if (namespaceURI.length() > 0) {
ns = element.findNamespace(namespaceURI, prefix);
if (ns == null) {
throw new OMException("Unbound namespace " + namespaceURI);
}
} else {
ns = null;
}
OMAttribute attr = element.addAttribute(localName, value, ns);
attr.setAttributeType(type);
}
Aggregations