use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestGetName method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement root = factory.createOMElement("root", null);
OMSourcedElement el = factory.createOMElement(new PullOMDataSource("<p:el xmlns:p='urn:ns'>content</p:el>"), "el", factory.createOMNamespace("urn:ns", null));
root.addChild(el);
XMLStreamReader reader = root.getXMLStreamReader();
assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
QName name = reader.getName();
assertEquals("p", name.getPrefix());
assertEquals("urn:ns", name.getNamespaceURI());
assertEquals("el", name.getLocalPart());
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestBase64StreamingWithGetSAXSource method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement elem = factory.createOMElement("test", null);
// Create a data source that would eat up all memory when loaded. If the test
// doesn't fail with an OutOfMemoryError, we know that the OMText implementation
// supports streaming.
DataSource ds = new RandomDataSource(654321L, Runtime.getRuntime().maxMemory());
OMText text = factory.createOMText(new DataHandler(ds), false);
elem.addChild(text);
SAXSource saxSource = elem.getSAXSource(true);
XMLReader xmlReader = saxSource.getXMLReader();
xmlReader.setContentHandler(new Base64Comparator(ds.getInputStream()));
xmlReader.parse(saxSource.getInputSource());
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestAddNamespaces method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement root1 = AXIOMUtil.stringToOM(factory, "<ns1:root xmlns:ns1='urn:ns1'><ns1:child xmlns:ns2='urn:ns2'/></root>");
OMElement root2 = AXIOMUtil.stringToOM(factory, "<root xmlns='urn:ns1'><child xmlns='urn:ns2'>text</child></root>");
AXIOMXPath xpath = new AXIOMXPath("/ns1:root/ns2:child");
xpath.addNamespaces(root1.getFirstElement());
assertEquals("text", xpath.stringValueOf(root2.getParent()));
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestAddNamespaces2 method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement root1 = AXIOMUtil.stringToOM(factory, "<ns:root xmlns:ns='urn:ns1'><ns:child xmlns:ns='urn:ns2'/></root>");
OMElement root2 = AXIOMUtil.stringToOM(factory, "<root xmlns='urn:ns1'><child xmlns='urn:ns2'>text</child></root>");
AXIOMXPath xpath = new AXIOMXPath("//ns:child");
xpath.addNamespaces(root1.getFirstElement());
assertEquals("text", xpath.stringValueOf(root2.getParent()));
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestGetAttributeQName method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement element = factory.createOMElement("test", null);
element.addAttribute("att", "value", factory.createOMNamespace("urn:test", "p"));
assertEquals("p:att", new AXIOMXPath("name(@*)").stringValueOf(element));
}
Aggregations