Example usage for org.dom4j.tree FlyweightProcessingInstruction getTarget

List of usage examples for org.dom4j.tree FlyweightProcessingInstruction getTarget

Introduction

In this page you can find the example usage for org.dom4j.tree FlyweightProcessingInstruction getTarget.

Prototype

public String getTarget() 

Source Link

Usage

From source file:com.cladonia.xngreditor.actions.OpenBrowserAction.java

License:Open Source License

/**
 * Method to check if the document contains a processing intruction
 * which specifies a stylesheet. If it cannot find one declared at the beginning
 * it will walk the tree to see can it find one.
 * /*from  w  w w .  j av a 2s  .c o  m*/
 * @param document
 * @return boolean true or false
 */
public boolean checkForStylesheetPI(ExchangerDocument document) {
    XDocument doc = document.getDocument();
    for (int cnt = 0; cnt < doc.nodeCount(); ++cnt) {
        Node n = doc.node(cnt);
        if (n.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
            FlyweightProcessingInstruction pi = (FlyweightProcessingInstruction) n;
            if (pi.getTarget().equalsIgnoreCase(XML_STYLESHEET)) {
                return (true);
            }
        }

    }
    return (treeWalk(document.getRoot()));

}

From source file:com.cladonia.xngreditor.actions.OpenBrowserAction.java

License:Open Source License

/**
 * walks the tree to see if it can find a processing instruction 
 * relating to a stylesheet// ww w . j av  a2s  .com
 * @param element
 * @return boolean true or false
 */
public boolean treeWalk(XElement element) {
    for (int i = 0, size = element.nodeCount(); i < size; i++) {
        Node node = element.node(i);
        if (node instanceof Element) {
            treeWalk((XElement) node);
        } else {

            if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
                FlyweightProcessingInstruction pi = (FlyweightProcessingInstruction) node;
                if (pi.getTarget().equalsIgnoreCase(XML_STYLESHEET)) {
                    return (true);
                }
            }
        }
    }
    return (false);
}