Example usage for org.dom4j ProcessingInstruction getValue

List of usage examples for org.dom4j ProcessingInstruction getValue

Introduction

In this page you can find the example usage for org.dom4j ProcessingInstruction getValue.

Prototype

String getValue(String name);

Source Link

Document

Returns the value of a specific name in the PI.

Usage

From source file:freemarker.ext.xml._Dom4jNavigator.java

License:Apache License

void getAttributes(Object node, String localName, String namespaceUri, List result) {
    if (node instanceof Element) {
        Element e = (Element) node;
        if (localName == null) {
            result.addAll(e.attributes());
        } else {/*from w  w  w  .java2 s . co m*/
            Attribute attr = e
                    .attribute(e.getQName().getDocumentFactory().createQName(localName, "", namespaceUri));
            if (attr != null) {
                result.add(attr);
            }
        }
    } else if (node instanceof ProcessingInstruction) {
        ProcessingInstruction pi = (ProcessingInstruction) node;
        if ("target".equals(localName)) {
            result.add(new DefaultAttribute("target", pi.getTarget()));
        } else if ("data".equals(localName)) {
            result.add(new DefaultAttribute("data", pi.getText()));
        } else {
            result.add(new DefaultAttribute(localName, pi.getValue(localName)));
        }
    } else if (node instanceof DocumentType) {
        DocumentType doctype = (DocumentType) node;
        if ("publicId".equals(localName)) {
            result.add(new DefaultAttribute("publicId", doctype.getPublicID()));
        } else if ("systemId".equals(localName)) {
            result.add(new DefaultAttribute("systemId", doctype.getSystemID()));
        } else if ("elementName".equals(localName)) {
            result.add(new DefaultAttribute("elementName", doctype.getElementName()));
        }
    }
}