Example usage for org.dom4j Namespace NO_NAMESPACE

List of usage examples for org.dom4j Namespace NO_NAMESPACE

Introduction

In this page you can find the example usage for org.dom4j Namespace NO_NAMESPACE.

Prototype

Namespace NO_NAMESPACE

To view the source code for org.dom4j Namespace NO_NAMESPACE.

Click Source Link

Document

No Namespace present

Usage

From source file:com.cladonia.xml.ExchangerXMLWriter.java

License:Open Source License

public ExchangerXMLWriter(Writer writer, ExchangerOutputFormat format) throws UnsupportedEncodingException {
    super(format);

    setWriter(new PositionedWriter(this, writer));

    namespaceStack.push(Namespace.NO_NAMESPACE);

    this.format = format;

    format.setNewlines(true);//ww  w  . j a  va2s.c o  m
    format.setIndent("");
}

From source file:com.cladonia.xml.ExchangerXMLWriter.java

License:Open Source License

protected void writeAttributes(Element element) throws IOException {

    // I do not yet handle the case where the same prefix maps to
    // two different URIs. For attributes on the same element
    // this is illegal; but as yet we don't throw an exception
    // if someone tries to do this
    for (int i = 0, size = element.attributeCount(); i < size; i++) {
        Attribute attribute = element.attribute(i);
        Namespace ns = attribute.getNamespace();
        if (ns != null && ns != Namespace.NO_NAMESPACE && ns != Namespace.XML_NAMESPACE) {
            String prefix = ns.getPrefix();
            String uri = namespaceStack.getURI(prefix);
            if (!ns.getURI().equals(uri)) { // output a new namespace declaration
                writeNamespace(ns);/*from   ww  w. j  a v  a  2s  . co m*/
                namespaceStack.push(ns);
            }
        }

        writeAttribute(attribute);
    }
}

From source file:com.cladonia.xml.XMLFormatter.java

License:Mozilla Public License

public XMLFormatter(OutputStream out, ExchangerOutputFormat format) throws UnsupportedEncodingException {
    super(out, format);

    this.format = format;
    namespaceStack.push(Namespace.NO_NAMESPACE);
}

From source file:com.cladonia.xml.XMLFormatter.java

License:Mozilla Public License

public XMLFormatter(ExchangerOutputFormat format) throws UnsupportedEncodingException {
    super(format);

    this.format = format;
    namespaceStack.push(Namespace.NO_NAMESPACE);
}

From source file:com.cladonia.xngreditor.SchemaLocationDialog.java

License:Open Source License

/**
 * Sets the original values displayed by the dialog, plus what should be enabled\disabled
 */// w  w  w. j  a va  2 s.c o m
private void setCurrentValues() {
    XDocument xdoc = document.getDocument();
    Element ele = xdoc.getRootElement();

    Attribute attr = ele.attribute(SCHEMALOCATION);

    if (attr == null) {
        // check for no namespace schema
        Attribute attr2 = ele.attribute(NOSCHEMALOCATION);
        if (attr2 == null) {
            // set the defaults
            schemaButton.setSelected(true);
            Namespace ns = ele.getNamespace();
            if (ns != Namespace.NO_NAMESPACE) {
                namespaceField.setText(ns.getURI());
            } else {
                namespaceField.setText("");
            }

            urlField.setText("");
        } else {
            // we have a "no namespace schema"
            schemaNoNSButton.setSelected(true);
            namespaceField.setText("");
            namespaceField.setEnabled(false);
            namespaceLabel.setEnabled(false);
            urlField.setText(attr2.getValue());
        }
    } else {
        // we hava a namepace schema

        schemaButton.setSelected(true);

        // we have namespace schema, set the namespace and the URL
        String attrValue = attr.getValue();

        // break up all the namespace and url pairs
        ArrayList stringValues = new ArrayList();

        StringTokenizer st = new StringTokenizer(attrValue);
        while (st.hasMoreTokens()) {
            stringValues.add(st.nextToken());
        }

        String namespaceValue = (String) stringValues.get(0);
        if (namespaceValue != null) {
            namespaceField.setText(namespaceValue);
        } else {
            namespaceField.setText("");
        }

        String urlValue = (String) stringValues.get(1);
        if (urlValue != null) {
            urlField.setText(urlValue);
        } else {
            urlField.setText("");
        }
    }
}

From source file:com.flaptor.util.parser.HtmlParser.java

License:Apache License

private void removeNamespace(Element elem) {
    if (null != elem) {
        elem.remove(elem.getNamespace());
        elem.setQName(QName.get(elem.getName(), Namespace.NO_NAMESPACE));
        removeNamespace(elem.content());
    }/*from   w w  w .  j a  v  a2  s  . c o  m*/
}

From source file:com.flaptor.util.parser.HtmlParser.java

License:Apache License

@SuppressWarnings("unchecked")
private void removeNamespace(List list) {
    if (null != list) {
        for (Node node : (List<Node>) list) {
            if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
                ((Attribute) node).setNamespace(Namespace.NO_NAMESPACE);
            } else if (node.getNodeType() == Node.ELEMENT_NODE) {
                removeNamespace((Element) node);
            }/*from  w w  w.ja  v a2 s. co  m*/
        }
    }
}

From source file:com.smartwork.im.utils.XMLWriter.java

License:Open Source License

public XMLWriter(Writer writer, OutputFormat format) {
    this.writer = writer;
    this.format = format;
    namespaceStack.push(Namespace.NO_NAMESPACE);
}

From source file:com.smartwork.im.utils.XMLWriter.java

License:Open Source License

public XMLWriter() {
    this.format = DEFAULT_FORMAT;
    this.writer = new BufferedWriter(new OutputStreamWriter(System.out));
    this.autoFlush = true;
    namespaceStack.push(Namespace.NO_NAMESPACE);
}

From source file:com.smartwork.im.utils.XMLWriter.java

License:Open Source License

public XMLWriter(OutputStream out) throws UnsupportedEncodingException {
    this.format = DEFAULT_FORMAT;
    this.writer = createWriter(out, format.getEncoding());
    this.autoFlush = true;
    namespaceStack.push(Namespace.NO_NAMESPACE);
}