Package org.apache.ws.commons.om.impl.builder

Examples of org.apache.ws.commons.om.impl.builder.StAXOMBuilder


        String schemaTypes = DOM2Writer.nodeToString(element);
        XMLStreamReader xmlReader = XMLInputFactory.newInstance().createXMLStreamReader(new
                ByteArrayInputStream(schemaTypes.getBytes()));
        OMFactory fac = OMAbstractFactory.getOMFactory();

        StAXOMBuilder staxOMBuilder = new StAXOMBuilder(fac, xmlReader);
        OMElement schemaElement = staxOMBuilder.getDocumentElement();
        schemaElement.serialize(writer);
    }
View Full Code Here


    private void checkOMConformance(InputStream iStream) throws Exception {
        try {
            XMLInputFactory factory = XMLInputFactory.newInstance();

            StAXOMBuilder staxOMBuilder = OMXMLBuilderFactory.
                    createStAXOMBuilder(OMAbstractFactory.getOMFactory(),
                            factory.createXMLStreamReader(
                                    iStream));
            staxOMBuilder.setDoDebug(true);
            rootElement = staxOMBuilder.getDocumentElement();

            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ((OMDocument) rootElement.getParent()).serialize(baos);

            InputSource resultXML = new InputSource(new InputStreamReader(
View Full Code Here

    public String getSerializedOM(String xmlString) throws Exception {
        try {
            XMLInputFactory factory = XMLInputFactory.newInstance();

            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xmlString.getBytes());
            StAXOMBuilder staxOMBuilder = OMXMLBuilderFactory.
                    createStAXOMBuilder(OMAbstractFactory.getOMFactory(),
                            factory.createXMLStreamReader(byteArrayInputStream));
            staxOMBuilder.setDoDebug(true);
            OMElement rootElement = staxOMBuilder.getDocumentElement();

            ByteArrayOutputStream baos = new ByteArrayOutputStream();

            OMOutputFormat format = new OMOutputFormat();
            format.setIgnoreXMLDeclaration(ignoreXMLDeclaration);
View Full Code Here

    public Diff getDiffForComparison(InputStream inStream) throws Exception {

        try {
            XMLInputFactory factory = XMLInputFactory.newInstance();

            StAXOMBuilder staxOMBuilder = OMXMLBuilderFactory.
                    createStAXOMBuilder(OMAbstractFactory.getOMFactory(),
                            factory.createXMLStreamReader(inStream));
            staxOMBuilder.setDoDebug(true);
            OMElement rootElement = staxOMBuilder.getDocumentElement();

            ByteArrayOutputStream baos = new ByteArrayOutputStream();

            if (ignoreDocument) {
                rootElement.serialize(baos);
View Full Code Here

        OMElement rootElement;

        System.out.println("XML File:" + filePath);
        XMLInputFactory factory = XMLInputFactory.newInstance();
//        factory.setProperty("report-cdata-event", Boolean.TRUE);
        StAXOMBuilder staxOMBuilder = OMXMLBuilderFactory.
                createStAXOMBuilder(OMAbstractFactory.getOMFactory(),
                        factory.createXMLStreamReader(
                                new FileInputStream(filePath)));
        rootElement = staxOMBuilder.getDocumentElement();

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ((OMDocument)rootElement.getParent()).serialize(baos);

        InputSource resultXML = new InputSource(new InputStreamReader(
View Full Code Here

    }

    private OMDocument getSampleOMDocument(String xml) {
        try {
            XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xml));
            StAXOMBuilder builder = new StAXOMBuilder(xmlStreamReader);
            return builder.getDocument();
        } catch (XMLStreamException e) {
            throw new UnsupportedOperationException();
        }
    }
View Full Code Here

        String xml = "<wsp:Policy xml:base=\"uri:thisBase\" " +
                "xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\">" +
                "</wsp:Policy>";

        ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes());
        StAXOMBuilder builder = new StAXOMBuilder(bais);
        OMElement elem = builder.getDocumentElement();
        elem.build();
        assertEquals("Attribute value mismatch", "uri:thisBase", elem.getAttributeValue(new QName(OMConstants.XMLNS_URI, "base")));

        OMAttribute attr = elem.getAttribute(new QName(OMConstants.XMLNS_URI, "base"));
View Full Code Here

     */
    public void testAttrWithoutElementNS() throws Exception {
        String xml = "<Policy xml:base=\"uri:thisBase\"></Policy>";

        ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes());
        StAXOMBuilder builder = new StAXOMBuilder(bais);
        OMElement elem = builder.getDocumentElement();
        elem.build();
        assertEquals("Attribute value mismatch", "uri:thisBase", elem.getAttributeValue(new QName(OMConstants.XMLNS_URI, "base")));

        OMAttribute attr = elem.getAttribute(new QName(OMConstants.XMLNS_URI, "base"));

View Full Code Here

    }

    protected void setUp() throws Exception {
        //lets use a plain OM factory
        envelope =
                new StAXOMBuilder(new OMLinkedListImplFactory(),
                        XMLInputFactory.newInstance().createXMLStreamReader(
                                new FileReader(
                                        getTestResourceFile(
                                                "soap/soapmessage1.xml")))).getDocumentElement();
    }
View Full Code Here


    
     public void testOMNS() {
            try {
              StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(originalXML.getBytes()));
                OMElement documentElement = builder.getDocumentElement();
                //assertXMLEqual(originalXML, documentElement.toString());
               
                String outstr  = documentElement.toString();
                System.out.println(outstr);
                assertTrue(outstr.indexOf("xmlns:saml=") > 0);
View Full Code Here

TOP

Related Classes of org.apache.ws.commons.om.impl.builder.StAXOMBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.