Example usage for org.dom4j Node PROCESSING_INSTRUCTION_NODE

List of usage examples for org.dom4j Node PROCESSING_INSTRUCTION_NODE

Introduction

In this page you can find the example usage for org.dom4j Node PROCESSING_INSTRUCTION_NODE.

Prototype

short PROCESSING_INSTRUCTION_NODE

To view the source code for org.dom4j Node PROCESSING_INSTRUCTION_NODE.

Click Source Link

Document

Matches ProcessingInstruction

Usage

From source file:architecture.common.xml.XmlWriter.java

License:Apache License

@Override
public void processingInstruction(String target, String data) throws SAXException {
    try {//w  w  w . jav  a  2  s.  co  m
        indent();
        writer.write("<?");
        writer.write(target);
        writer.write(" ");
        writer.write(data);
        writer.write("?>");
        writePrintln();
        lastOutputNodeType = Node.PROCESSING_INSTRUCTION_NODE;

        super.processingInstruction(target, data);
    } catch (IOException e) {
        handleException(e);
    }
}

From source file:architecture.common.xml.XmlWriter.java

License:Apache License

protected void writeProcessingInstruction(ProcessingInstruction processingInstruction) throws IOException {
    // indent();/*from  w  w  w.j  a v a  2  s  . c  om*/
    writer.write("<?");
    writer.write(processingInstruction.getName());
    writer.write(" ");
    writer.write(processingInstruction.getText());
    writer.write("?>");
    writePrintln();

    lastOutputNodeType = Node.PROCESSING_INSTRUCTION_NODE;
}

From source file:architecture.common.xml.XmlWriter.java

License:Apache License

protected void writeNode(Node node) throws IOException {
    int nodeType = node.getNodeType();
    switch (nodeType) {
    case Node.ELEMENT_NODE:
        writeElement((Element) node);
        break;/*from www.j av  a2 s  .  c o  m*/
    case Node.ATTRIBUTE_NODE:
        writeAttribute((Attribute) node);
        break;
    case Node.TEXT_NODE:
        writeNodeText(node);
        // write((Text) node);
        break;
    case Node.CDATA_SECTION_NODE:
        writeCDATA(node.getText());
        break;
    case Node.ENTITY_REFERENCE_NODE:
        writeEntity((Entity) node);
        break;
    case Node.PROCESSING_INSTRUCTION_NODE:
        writeProcessingInstruction((ProcessingInstruction) node);
        break;
    case Node.COMMENT_NODE:
        writeComment(node.getText());
        break;
    case Node.DOCUMENT_NODE:
        write((Document) node);
        break;
    case Node.DOCUMENT_TYPE_NODE:
        writeDocType((DocumentType) node);
        break;
    case Node.NAMESPACE_NODE:
        // Will be output with attributes
        // write((Namespace) node);
        break;
    default:
        throw new IOException("Invalid node type: " + node);
    }
}

From source file:architecture.ee.util.xml.XmlWriter.java

License:Apache License

protected void writeNode(Node node) throws IOException {
    int nodeType = node.getNodeType();
    switch (nodeType) {
    case Node.ELEMENT_NODE:
        writeElement((Element) node);
        break;//from w ww .  j  av  a  2  s  .c om
    case Node.ATTRIBUTE_NODE:
        writeAttribute((Attribute) node);
        break;
    case Node.TEXT_NODE:
        writeNodeText(node);
        //write((Text) node);
        break;
    case Node.CDATA_SECTION_NODE:
        writeCDATA(node.getText());
        break;
    case Node.ENTITY_REFERENCE_NODE:
        writeEntity((Entity) node);
        break;
    case Node.PROCESSING_INSTRUCTION_NODE:
        writeProcessingInstruction((ProcessingInstruction) node);
        break;
    case Node.COMMENT_NODE:
        writeComment(node.getText());
        break;
    case Node.DOCUMENT_NODE:
        write((Document) node);
        break;
    case Node.DOCUMENT_TYPE_NODE:
        writeDocType((DocumentType) node);
        break;
    case Node.NAMESPACE_NODE:
        // Will be output with attributes
        //write((Namespace) node);
        break;
    default:
        throw new IOException("Invalid node type: " + node);
    }
}

From source file:architecture.ee.util.xml.XmlWriter.java

License:Apache License

protected void writeProcessingInstruction(ProcessingInstruction processingInstruction) throws IOException {
    //indent();/*w w w . j  a v  a  2 s. c o  m*/
    writer.write("<?");
    writer.write(processingInstruction.getName());
    writer.write(" ");
    writer.write(processingInstruction.getText());
    writer.write("?>");
    writePrintln();

    lastOutputNodeType = Node.PROCESSING_INSTRUCTION_NODE;
}

From source file:com.christophermrossi.jpt.PageTemplateImpl.java

License:Open Source License

