org.w3c.dom.Document.createCDATASection()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(177)

本文整理了Java中org.w3c.dom.Document.createCDATASection()方法的一些代码示例,展示了Document.createCDATASection()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Document.createCDATASection()方法的具体详情如下:
包路径:org.w3c.dom.Document
类名称:Document
方法名:createCDATASection

Document.createCDATASection介绍

[英]Creates a CDATASection node whose value is the specified string.
[中]创建一个CDATASection节点,其值为指定的字符串。

代码示例

代码示例来源:origin: plutext/docx4j

/**
 * Writes the CDATA section to the DOM.
 *
 * <p>Does nothing if the object is <code>null</code>.
 *
 * @param data The data to write to the section.
 *
 * @throws DOMException If thrown by method invoked on the underlying DOM document
 */
public void writeCDATA(String data) {
 if (data == null) return;
 this.document.createCDATASection(data);
}

代码示例来源:origin: pmd/pmd

private Element createCDATASectionElement(String name, String value) {
    Element element = document.createElementNS(RULESET_2_0_0_NS_URI, name);
    CDATASection cdataSection = document.createCDATASection(value);
    element.appendChild(cdataSection);
    return element;
  }
}

代码示例来源:origin: cucumber/cucumber-jvm

private Element createElement(Document doc, StringBuilder sb, String elementType) {
  Element child = doc.createElement(elementType);
  // the createCDATASection method seems to convert "\n" to "\r\n" on Windows, in case
  // data originally contains "\r\n" line separators the result becomes "\r\r\n", which
  // are displayed as double line breaks.
  // TODO Java 7 PR #1147: Inlined System.lineSeparator()
  String systemLineSeperator = System.getProperty("line.separator");
  child.appendChild(doc.createCDATASection(sb.toString().replace(systemLineSeperator, "\n")));
  return child;
}

代码示例来源:origin: cucumber/cucumber-jvm

private Element createException(Document doc, String clazz, String message, String stacktrace) {
    Element exceptionElement = doc.createElement("exception");
    exceptionElement.setAttribute("class", clazz);
    if (message != null) {
      Element messageElement = doc.createElement("message");
      messageElement.appendChild(doc.createCDATASection(message));
      exceptionElement.appendChild(messageElement);
    }
    Element stacktraceElement = doc.createElement("full-stacktrace");
    stacktraceElement.appendChild(doc.createCDATASection(stacktrace));
    exceptionElement.appendChild(stacktraceElement);
    return exceptionElement;
  }
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Adds a nested CDATA section.
 *
 * <p>This means
 * <pre>appendCDATA(&lt;a&gt;, "b")</pre>
 * creates
 * <pre>
 * &lt;a&gt;&lt;[!CDATA[b]]&gt;&lt;/a&gt;
 * </pre>
 *
 * @param parent element that will receive the new element as child.
 * @param content text content.
 *
 * @since Ant 1.6.3
 */
public static void appendCDATA(Element parent, String content) {
  Document doc = parent.getOwnerDocument();
  CDATASection c = doc.createCDATASection(content);
  parent.appendChild(c);
}

代码示例来源:origin: pmd/pmd

private Element addCodeSnippet(Document doc, Element duplication, Match match) {
  String codeSnipet = match.getSourceCodeSlice();
  if (codeSnipet != null) {
    Element codefragment = doc.createElement("codefragment");
    codefragment.appendChild(doc.createCDATASection(codeSnipet));
    duplication.appendChild(codefragment);
  }
  return duplication;
}

代码示例来源:origin: plantuml/plantuml

private Element getPathHover(String hover) {
  final Element style = simpleElement("style");
  final CDATASection cdata = document.createCDATASection("path:hover { stroke: " + hover + " !important;}");
  style.setAttribute("type", "text/css");
  style.appendChild(cdata);
  return style;
}

代码示例来源:origin: robovm/robovm

/**
 * Report the start of a CDATA section.
 *
 * @see #endCDATA
 */
public void startCDATA() throws org.xml.sax.SAXException
{
 m_inCData = true;
 append(m_doc.createCDATASection(""));
}

代码示例来源:origin: xalan/xalan

/**
 * Report the start of a CDATA section.
 *
 * @see #endCDATA
 */
public void startCDATA() throws org.xml.sax.SAXException
{
 m_inCData = true;
 append(m_doc.createCDATASection(""));
}

代码示例来源:origin: aragozin/jvm-tools

