Example usage for org.dom4j Node NAMESPACE_NODE

List of usage examples for org.dom4j Node NAMESPACE_NODE

Introduction

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

Prototype

short NAMESPACE_NODE

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

Click Source Link

Document

Matchs a Namespace Node - NOTE this differs from DOM

Usage

From source file:org.zenonpagetemplates.twoPhasesImpl.ZPTDocumentFactory.java

License:Open Source License

@SuppressWarnings({ "unchecked" })
static private void mapContent(Element element, ZPTElement zptElement, ZPTDocument zptDocument,
        Stack<Map<String, Slot>> slotStack) throws SAXException, PageTemplateException, IOException {

    // Use default template content
    for (Iterator<Node> i = element.nodeIterator(); i.hasNext();) {
        Node node = i.next();//from w ww .j  a v a  2 s  .  c om
        switch (node.getNodeType()) {
        case Node.ELEMENT_NODE:
            zptElement.addContent(getNewZPTElement((Element) node, zptDocument, slotStack));
            break;

        case Node.TEXT_NODE:
            zptElement.addContent(new TextNode(node.getText()));
            break;

        case Node.CDATA_SECTION_NODE:
            zptElement.addContent(new CDATANode(node.getText()));
            break;

        case Node.NAMESPACE_NODE: // Already handled
            /*
             Namespace declared = (Namespace)node;
             if (zptDocument.isNamespaceToDeclare(declared)){
                zptDocument.addNamespace(declared);
             } else {
                zptElement.addNamespaceStaticAttribute(declared);
             }
             break;*/

        case Node.ATTRIBUTE_NODE: // Already handled
        case Node.COMMENT_NODE: // Remove all comments
        case Node.DOCUMENT_TYPE_NODE:
        case Node.ENTITY_REFERENCE_NODE:
        case Node.PROCESSING_INSTRUCTION_NODE:
        default:
            // Nothing to do
        }
    }
}

From source file:org.zenonpagetemplates.twoPhasesImpl.ZPTDocumentFactory.java

License:Open Source License

@SuppressWarnings("unchecked")
static private void mapNamespaces(Element element, ZPTElement zptElement, ZPTDocument zptDocument)
        throws PageTemplateException {

    for (Iterator<Attribute> i = element.nodeIterator(); i.hasNext();) {
        Node node = i.next();/*from   w  ww.j a v a 2 s  .c  o  m*/
        if (node.getNodeType() == Node.NAMESPACE_NODE) {
            Namespace declared = (Namespace) node;
            if (zptDocument.isNamespaceToDeclare(declared)) {
                zptDocument.addNamespace(declared);
            } else {
                zptElement.addNamespaceStaticAttribute(declared);
            }
        }
    }
}