Package org.apache.axiom.om.impl.dom.factory

Examples of org.apache.axiom.om.impl.dom.factory.OMDOMFactory


import javax.xml.namespace.QName;

public class OMDOMFactoryTest extends TestCase {
    public void testCreateElement() {
        OMDOMFactory factory = new OMDOMFactory();
        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());
View Full Code Here


    public Document createDocument(String namespaceURI, String qualifiedName,
                                   DocumentType doctype) throws DOMException {

        // TODO Handle docType stuff
        OMDOMFactory fac = new OMDOMFactory();
        DocumentImpl doc = new DocumentImpl(fac);
        fac.setDocument(doc);

        new ElementImpl(doc, DOMUtil.getLocalName(qualifiedName),
                        new NamespaceImpl(namespaceURI, DOMUtil
                                .getPrefix(qualifiedName)), fac);
View Full Code Here

    public void testSearch() throws Exception {
        String NSURI = "http://testns";
        String NSURI_UPPER = "HTTP://TESTNS";

        OMFactory fac = new OMDOMFactory();
        OMNamespace ns = new NamespaceImpl(NSURI);
        OMElement el = fac.createOMElement("foo", null);
        el.declareNamespace(NSURI, "p");
        assertNull(el.findNamespace(NSURI_UPPER, "p"));
    }
View Full Code Here

     * @throws Exception
     */
    public void testQNames() throws Exception {
        String ATTR = "attr";
        String NSURI = "http://ns1";
        OMFactory fac = new OMDOMFactory();
        OMNamespace ns = new NamespaceImpl(NSURI);
        OMAttribute attr = fac.createOMAttribute(ATTR, ns, "value");
        QName qname = attr.getQName();
        assertEquals("Wrong namespace", NSURI, qname.getNamespaceURI());
        assertEquals("Wrong localPart", ATTR, qname.getLocalPart());
        assertEquals("Wrong prefix", "", qname.getPrefix());
    }
View Full Code Here

    public Document createDocument(String namespaceURI, String qualifiedName,
                                   DocumentType doctype) throws DOMException {

        // TODO Handle docType stuff
        OMDOMFactory fac = new OMDOMFactory();
        DocumentImpl doc = new DocumentImpl(fac);
        fac.setDocument(doc);

        new ElementImpl(doc, DOMUtil.getLocalName(qualifiedName),
                        new NamespaceImpl(namespaceURI, DOMUtil
                                .getPrefix(qualifiedName)), fac);
View Full Code Here

     * Returns a new document impl.
     *
     * @see javax.xml.parsers.DocumentBuilder#newDocument()
     */
    public Document newDocument() {
        OMDOMFactory factory = new OMDOMFactory();
        DocumentImpl documentImpl = new DocumentImpl(factory);
        documentImpl.setComplete(true);
        return documentImpl;
    }
View Full Code Here

    }

    public Document parse(InputSource inputSource) throws SAXException,
            IOException {
        try {
            OMDOMFactory factory = new OMDOMFactory();
            // Not really sure whether this will work :-?
            XMLStreamReader reader = StAXUtils
                    .createXMLStreamReader(inputSource.getCharacterStream());
            StAXOMBuilder builder = new StAXOMBuilder(factory, reader);
            DocumentImpl doc = (DocumentImpl) builder.getDocument();
View Full Code Here

    }

    /** @see javax.xml.parsers.DocumentBuilder#parse(java.io.InputStream) */
    public Document parse(InputStream is) throws SAXException, IOException {
        try {
            OMDOMFactory factory = new OMDOMFactory();
            XMLStreamReader reader = StAXUtils
                    .createXMLStreamReader(is);
            StAXOMBuilder builder = new StAXOMBuilder(factory, reader);
            return (DocumentImpl) builder.getDocument();
        } catch (XMLStreamException e) {
View Full Code Here

    }

    /** @see javax.xml.parsers.DocumentBuilder#parse(java.io.File) */
    public Document parse(File file) throws SAXException, IOException {
        try {
            OMDOMFactory factory = new OMDOMFactory();
            XMLStreamReader reader = StAXUtils
                    .createXMLStreamReader(new FileInputStream(file));
            StAXOMBuilder builder = new StAXOMBuilder(factory, reader);
            return (DocumentImpl) builder.getDocument();
        } catch (XMLStreamException e) {
View Full Code Here

     * @return the new <code>SOAPElement</code> object that was created
     * @throws javax.xml.soap.SOAPException if there is an error in creating the <code>SOAPElement</code>
     *                                      object
     */
    public SOAPElement createElement(String localName) throws SOAPException {
        OMDOMFactory omdomFactory = null;
        if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) {
            omdomFactory = (OMDOMFactory)DOOMAbstractFactory.getSOAP12Factory();
        } else {
            omdomFactory = (OMDOMFactory)DOOMAbstractFactory.getSOAP11Factory();
        }
        OMElement omElement = omdomFactory.createOMElement(new QName(localName));
        return new SOAPElementImpl((ElementImpl)omElement);
    }
View Full Code Here

TOP

Related Classes of org.apache.axiom.om.impl.dom.factory.OMDOMFactory

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.