List of usage examples for org.dom4j Node PROCESSING_INSTRUCTION_NODE
short PROCESSING_INSTRUCTION_NODE
To view the source code for org.dom4j Node PROCESSING_INSTRUCTION_NODE.
Click Source Link
From source file:com.smartwork.im.utils.XMLWriter.java
License:Open Source License
public void processingInstruction(String target, String data) throws SAXException { try {//from www .j a v a 2 s . c o 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:com.webslingerz.jpt.PageTemplateImpl.java
License:Open Source License
private void defaultContent(Element element, ContentHandler contentHandler, LexicalHandler lexicalHandler, Interpreter beanShell, Stack<Map<String, Slot>> 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 = Expression.evaluateText(node.getText().toString(), beanShell).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 ww w .j a v a 2s .co m*/ 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:freemarker.ext.xml._Dom4jNavigator.java
License:Apache License
String getType(Object node) { switch (((Node) node).getNodeType()) { case Node.ATTRIBUTE_NODE: { return "attribute"; }/*from www. j a va 2s. com*/ case Node.CDATA_SECTION_NODE: { return "cdata"; } case Node.COMMENT_NODE: { return "comment"; } case Node.DOCUMENT_NODE: { return "document"; } case Node.DOCUMENT_TYPE_NODE: { return "documentType"; } case Node.ELEMENT_NODE: { return "element"; } case Node.ENTITY_REFERENCE_NODE: { return "entityReference"; } case Node.NAMESPACE_NODE: { return "namespace"; } case Node.PROCESSING_INSTRUCTION_NODE: { return "processingInstruction"; } case Node.TEXT_NODE: { return "text"; } } return "unknown"; }
From source file:org.hudsonci.xpath.impl.Dom2Dom.java
License:Open Source License
private org.w3c.dom.Node createChild(Node child, org.w3c.dom.Node wparent) { int type = child.getNodeType(); // Collapse multiple consecutive text nodes to a single text node // with trimmed value. if (type != Node.TEXT_NODE) endText(wparent);//from ww w . ja va 2 s . c om Name name; org.w3c.dom.Node node = null; switch (type) { case Node.ATTRIBUTE_NODE: break; case Node.CDATA_SECTION_NODE: CDATA cd = (CDATA) child; wparent.appendChild(node = wdoc.createCDATASection(cd.getText())); break; case Node.COMMENT_NODE: Comment co = (Comment) child; wparent.appendChild(node = wdoc.createComment(co.getText())); break; case Node.DOCUMENT_TYPE_NODE: DocumentType dt = (DocumentType) child; wparent.appendChild(new XDocumentType(dt, wparent)); break; case Node.ELEMENT_NODE: Element el = (Element) child; name = new Name(el); org.w3c.dom.Element e = name.namespaceURI == null ? wdoc.createElement(name.qualifiedName) : wdoc.createElementNS(name.namespaceURI, name.qualifiedName); wparent.appendChild(e); node = currentElement = e; for (int i = 0, n = el.attributeCount(); i < n; i++) { Attribute at = el.attribute(i); name = new Name(at); if (name.namespaceURI == null) e.setAttribute(name.qualifiedName, at.getValue()); else e.setAttributeNS(name.namespaceURI, name.qualifiedName, at.getValue()); } return e; case Node.ENTITY_REFERENCE_NODE: break; case Node.PROCESSING_INSTRUCTION_NODE: ProcessingInstruction p = (ProcessingInstruction) child; wparent.appendChild(node = wdoc.createProcessingInstruction(p.getTarget(), p.getText())); break; case Node.TEXT_NODE: textBuilder.append(child.getText()); lastText = (Text) child; break; case Node.NAMESPACE_NODE: Namespace ns = (Namespace) child; name = new Name(ns); currentElement.setAttribute(name.qualifiedName, ns.getURI()); break; default: throw new IllegalStateException("Unknown node type"); } if (node != null) reverseMap.put(node, child); return null; }
From source file:org.zenonpagetemplates.onePhaseImpl.PageTemplateImpl.java
License:Open Source License
@SuppressWarnings({ "unchecked" }) private void defaultContent(Element element, ContentHandler contentHandler, LexicalHandler lexicalHandler, EvaluationHelper evaluationHelper, Stack<Map<String, Slot>> slotStack) throws SAXException, PageTemplateException, IOException, EvaluationException { // Use default template content for (Iterator<Node> i = element.nodeIterator(); i.hasNext();) { Node node = i.next();//w w w . j av a2 s .c o m switch (node.getNodeType()) { case Node.ELEMENT_NODE: processElement((Element) node, contentHandler, lexicalHandler, evaluationHelper, 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(); break; case Node.NAMESPACE_NODE: Namespace declared = (Namespace) node; //System.err.println( "Declared namespace: " + declared.getPrefix() + ":" + declared.getURI() ); this.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: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();//w w w . j av a 2 s . com 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 } } }