/** * 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); }
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; } }
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; }
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; } }
/** * Adds a nested CDATA section. * * <p>This means * <pre>appendCDATA(<a>, "b")</pre> * creates * <pre> * <a><[!CDATA[b]]></a> * </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); }
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; }
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; }
/** * Report the start of a CDATA section. * * @see #endCDATA */ public void startCDATA() throws org.xml.sax.SAXException { m_inCData = true; append(m_doc.createCDATASection("")); }
/** * Report the start of a CDATA section. * * @see #endCDATA */ public void startCDATA() throws org.xml.sax.SAXException { m_inCData = true; append(m_doc.createCDATASection("")); }
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); }
Text text = e.getOwnerDocument().createCDATASection(sb.toString()); e.appendChild(text);
settingsElement.appendChild(codeElement); codeElement.setAttribute("language-version", getLanguageVersion().getTerseName()); codeElement.appendChild(document.createCDATASection(codeEditorPane.getText())); xpathElement.appendChild(document.createCDATASection(xpathQueryArea.getText()));
@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); }
file.appendChild(doc.createCDATASection(contents));
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;
Text errText = doc.createCDATASection(StringUtils.getStackTrace(t)); Element stacktrace = doc.createElement(STACKTRACE_TAG); stacktrace.appendChild(errText);
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);
public void addCDataSection(String data) { synchronized (document) { CDATASection cdataSection = document.createCDATASection(data); element.appendChild(cdataSection); } }
private Object cdata(String content, Element parent) { CDATASection section = factory.createCDATASection(content); parent.appendChild(section); return section; }
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; }