private void defaultContent(Element element, ContentHandler contentHandler, LexicalHandler lexicalHandler,
        Interpreter beanShell, Stack slotStack) throws SAXException, PageTemplateException, IOException {
    // Use default template content
    for (Iterator i = element.nodeIterator(); i.hasNext();) {
        Node node = (Node) i.next();
        switch (node.getNodeType()) {
        case Node.ELEMENT_NODE:
            processElement((Element) node, contentHandler, lexicalHandler, beanShell, slotStack);
            break;

        case Node.TEXT_NODE:
            char[] text = node.getText().toCharArray();
            contentHandler.characters(text, 0, text.length);
            break;

        case Node.COMMENT_NODE:
            char[] comment = node.getText().toCharArray();
            lexicalHandler.comment(comment, 0, comment.length);
            break;

        case Node.CDATA_SECTION_NODE:
            lexicalHandler.startCDATA();
            char[] cdata = node.getText().toCharArray();
            contentHandler.characters(cdata, 0, cdata.length);
            lexicalHandler.endCDATA();//from   w  w  w .  j  a  v  a  2s  .c om
            break;

        case Node.NAMESPACE_NODE:
            Namespace declared = (Namespace) node;
            //System.err.println( "Declared namespace: " + declared.getPrefix() + ":" + declared.getURI() );
            namespaces.put(declared.getPrefix(), declared.getURI());
            //if ( declared.getURI().equals( TAL_NAMESPACE_URI ) ) {
            //    this.talNamespacePrefix = declared.getPrefix();
            //} 
            //else if (declared.getURI().equals( METAL_NAMESPACE_URI ) ) {
            //    this.metalNamespacePrefix = declared.getPrefix();
            //}
            break;

        case Node.ATTRIBUTE_NODE:
            // Already handled
            break;

        case Node.DOCUMENT_TYPE_NODE:
        case Node.ENTITY_REFERENCE_NODE:
        case Node.PROCESSING_INSTRUCTION_NODE:
        default:
            //System.err.println( "WARNING: Node type not supported: " + node.getNodeTypeName() );       
        }
    }
}

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

License:Mozilla Public License

protected void writeMixedNode(Node node) throws IOException {
    if (DEBUG)//  www  . jav a2 s.c om
        System.out.println("XMLFormatter.writeMixedNode( " + node + ")");
    int nodeType = node.getNodeType();
    switch (nodeType) {
    case Node.ELEMENT_NODE:
        writeMixedElement((Element) node);
        break;
    case Node.ATTRIBUTE_NODE:
        writeAttribute((Attribute) node);
        break;
    case Node.TEXT_NODE:
        writeString(node.getText());
        //write((Text) node);
        break;
    case Node.CDATA_SECTION_NODE:
        writeCDATA(node.getText());
        break;
    case Node.ENTITY_REFERENCE_NODE:
        writeEntity((Entity) node);
        break;
    case Node.PROCESSING_INSTRUCTION_NODE:
        writeProcessingInstruction((ProcessingInstruction) node);
        break;
    case Node.COMMENT_NODE:
        writeComment(node.getText());
        break;
    case Node.DOCUMENT_NODE:
        write((Document) node);
        break;
    case Node.DOCUMENT_TYPE_NODE:
        writeDocType((DocumentType) node);
        break;
    case Node.NAMESPACE_NODE:
        // Will be output with attributes
        //write((Namespace) node);
        break;
    default:
        throw new IOException("Invalid node type: " + node);
    }
}

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

License:Mozilla Public License

protected void writePreservedNode(Node node) throws IOException {
    if (DEBUG)/* w w  w.j av  a2  s. c om*/
        System.out.println("XMLFormatter.writeMixedNode( " + node + ")");
    int nodeType = node.getNodeType();
    switch (nodeType) {
    case Node.ELEMENT_NODE:
        writePreservedElement((Element) node);
        break;
    case Node.ATTRIBUTE_NODE:
        writeAttribute((Attribute) node);
        break;
    case Node.TEXT_NODE:
        writeString(node.getText());
        //write((Text) node);
        break;
    case Node.CDATA_SECTION_NODE:
        writeCDATA(node.getText());
        break;
    case Node.ENTITY_REFERENCE_NODE:
        writeEntity((Entity) node);
        break;
    case Node.PROCESSING_INSTRUCTION_NODE:
        writeProcessingInstruction((ProcessingInstruction) node);
        break;
    case Node.COMMENT_NODE:
        writeComment(node.getText());
        break;
    case Node.DOCUMENT_NODE:
        write((Document) node);
        break;
    case Node.DOCUMENT_TYPE_NODE:
        writeDocType((DocumentType) node);
        break;
    case Node.NAMESPACE_NODE:
        // Will be output with attributes
        //write((Namespace) node);
        break;
    default:
        throw new IOException("Invalid node type: " + node);
    }
}

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.
 * /*w w w .  jav a  2 s.  co  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//from  w w  w .  j  ava 2s .  c o  m
 * @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);
}