private void importDataSet(String flameName, Element e) {
  JsonFlameDataSet dataSet = datasets.get(flameName);
  if (dataSet == null) {
    throw new IllegalArgumentException("Unknown data set name: " + flameName);
  }
  for(Text t: textOf(e)) {
    e.removeChild(t);
  }
  
  StringBuilder sb = new StringBuilder();
  sb.append("$(document).ready(function() {createFlameChart(\"" + flameName + "\", ");
  dataSet.exportJson(sb);
  sb.append(").initFlameChart()});\n");
  Text text = e.getOwnerDocument().createCDATASection(sb.toString());
  e.appendChild(text);
}

代码示例来源:origin: aragozin/jvm-tools

Text text = e.getOwnerDocument().createCDATASection(sb.toString());
e.appendChild(text);

代码示例来源:origin: pmd/pmd

settingsElement.appendChild(codeElement);
codeElement.setAttribute("language-version", getLanguageVersion().getTerseName());
codeElement.appendChild(document.createCDATASection(codeEditorPane.getText()));
xpathElement.appendChild(document.createCDATASection(xpathQueryArea.getText()));

代码示例来源:origin: pmd/pmd

@Override
public void visit(SimpleBeanModelNode node, Element parent) {
  Element nodeElement = parent.getOwnerDocument().createElement(SCHEMA_NODE_ELEMENT);
  nodeElement.setAttribute(SCHEMA_NODE_CLASS_ATTRIBUTE, node.getNodeType().getCanonicalName());
  for (Entry<String, Object> keyValue : node.getSettingsValues().entrySet()) {
    // I don't think the API is intended to be used like that
    // but ConvertUtils wouldn't use the convertToString methods
    // defined in the converters otherwise.
    // Even when a built-in converter is available, objects are
    // still converted with Object::toString which fucks up the
    // conversion...
    String value = (String) ConvertUtils.lookup(keyValue.getValue().getClass()).convert(String.class, keyValue.getValue());
    if (value == null) {
      continue;
    }
    Element setting = parent.getOwnerDocument().createElement(SCHEMA_PROPERTY_ELEMENT);
    setting.setAttribute(SCHEMA_PROPERTY_NAME, keyValue.getKey());
    setting.setAttribute(SCHEMA_PROPERTY_TYPE, node.getSettingsTypes().get(keyValue.getKey()).getCanonicalName());
    setting.appendChild(parent.getOwnerDocument().createCDATASection(value));
    nodeElement.appendChild(setting);
  }
  parent.appendChild(nodeElement);
  super.visit(node, nodeElement);
}

代码示例来源:origin: org.netbeans.api/org-openide-filesystems

file.appendChild(doc.createCDATASection(contents));

代码示例来源:origin: jphp-group/jphp

used.remove(value.getPointer());
} else {
  property.appendChild(document.createCDATASection(Base64.encodeBase64String("**RECURSION**".getBytes())));
  used.remove(value.getPointer());
} else {
  property.appendChild(document.createCDATASection(Base64.encodeBase64String("**RECURSION**".getBytes())));
property.appendChild(document.createCDATASection(Base64.encodeBase64String(bytes)));
break;

代码示例来源:origin: org.apache.ant/ant

Text errText = doc.createCDATASection(StringUtils.getStackTrace(t));
Element stacktrace = doc.createElement(STACKTRACE_TAG);
stacktrace.appendChild(errText);

代码示例来源:origin: org.apache.ant/ant

Text errText = doc.createCDATASection(StringUtils.getStackTrace(ex));
  Element stacktrace = doc.createElement(STACKTRACE_TAG);
  stacktrace.appendChild(errText);
  synchronizedAppend(buildElement.element, stacktrace);
Text messageText = doc.createCDATASection(event.getMessage());
messageElement.appendChild(messageText);

代码示例来源:origin: camunda/camunda-bpm-platform

public void addCDataSection(String data) {
 synchronized (document) {
  CDATASection cdataSection = document.createCDATASection(data);
  element.appendChild(cdataSection);
 }
}

代码示例来源:origin: pentaho/mondrian

private Object cdata(String content, Element parent) {
  CDATASection section = factory.createCDATASection(content);
  parent.appendChild(section);
  return section;
}

代码示例来源:origin: mulesoft/mule

private Element createTransformTextElement(ComponentConfiguration config) {
 String namespaceURI = EE_NAMESPACE;
 String eeSchemaLocation = buildSchemaLocation(EE_PREFIX, EE_NAMESPACE);
 addNamespaceDeclarationIfNeeded(EE_PREFIX, namespaceURI, eeSchemaLocation);
 Element nested = doc.createElementNS(namespaceURI, EE_PREFIX + ":" + config.getIdentifier().getName());
 config.getParameters().forEach(nested::setAttribute);
 config.getNestedComponents().stream()
   .filter(inner -> inner.getValue().isPresent())
   .forEach(inner -> nested.appendChild(doc.createCDATASection(inner.getValue().get())));
 return nested;
}

相关文章

微信公众号

最新文章

更多

Document类方法