Package org.dom4j

Examples of org.dom4j.DocumentFactory


    protected void setAttributeList(List attributeList) {
        this.attributes = attributeList;
    }

    protected DocumentFactory getDocumentFactory() {
        DocumentFactory factory = qname.getDocumentFactory();

        return (factory != null) ? factory : DOCUMENT_FACTORY;
    }
View Full Code Here


   
    private SAXReader createXmlReader() {
  Map<String,String> uris = new HashMap<String,String>();
        uris.put( "y", "http://xml.weather.yahoo.com/ns/rss/1.0" );
       
        DocumentFactory factory = new DocumentFactory();
        factory.setXPathNamespaceURIs( uris );
       
  SAXReader xmlReader = new SAXReader();
  xmlReader.setDocumentFactory( factory );
  return xmlReader;
    }
View Full Code Here

  private SAXReader createXmlReader() {
    Map<String,String> uris = new HashMap<String,String>();
        uris.put( "y", "http://xml.weather.yahoo.com/ns/rss/1.0" );
       
        DocumentFactory factory = new DocumentFactory();
        factory.setXPathNamespaceURIs( uris );
       
    SAXReader xmlReader = new SAXReader();
    xmlReader.setDocumentFactory( factory );
    return xmlReader;
  }
View Full Code Here

    return value;
  }

  private SAXReader buildSAXReader() {
    SAXReader saxReader = new SAXReader( new DocumentFactory() );
    saxReader.setMergeAdjacentText( true );
    return saxReader;
  }
View Full Code Here

        SAXReader answer = new SAXReader();
        if (documentFactoryClassName != null) {
            try {
                Class theClass = Class.forName(documentFactoryClassName);
                DocumentFactory factory = (DocumentFactory) theClass
                        .newInstance();
                if (factory != null) {
                    println("DocumentFactory:  " + factory);
                    answer.setDocumentFactory(factory);
                }
View Full Code Here

    // Implementation methods
    // -------------------------------------------------------------------------
    protected void setUp() throws Exception {
        super.setUp();

        DocumentFactory factory = loadDocumentFactory();
        SAXReader reader = new SAXReader(factory);
        document = getDocument(getDocumentURI(), reader);
    }
View Full Code Here

    // Implementation methods
    // -------------------------------------------------------------------------
    protected void setUp() throws Exception {
        super.setUp();

        DocumentFactory factory = DatatypeDocumentFactory.getInstance();
        SAXReader reader = new SAXReader(factory);
        document = getDocument("/xml/test/schema/test.xml", reader);
    }
View Full Code Here

*/
public class Dom4jUnmarshallingEventHandler extends UnmarshallingEventHandlerAdaptor {
    private Element owner;
   
    public Dom4jUnmarshallingEventHandler(UnmarshallingContext _ctxt) throws SAXException {
        super(_ctxt, new SAXContentHandler(new DocumentFactory()));
    }
View Full Code Here

            NamespaceStack namespaceStack, boolean noNamespaceAttributes) {
        // now lets add all attribute values
        int size = attributes.getLength();

        if (size > 0) {
            DocumentFactory factory = getDocumentFactory();

            if (size == 1) {
                // allow lazy construction of the List of Attributes
                String name = attributes.getQName(0);

                if (noNamespaceAttributes || !name.startsWith("xmlns")) {
                    String attributeURI = attributes.getURI(0);

                    String attributeLocalName = attributes.getLocalName(0);

                    String attributeValue = attributes.getValue(0);

                    QName attributeQName = namespaceStack.getAttributeQName(
                            attributeURI, attributeLocalName, name);

                    add(factory.createAttribute(this, attributeQName,
                            attributeValue));
                }
            } else {
                List list = attributeList(size);

                list.clear();

                for (int i = 0; i < size; i++) {
                    // optimised to avoid the call to attribute(QName) to
                    // lookup an attribute for a given QName
                    String attributeName = attributes.getQName(i);

                    if (noNamespaceAttributes
                            || !attributeName.startsWith("xmlns")) {
                        String attributeURI = attributes.getURI(i);

                        String attributeLocalName = attributes.getLocalName(i);

                        String attributeValue = attributes.getValue(i);

                        QName attributeQName = namespaceStack
                                .getAttributeQName(attributeURI,
                                        attributeLocalName, attributeName);

                        Attribute attribute = factory.createAttribute(this,
                                attributeQName, attributeValue);

                        list.add(attribute);

                        childAdded(attribute);
View Full Code Here

        return this;
    }

    public Element addElement(String name) {
        DocumentFactory factory = getDocumentFactory();

        int index = name.indexOf(":");

        String prefix = "";

        String localName = name;

        Namespace namespace = null;

        if (index > 0) {
            prefix = name.substring(0, index);

            localName = name.substring(index + 1);

            namespace = getNamespaceForPrefix(prefix);

            if (namespace == null) {
                throw new IllegalAddException("No such namespace prefix: "
                        + prefix + " is in scope on: " + this
                        + " so cannot add element: " + name);
            }
        } else {
            namespace = getNamespaceForPrefix("");
        }

        Element node;

        if (namespace != null) {
            QName qname = factory.createQName(localName, namespace);

            node = factory.createElement(qname);
        } else {
            node = factory.createElement(name);
        }

        addNewNode(node);

        return node;
View Full Code Here

TOP

Related Classes of org.dom4j.DocumentFactory

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.