Search in sources :

Example 36 with OMXMLParserWrapper

use of org.apache.axiom.om.OMXMLParserWrapper in project webservices-axiom by apache.

the class OMAttributeTest method addAttributeMethod1.

private String addAttributeMethod1(String xmlString) throws Exception {
    OMXMLParserWrapper builder2 = OMXMLBuilderFactory.createOMBuilder(new StringReader(xmlString));
    OMElement doc = builder2.getDocumentElement();
    OMFactory factory = OMAbstractFactory.getOMFactory();
    OMNamespace ns = factory.createOMNamespace("http://www.me.com", "axiom");
    //code line to be tested
    OMAttribute at = factory.createOMAttribute("id", ns, "value");
    doc.addAttribute(at);
    return doc.toString();
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMNamespace(org.apache.axiom.om.OMNamespace) StringReader(java.io.StringReader) OMElement(org.apache.axiom.om.OMElement) OMXMLParserWrapper(org.apache.axiom.om.OMXMLParserWrapper) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 37 with OMXMLParserWrapper

use of org.apache.axiom.om.OMXMLParserWrapper in project webservices-axiom by apache.

the class PreserveEnvelopeTest method testOMNS.

public void testOMNS() {
    OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(new StringReader(originalXML));
    OMElement documentElement = builder.getDocumentElement();
    //assertXMLEqual(originalXML, documentElement.toString());
    documentElement.build();
    String outstr = documentElement.toString();
    assertTrue(outstr.indexOf("xmlns:saml=") > 0);
    assertTrue(outstr.indexOf("<Assertion") == 0);
}
Also used : StringReader(java.io.StringReader) OMElement(org.apache.axiom.om.OMElement) OMXMLParserWrapper(org.apache.axiom.om.OMXMLParserWrapper)

Aggregations

OMXMLParserWrapper (org.apache.axiom.om.OMXMLParserWrapper)37 OMElement (org.apache.axiom.om.OMElement)21 StringReader (java.io.StringReader)12 XMLStreamReader (javax.xml.stream.XMLStreamReader)8 OMFactory (org.apache.axiom.om.OMFactory)8 InputSource (org.xml.sax.InputSource)8 OMNode (org.apache.axiom.om.OMNode)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 InputStream (java.io.InputStream)4 QName (javax.xml.namespace.QName)3 OMAttribute (org.apache.axiom.om.OMAttribute)3 OMDocument (org.apache.axiom.om.OMDocument)3 OMOutputFormat (org.apache.axiom.om.OMOutputFormat)3 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)3 DOMSource (javax.xml.transform.dom.DOMSource)2 SAXSource (javax.xml.transform.sax.SAXSource)2 NodeUnavailableException (org.apache.axiom.om.NodeUnavailableException)2 OMException (org.apache.axiom.om.OMException)2 OMNamespace (org.apache.axiom.om.OMNamespace)2