本文整理了Java中org.w3c.dom.Element.getOwnerDocument()
方法的一些代码示例,展示了Element.getOwnerDocument()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getOwnerDocument()
方法的具体详情如下:
包路径:org.w3c.dom.Element
类名称:Element
方法名:getOwnerDocument
暂无
代码示例来源:origin: apache/hive
private Element appendElement(Element parent, String name, String text) {
Document document = parent.getOwnerDocument();
Element child = document.createElement(name);
parent.appendChild(child);
if (text != null) {
Text textNode = document.createTextNode(text);
child.appendChild(textNode);
}
return child;
}
代码示例来源:origin: plutext/docx4j
/**
* Method addReturnToElement
*
* @param e
*/
public static void addReturnToElement(Element e) {
if (!ignoreLineBreaks) {
Document doc = e.getOwnerDocument();
e.appendChild(doc.createTextNode("\n"));
}
}
代码示例来源:origin: plutext/docx4j
public static void addReturnBeforeChild(Element e, Node child) {
if (!ignoreLineBreaks) {
Document doc = e.getOwnerDocument();
e.insertBefore(doc.createTextNode("\n"), child);
}
}
代码示例来源:origin: apache/nifi
private void addStringElement(final Element parentElement, final String elementName, final String value) {
final Element childElement = parentElement.getOwnerDocument().createElement(elementName);
childElement.setTextContent(value);
parentElement.appendChild(childElement);
}
代码示例来源:origin: marytts/marytts
/**
* Enclose the elements' closest common ancestor.
*
* @param first
* first
* @param last
* last
*/
protected void slowDown(Element first, Element last) {
Element phonol = MaryDomUtils.encloseNodesWithNewElement(first, last, MaryXML.PHONOLOGY);
phonol.setAttribute("precision", "precise");
Document doc = phonol.getOwnerDocument();
Element prosody = MaryXML.createElement(doc, MaryXML.PROSODY);
prosody.setAttribute("rate", "-20%");
phonol.getParentNode().insertBefore(prosody, phonol);
prosody.appendChild(phonol);
}
}
代码示例来源:origin: marytts/marytts
private void prependSchwa(Element currentSegment) {
Element syllable = (Element) currentSegment.getParentNode();
assert syllable != null;
Element schwa = MaryXML.createElement(syllable.getOwnerDocument(), MaryXML.PHONE);
schwa.setAttribute("p", "@");
syllable.insertBefore(schwa, currentSegment);
}
}
代码示例来源: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
if (isStyleSheet(e)) {
Element re = head.getOwnerDocument().createElement("style");
head.replaceChild(re, e);
importCss(href, re);
代码示例来源:origin: apache/hive
private Element appendElement(Element parent, String name, String text) {
Document document = parent.getOwnerDocument();
Element child = document.createElement(name);
parent.appendChild(child);
if (text != null) {
Text textNode = document.createTextNode(text);
child.appendChild(textNode);
}
return child;
}
代码示例来源:origin: apache/nifi
private static void addTextElement(final Element element, final String name, final String value) {
final Document doc = element.getOwnerDocument();
final Element toAdd = doc.createElement(name);
toAdd.setTextContent(CharacterFilterUtils.filterInvalidXmlCharacters(value)); // value should already be filtered, but just in case ensure there are no invalid xml characters
element.appendChild(toAdd);
}
代码示例来源:origin: marytts/marytts
/**
* Enclose the elements' closest common ancestor.
*
* @param first
* first
* @param last
* last
*/
protected void slowDown(Element first, Element last) {
Element phonol = MaryDomUtils.encloseNodesWithNewElement(first, last, MaryXML.PHONOLOGY);
phonol.setAttribute("precision", "precise");
Document doc = phonol.getOwnerDocument();
Element prosody = MaryXML.createElement(doc, MaryXML.PROSODY);
prosody.setAttribute("rate", "-20%");
phonol.getParentNode().insertBefore(prosody, phonol);
prosody.appendChild(phonol);
}
}
代码示例来源:origin: groovy/groovy-core
public static void setValue(Element self, String value) {
Node firstChild = self.getFirstChild();
if (firstChild == null) {
firstChild = self.getOwnerDocument().createTextNode(value);
self.appendChild(firstChild);
}
firstChild.setNodeValue(value);
}
代码示例来源:origin: marytts/marytts
TreeWalker tw = ((DocumentTraversal) sentence.getOwnerDocument()).createTreeWalker(sentence, NodeFilter.SHOW_ELEMENT,
new NameNodeFilter(new String[] { MaryXML.PHONE, MaryXML.BOUNDARY }), false);
float totalDurationInSeconds = 0f;
element.setAttribute("end", String.format(Locale.US, "%.3f", totalDurationInSeconds));
} else {
代码示例来源:origin: apache/nifi
public static void addTemplate(final Element element, final Template template) {
try {
final byte[] serialized = TemplateSerializer.serialize(template.getDetails());
final DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
final DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
final Document document;
try (final InputStream in = new ByteArrayInputStream(serialized)) {
document = docBuilder.parse(in);
}
final Node templateNode = element.getOwnerDocument().importNode(document.getDocumentElement(), true);
element.appendChild(templateNode);
} catch (final Exception e) {
throw new FlowSerializationException(e);
}
}
}
代码示例来源:origin: apache/nifi
private static void addVariable(final Element parentElement, final String variableName, final String variableValue) {
final Element variableElement = parentElement.getOwnerDocument().createElement("variable");
variableElement.setAttribute("name", variableName);
variableElement.setAttribute("value", variableValue);
parentElement.appendChild(variableElement);
}
代码示例来源:origin: apache/nifi
private static void addTextElement(final Element element, final String name, final Optional<String> value) {
if (!value.isPresent()) {
return;
}
final Document doc = element.getOwnerDocument();
final Element toAdd = doc.createElement(name);
toAdd.setTextContent(CharacterFilterUtils.filterInvalidXmlCharacters(value.get())); // value should already be filtered, but just in case ensure there are no invalid xml characters
element.appendChild(toAdd);
}
代码示例来源:origin: marytts/marytts
/**
* Enclose the elements' closest common ancestor.
*
* @param first
* first
* @param last
* last
*/
protected void slowDown(Element first, Element last) {
Element phonol = MaryDomUtils.encloseNodesWithNewElement(first, last, MaryXML.PHONOLOGY);
phonol.setAttribute("precision", "precise");
Document doc = phonol.getOwnerDocument();
Element prosody = MaryXML.createElement(doc, MaryXML.PROSODY);
prosody.setAttribute("rate", "-20%");
phonol.getParentNode().insertBefore(prosody, phonol);
prosody.appendChild(phonol);
}
}
代码示例来源:origin: org.apache.ant/ant
/**
* Adds nested text.
*
* <p>This means
* <pre>appendText(<a>, "b")</pre>
* creates
* <pre>
* <a>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 appendText(Element parent, String content) {
Document doc = parent.getOwnerDocument();
Text t = doc.createTextNode(content);
parent.appendChild(t);
}
代码示例来源:origin: marytts/marytts
TreeWalker tw = ((DocumentTraversal) sentence.getOwnerDocument()).createTreeWalker(sentence, NodeFilter.SHOW_ELEMENT,
new NameNodeFilter(new String[] { MaryXML.PHONE, MaryXML.BOUNDARY }), false);
float totalDurationInSeconds = 0f;
element.setAttribute("end", String.format(Locale.US, "%.3f", totalDurationInSeconds));
} else {
代码示例来源:origin: apache/nifi
private void addStyle(final Element parentElement, final Map<String, String> style) {
final Element element = parentElement.getOwnerDocument().createElement("styles");
for (final Map.Entry<String, String> entry : style.entrySet()) {
final Element styleElement = parentElement.getOwnerDocument().createElement("style");
styleElement.setAttribute("name", entry.getKey());
styleElement.setTextContent(entry.getValue());
element.appendChild(styleElement);
}
parentElement.appendChild(element);
}
内容来源于网络,如有侵权,请联系作者删除!