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

x33g5p2x  于2022-01-18 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(409)

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

Element.getOwnerDocument介绍

暂无

代码示例

代码示例来源:origin: apache/hive

  1. private Element appendElement(Element parent, String name, String text) {
  2. Document document = parent.getOwnerDocument();
  3. Element child = document.createElement(name);
  4. parent.appendChild(child);
  5. if (text != null) {
  6. Text textNode = document.createTextNode(text);
  7. child.appendChild(textNode);
  8. }
  9. return child;
  10. }

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

  1. /**
  2. * Method addReturnToElement
  3. *
  4. * @param e
  5. */
  6. public static void addReturnToElement(Element e) {
  7. if (!ignoreLineBreaks) {
  8. Document doc = e.getOwnerDocument();
  9. e.appendChild(doc.createTextNode("\n"));
  10. }
  11. }

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

  1. public static void addReturnBeforeChild(Element e, Node child) {
  2. if (!ignoreLineBreaks) {
  3. Document doc = e.getOwnerDocument();
  4. e.insertBefore(doc.createTextNode("\n"), child);
  5. }
  6. }

代码示例来源:origin: apache/nifi

  1. private void addStringElement(final Element parentElement, final String elementName, final String value) {
  2. final Element childElement = parentElement.getOwnerDocument().createElement(elementName);
  3. childElement.setTextContent(value);
  4. parentElement.appendChild(childElement);
  5. }

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

  1. /**
  2. * Enclose the elements' closest common ancestor.
  3. *
  4. * @param first
  5. * first
  6. * @param last
  7. * last
  8. */
  9. protected void slowDown(Element first, Element last) {
  10. Element phonol = MaryDomUtils.encloseNodesWithNewElement(first, last, MaryXML.PHONOLOGY);
  11. phonol.setAttribute("precision", "precise");
  12. Document doc = phonol.getOwnerDocument();
  13. Element prosody = MaryXML.createElement(doc, MaryXML.PROSODY);
  14. prosody.setAttribute("rate", "-20%");
  15. phonol.getParentNode().insertBefore(prosody, phonol);
  16. prosody.appendChild(phonol);
  17. }
  18. }

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

  1. private void prependSchwa(Element currentSegment) {
  2. Element syllable = (Element) currentSegment.getParentNode();
  3. assert syllable != null;
  4. Element schwa = MaryXML.createElement(syllable.getOwnerDocument(), MaryXML.PHONE);
  5. schwa.setAttribute("p", "@");
  6. syllable.insertBefore(schwa, currentSegment);
  7. }
  8. }

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

  1. private void importDataSet(String flameName, Element e) {
  2. JsonFlameDataSet dataSet = datasets.get(flameName);
  3. if (dataSet == null) {
  4. throw new IllegalArgumentException("Unknown data set name: " + flameName);
  5. }
  6. for(Text t: textOf(e)) {
  7. e.removeChild(t);
  8. }
  9. StringBuilder sb = new StringBuilder();
  10. sb.append("$(document).ready(function() {createFlameChart(\"" + flameName + "\", ");
  11. dataSet.exportJson(sb);
  12. sb.append(").initFlameChart()});\n");
  13. Text text = e.getOwnerDocument().createCDATASection(sb.toString());
  14. e.appendChild(text);
  15. }

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

  1. if (isStyleSheet(e)) {
  2. Element re = head.getOwnerDocument().createElement("style");
  3. head.replaceChild(re, e);
  4. importCss(href, re);

代码示例来源:origin: apache/hive

  1. private Element appendElement(Element parent, String name, String text) {
  2. Document document = parent.getOwnerDocument();
  3. Element child = document.createElement(name);
  4. parent.appendChild(child);
  5. if (text != null) {
  6. Text textNode = document.createTextNode(text);
  7. child.appendChild(textNode);
  8. }
  9. return child;
  10. }

代码示例来源:origin: apache/nifi

  1. private static void addTextElement(final Element element, final String name, final String value) {
  2. final Document doc = element.getOwnerDocument();
  3. final Element toAdd = doc.createElement(name);
  4. toAdd.setTextContent(CharacterFilterUtils.filterInvalidXmlCharacters(value)); // value should already be filtered, but just in case ensure there are no invalid xml characters
  5. element.appendChild(toAdd);
  6. }

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

  1. /**
  2. * Enclose the elements' closest common ancestor.
  3. *
  4. * @param first
  5. * first
  6. * @param last
  7. * last
  8. */
  9. protected void slowDown(Element first, Element last) {
  10. Element phonol = MaryDomUtils.encloseNodesWithNewElement(first, last, MaryXML.PHONOLOGY);
  11. phonol.setAttribute("precision", "precise");
  12. Document doc = phonol.getOwnerDocument();
  13. Element prosody = MaryXML.createElement(doc, MaryXML.PROSODY);
  14. prosody.setAttribute("rate", "-20%");
  15. phonol.getParentNode().insertBefore(prosody, phonol);
  16. prosody.appendChild(phonol);
  17. }
  18. }

