use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestHasNameWithNamespace method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
String localName = "TestLocalName";
String namespace = "http://ws.apache.org/axis2/ns";
String prefix = "axis2";
OMElement element = factory.createOMElement(localName, namespace, prefix);
assertTrue(element.hasName(new QName(namespace, localName, prefix)));
assertTrue(element.hasName(new QName(namespace, localName, "otherPrefix")));
assertFalse(element.hasName(new QName("http://some.other.org/", localName, prefix)));
assertFalse(element.hasName(new QName(namespace, "otherName", prefix)));
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestGetXMLStreamReaderWithoutCachingPartiallyBuiltModified method runTest.
@Override
protected void runTest() throws Throwable {
OMElement root = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), new StringReader("<root><a/><b/><c/></root>")).getDocumentElement();
OMElement b = root.getFirstChildWithName(new QName("b"));
b.addAttribute("att", "value", null);
assertFalse(b.isComplete());
XMLStreamReader reader = root.getXMLStreamReaderWithoutCaching();
// Skip to the START_ELEMENT event corresponding to b
for (int i = 0; i < 4; i++) {
reader.next();
}
assertEquals(XMLStreamReader.START_ELEMENT, reader.getEventType());
assertEquals("b", reader.getLocalName());
// The previously added attribute must be visible
assertEquals(1, reader.getAttributeCount());
assertEquals("att", reader.getAttributeLocalName(0));
assertEquals("value", reader.getAttributeValue(0));
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestGetQNameWithNamespace method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
String localName = "TestLocalName";
String namespace = "http://ws.apache.org/axis2/ns";
String prefix = "axis2";
OMElement elem = factory.createOMElement(localName, namespace, prefix);
QName qname = elem.getQName();
assertEquals("Localname mismatch", localName, qname.getLocalPart());
assertEquals("Namespace mismatch", namespace, qname.getNamespaceURI());
assertEquals("namespace prefix mismatch", prefix, qname.getPrefix());
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestGetSAXResultWithDTD method runTest.
@Override
protected void runTest() throws Throwable {
OMElement root = metaFactory.getOMFactory().createOMElement("root", null);
SAXResult result = root.getSAXResult();
LexicalHandler lexicalHandler = result.getLexicalHandler();
ContentHandler contentHandler = result.getHandler();
contentHandler.startDocument();
lexicalHandler.startDTD("test", null, "my.dtd");
lexicalHandler.endDTD();
contentHandler.startElement("", "test", "test", new AttributesImpl());
contentHandler.endElement("", "test", "test");
contentHandler.endDocument();
OMNode child = root.getFirstOMChild();
assertTrue(child instanceof OMElement);
assertEquals("test", ((OMElement) child).getLocalName());
}
use of org.apache.axiom.om.OMElement in project webservices-axiom by apache.
the class TestGetSAXSourceIdentityTransformOnFragment method runTest.
@Override
protected void runTest() throws Throwable {
Transformer transformer = xsltImplementation.newTransformerFactory().newTransformer();
OMFactory factory = metaFactory.getOMFactory();
OMElement element = OMXMLBuilderFactory.createOMBuilder(factory, getInput()).getDocumentElement().getFirstElement();
OMDocument outputDocument = factory.createOMDocument();
transformer.transform(element.getSAXSource(cache), outputDocument.getSAXResult());
OMNamespace ns = outputDocument.getOMDocumentElement().findNamespaceURI("p");
assertNotNull(ns);
assertEquals("urn:some:namespace", ns.getNamespaceURI());
element.close(false);
}
Aggregations