@Override public Element createStyleElement(OpcPackage opcPackage, Document document, String styleDefinition) { // See XsltHTMLFunctions, which typically generates the String styleDefinition. // In practice, the styles are coupled to the document content, so you're // less likely to override their content; just whether they are linked or inline. Element ret = null; if ((styleDefinition != null) && (styleDefinition.length() > 0)) { ret = document.createElement("style"); ret.appendChild(document.createComment(styleDefinition)); } return ret; } };
@Override public Element createScriptElement(OpcPackage opcPackage, Document document, String scriptDefinition) { Element ret = null; if ((scriptDefinition != null) && (scriptDefinition.length() > 0)) { ret = document.createElement("script"); ret.setAttribute("type", "text/javascript"); ret.appendChild(document.createComment(scriptDefinition)); } return ret; } };
/** * Lexical Handler method to create comment node in DOM tree. */ public void comment(char[] ch, int start, int length) { final Node last = (Node)_nodeStk.peek(); Comment comment = _document.createComment(new String(ch,start,length)); if (comment != null){ if (last == _root && _nextSibling != null) last.insertBefore(comment, _nextSibling); else last.appendChild(comment); _lastSibling = comment; } }
public void addComment(String comment) { final Comment commentElement = document.createComment(comment); getG().appendChild(commentElement); }
/** * Report an XML comment anywhere in the document. * * This callback will be used for comments inside or outside the * document element, including comments in the external DTD * subset (if read). * * @param ch An array holding the characters in the comment. * @param start The starting position in the array. * @param length The number of characters to use from the array. */ public void comment(char ch[], int start, int length) throws org.xml.sax.SAXException { append(m_doc.createComment(new String(ch, start, length))); }
/** * Report an XML comment anywhere in the document. * * This callback will be used for comments inside or outside the * document element, including comments in the external DTD * subset (if read). * * @param ch An array holding the characters in the comment. * @param start The starting position in the array. * @param length The number of characters to use from the array. */ public void comment(char ch[], int start, int length) throws org.xml.sax.SAXException { append(m_doc.createComment(new String(ch, start, length))); }
/** * {@inheritDoc} * * @throws DOMException If thrown by method invoked on the underlying DOM document */ public void writeComment(String comment) throws DOMException { if (comment.indexOf("--") >= 0) throw new IllegalArgumentException("A comment must not contain '--'."); deNude(); Node node = this.document.createComment(comment); this.currentElement.appendChild(node); if (this.indent) { newLine(); } }
"xml-stylesheet", "type=\"text/xsl\" href=\"configuration.xsl\"")); doc.appendChild(doc.createComment("\n" + " Licensed to the Apache Software Foundation (ASF) under one or more\n" + " contributor license agreements. See the NOTICE file distributed with\n" + doc.appendChild(root); root.appendChild(doc.createComment( " WARNING!!! This file is auto generated for documentation purposes ONLY! ")); root.appendChild(doc.createComment( " WARNING!!! Any changes you make to this file will be ignored by the metastore. ")); root.appendChild(doc.createComment( " WARNING!!! You must make your changes in metastore-site.xml instead. ")); root.appendChild(doc.createComment(" Metastore Execution Parameters ")); root.appendChild(doc.createComment("================================")); root.appendChild(doc.createComment("All time unit values have a time unit abbreviation suffix")); root.appendChild(doc.createComment("Any time value can take any of the units")); root.appendChild(doc.createComment("d = day")); root.appendChild(doc.createComment("h = hour")); root.appendChild(doc.createComment("m = minute")); root.appendChild(doc.createComment("s = second")); root.appendChild(doc.createComment("ms = millisecond")); root.appendChild(doc.createComment("us = microsecond")); root.appendChild(doc.createComment("ns = nanosecond")); root.appendChild(doc.createComment("================================"));
"xml-stylesheet", "type=\"text/xsl\" href=\"configuration.xsl\"")); doc.appendChild(doc.createComment("\n" + " Licensed to the Apache Software Foundation (ASF) under one or more\n" + " contributor license agreements. See the NOTICE file distributed with\n" + doc.appendChild(root); root.appendChild(doc.createComment( " WARNING!!! This file is auto generated for documentation purposes ONLY! ")); root.appendChild(doc.createComment( " WARNING!!! Any changes you make to this file will be ignored by Hive. ")); root.appendChild(doc.createComment( " WARNING!!! You must make your changes in hive-site.xml instead. ")); root.appendChild(doc.createComment(" Hive Execution Parameters "));
public void head(org.jsoup.nodes.Node source, int depth) { namespacesStack.push(new HashMap<>(namespacesStack.peek())); // inherit from above on the stack if (source instanceof org.jsoup.nodes.Element) { org.jsoup.nodes.Element sourceEl = (org.jsoup.nodes.Element) source; String prefix = updateNamespaces(sourceEl); String namespace = namespacesStack.peek().get(prefix); Element el = doc.createElementNS(namespace, sourceEl.tagName()); copyAttributes(sourceEl, el); if (dest == null) { // sets up the root doc.appendChild(el); } else { dest.appendChild(el); } dest = el; // descend } else if (source instanceof org.jsoup.nodes.TextNode) { org.jsoup.nodes.TextNode sourceText = (org.jsoup.nodes.TextNode) source; Text text = doc.createTextNode(sourceText.getWholeText()); dest.appendChild(text); } else if (source instanceof org.jsoup.nodes.Comment) { org.jsoup.nodes.Comment sourceComment = (org.jsoup.nodes.Comment) source; Comment comment = doc.createComment(sourceComment.getData()); dest.appendChild(comment); } else if (source instanceof org.jsoup.nodes.DataNode) { org.jsoup.nodes.DataNode sourceData = (org.jsoup.nodes.DataNode) source; Text node = doc.createTextNode(sourceData.getWholeData()); dest.appendChild(node); } else { // unhandled } }
file.appendChild(doc.createComment(name));
private static void addMimeComment(Mode mode, Element rootElement, Document doc) { Node mimeComment = doc.createComment( "for example: <mimeTypeRepository resource=\"/org/apache/tika/mime/tika-mimetypes.xml\"/>"); rootElement.appendChild(mimeComment); }
/** * Lexical Handler method to create comment node in DOM tree. */ public void comment(char[] ch, int start, int length) { final Node last = (Node) _nodeStk.peek(); Comment comment = _document.createComment(new String(ch, start, length)); if (comment != null) last.appendChild(comment); }
protected void appendDOMTree(org.w3c.dom.Document domDocument, org.w3c.dom.Node domCurrent, Comment comment) { org.w3c.dom.Comment domComment = domDocument.createComment(comment .getText()); domCurrent.appendChild(domComment); }
/** * This will handle printing of a {@link Comment}. * * @param fstack * the FormatStack * @param basedoc * The org.w3c.dom.Document for creating DOM Nodes * @param comment * <code>Comment</code> to write. * @return The input JDOM Comment converted to a DOM Comment */ protected org.w3c.dom.Comment printComment(final FormatStack fstack, final org.w3c.dom.Document basedoc, final Comment comment) { return basedoc.createComment(comment.getText()); }
private static void addCommentBefore(final Element element, final String comment, final Document document) { if (null == XmlUtils.findNode("//comment()[.=' " + comment + " ']", document.getDocumentElement())) { document.getDocumentElement().insertBefore(document.createComment(" " + comment + " "), element); addLineBreakBefore(element, document); } }
private static void addTranslator(Mode mode, Element rootElement, Document doc, TikaConfig config) { // Unlike the other entries, TikaConfig only wants one of // these, and no outer <translators> list Translator translator = config.getTranslator(); if (mode == Mode.MINIMAL && translator instanceof DefaultTranslator) { Node mimeComment = doc.createComment( "for example: <translator class=\"org.apache.tika.language.translate.GoogleTranslator\"/>"); rootElement.appendChild(mimeComment); } else { if (translator instanceof DefaultTranslator && (mode == Mode.STATIC || mode == Mode.STATIC_FULL)) { translator = ((DefaultTranslator)translator).getTranslator(); } if (translator != null) { Element translatorElement = doc.createElement("translator"); translatorElement.setAttribute("class", translator.getClass().getCanonicalName()); rootElement.appendChild(translatorElement); } else { rootElement.appendChild(doc.createComment("No translators available")); } } }
private static void addEncodingDetectors(Mode mode, Element rootElement, Document doc, TikaConfig config) throws Exception { EncodingDetector encDetector = config.getEncodingDetector(); if (mode == Mode.MINIMAL && encDetector instanceof DefaultEncodingDetector) { // Don't output anything, all using defaults Node detComment = doc.createComment( "for example: <encodingDetectors><encodingDetector class=\"" + "org.apache.tika.detect.DefaultEncodingDetector\"></encodingDetectors>"); rootElement.appendChild(detComment); return; } Element encDetectorsElement = doc.createElement("encodingDetectors"); if (mode == Mode.CURRENT && encDetector instanceof DefaultEncodingDetector || ! (encDetector instanceof CompositeEncodingDetector)) { Element encDetectorElement = doc.createElement("encodingDetector"); encDetectorElement.setAttribute("class", encDetector.getClass().getCanonicalName()); encDetectorsElement.appendChild(encDetectorElement); } else { List<EncodingDetector> children = ((CompositeEncodingDetector)encDetector).getDetectors(); for (EncodingDetector d : children) { Element encDetectorElement = doc.createElement("encodingDetector"); encDetectorElement.setAttribute("class", d.getClass().getCanonicalName()); encDetectorsElement.appendChild(encDetectorElement); } } rootElement.appendChild(encDetectorsElement); }
private static void addDetectors(Mode mode, Element rootElement, Document doc, TikaConfig config) throws Exception { Detector detector = config.getDetector(); if (mode == Mode.MINIMAL && detector instanceof DefaultDetector) { // Don't output anything, all using defaults Node detComment = doc.createComment( "for example: <detectors><detector class=\"org.apache.tika.detector.MimeTypes\"></detectors>"); rootElement.appendChild(detComment); return; } Element detectorsElement = doc.createElement("detectors"); if (mode == Mode.CURRENT && detector instanceof DefaultDetector || ! (detector instanceof CompositeDetector)) { Element detectorElement = doc.createElement("detector"); detectorElement.setAttribute("class", detector.getClass().getCanonicalName()); detectorsElement.appendChild(detectorElement); } else { List<Detector> children = ((CompositeDetector)detector).getDetectors(); for (Detector d : children) { Element detectorElement = doc.createElement("detector"); detectorElement.setAttribute("class", d.getClass().getCanonicalName()); detectorsElement.appendChild(detectorElement); } } rootElement.appendChild(detectorsElement); }
private void appendChild(Element e, XhtmlNode node) { if (node.getNodeType() == NodeType.Comment) e.appendChild(e.getOwnerDocument().createComment(node.getContent())); else if (node.getNodeType() == NodeType.DocType) throw new Error("not done yet"); else if (node.getNodeType() == NodeType.Instruction) e.appendChild(e.getOwnerDocument().createProcessingInstruction("", node.getContent())); else if (node.getNodeType() == NodeType.Text) e.appendChild(e.getOwnerDocument().createTextNode(node.getContent())); else if (node.getNodeType() == NodeType.Element) { Element child = e.getOwnerDocument().createElementNS(XHTML_NS, node.getName()); e.appendChild(child); for (XhtmlNode c : node.getChildNodes()) { appendChild(child, c); } } else throw new Error("Unknown node type: "+node.getNodeType().toString()); }