代码示例来源:origin: groovy/groovy-core

  1. public static void setValue(Element self, String value) {
  2. Node firstChild = self.getFirstChild();
  3. if (firstChild == null) {
  4. firstChild = self.getOwnerDocument().createTextNode(value);
  5. self.appendChild(firstChild);
  6. }
  7. firstChild.setNodeValue(value);
  8. }

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

  1. TreeWalker tw = ((DocumentTraversal) sentence.getOwnerDocument()).createTreeWalker(sentence, NodeFilter.SHOW_ELEMENT,
  2. new NameNodeFilter(new String[] { MaryXML.PHONE, MaryXML.BOUNDARY }), false);
  3. float totalDurationInSeconds = 0f;
  4. element.setAttribute("end", String.format(Locale.US, "%.3f", totalDurationInSeconds));
  5. } else {

代码示例来源:origin: apache/nifi

  1. public static void addTemplate(final Element element, final Template template) {
  2. try {
  3. final byte[] serialized = TemplateSerializer.serialize(template.getDetails());
  4. final DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
  5. final DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
  6. final Document document;
  7. try (final InputStream in = new ByteArrayInputStream(serialized)) {
  8. document = docBuilder.parse(in);
  9. }
  10. final Node templateNode = element.getOwnerDocument().importNode(document.getDocumentElement(), true);
  11. element.appendChild(templateNode);
  12. } catch (final Exception e) {
  13. throw new FlowSerializationException(e);
  14. }
  15. }
  16. }

代码示例来源:origin: apache/nifi

  1. private static void addVariable(final Element parentElement, final String variableName, final String variableValue) {
  2. final Element variableElement = parentElement.getOwnerDocument().createElement("variable");
  3. variableElement.setAttribute("name", variableName);
  4. variableElement.setAttribute("value", variableValue);
  5. parentElement.appendChild(variableElement);
  6. }

代码示例来源:origin: apache/nifi

  1. private static void addTextElement(final Element element, final String name, final Optional<String> value) {
  2. if (!value.isPresent()) {
  3. return;
  4. }
  5. final Document doc = element.getOwnerDocument();
  6. final Element toAdd = doc.createElement(name);
  7. toAdd.setTextContent(CharacterFilterUtils.filterInvalidXmlCharacters(value.get())); // value should already be filtered, but just in case ensure there are no invalid xml characters
  8. element.appendChild(toAdd);
  9. }

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

  1. /**
  2. * Enclose the elements' closest common ancestor.
  3. *
  4. * @param first
  5. * first
  6. * @param last
  7. * last
  8. */
  9. protected void slowDown(Element first, Element last) {
  10. Element phonol = MaryDomUtils.encloseNodesWithNewElement(first, last, MaryXML.PHONOLOGY);
  11. phonol.setAttribute("precision", "precise");
  12. Document doc = phonol.getOwnerDocument();
  13. Element prosody = MaryXML.createElement(doc, MaryXML.PROSODY);
  14. prosody.setAttribute("rate", "-20%");
  15. phonol.getParentNode().insertBefore(prosody, phonol);
  16. prosody.appendChild(phonol);
  17. }
  18. }

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

  1. /**
  2. * Adds nested text.
  3. *
  4. * <p>This means
  5. * <pre>appendText(&lt;a&gt;, "b")</pre>
  6. * creates
  7. * <pre>
  8. * &lt;a&gt;b&lt;/a&gt;
  9. * </pre>
  10. *
  11. * @param parent element that will receive the new element as child.
  12. * @param content text content.
  13. *
  14. * @since Ant 1.6.3
  15. */
  16. public static void appendText(Element parent, String content) {
  17. Document doc = parent.getOwnerDocument();
  18. Text t = doc.createTextNode(content);
  19. parent.appendChild(t);
  20. }

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

  1. TreeWalker tw = ((DocumentTraversal) sentence.getOwnerDocument()).createTreeWalker(sentence, NodeFilter.SHOW_ELEMENT,
  2. new NameNodeFilter(new String[] { MaryXML.PHONE, MaryXML.BOUNDARY }), false);
  3. float totalDurationInSeconds = 0f;
  4. element.setAttribute("end", String.format(Locale.US, "%.3f", totalDurationInSeconds));
  5. } else {

代码示例来源:origin: apache/nifi

  1. private void addStyle(final Element parentElement, final Map<String, String> style) {
  2. final Element element = parentElement.getOwnerDocument().createElement("styles");
  3. for (final Map.Entry<String, String> entry : style.entrySet()) {
  4. final Element styleElement = parentElement.getOwnerDocument().createElement("style");
  5. styleElement.setAttribute("name", entry.getKey());
  6. styleElement.setTextContent(entry.getValue());
  7. element.appendChild(styleElement);
  8. }
  9. parentElement.appendChild(element);
  10. }

相关文章