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

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

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

Element.insertBefore介绍

暂无

代码示例

代码示例来源: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: 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: marytts/marytts

  1. /**
  2. * Create a new <mtu> element, inserted in the tree at the position of t and enclosing t.
  3. *
  4. * @param t
  5. * the <t> element to enclose
  6. * @param orig
  7. * the original text for the MTU, saved in the orig attribute
  8. * @param accentPosition
  9. * optionally, specify an accent position, saved in the accent attribute of the mtu element. If null, no accent
  10. * attribute is inserted.
  11. * @return the newly created MTU element.
  12. */
  13. public static Element encloseWithMTU(Element t, String orig, String accentPosition) {
  14. if (!t.getNodeName().equals(MaryXML.TOKEN))
  15. throw new DOMException(DOMException.INVALID_ACCESS_ERR, "Only t elements allowed, received " + t.getNodeName() + ".");
  16. Element parent = (Element) t.getParentNode();
  17. assert parent != null;
  18. Document doc = t.getOwnerDocument();
  19. Element mtu = MaryXML.createElement(doc, MaryXML.MTU);
  20. mtu.setAttribute("orig", orig);
  21. // Which of the components gets a possible accent:
  22. if (accentPosition != null)
  23. mtu.setAttribute("accent", accentPosition);
  24. parent.insertBefore(mtu, t);
  25. mtu.appendChild(t);
  26. return mtu;
  27. }

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

  1. /**
  2. * Create a new <mtu> element, inserted in the tree at the position of t and enclosing t.
  3. *
  4. * @param t
  5. * the <t> element to enclose
  6. * @param orig
  7. * the original text for the MTU, saved in the orig attribute
  8. * @param accentPosition
  9. * optionally, specify an accent position, saved in the accent attribute of the mtu element. If null, no accent
  10. * attribute is inserted.
  11. * @return the newly created MTU element.
  12. */
  13. public static Element encloseWithMTU(Element t, String orig, String accentPosition) {
  14. if (!t.getNodeName().equals(MaryXML.TOKEN))
  15. throw new DOMException(DOMException.INVALID_ACCESS_ERR, "Only t elements allowed, received " + t.getNodeName() + ".");
  16. Element parent = (Element) t.getParentNode();
  17. assert parent != null;
  18. Document doc = t.getOwnerDocument();
  19. Element mtu = MaryXML.createElement(doc, MaryXML.MTU);
  20. mtu.setAttribute("orig", orig);
  21. // Which of the components gets a possible accent:
  22. if (accentPosition != null)
  23. mtu.setAttribute("accent", accentPosition);
  24. parent.insertBefore(mtu, t);
  25. mtu.appendChild(t);
  26. return mtu;
  27. }

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

  1. parent.insertBefore(el, insertBefore);

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

  1. grandParent.insertBefore(mtu, parent);
  2. grandParent.removeChild(parent);

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

  1. grandParent.insertBefore(mtu, parent);
  2. grandParent.removeChild(parent);

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

  1. grandParent.insertBefore(mtu, parent);
  2. grandParent.removeChild(parent);

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

  1. /**
  2. * Create a new <t> element and insert it after t.
  3. *
  4. * @param t
  5. * t
  6. * @param newTokenText
  7. * newTokenText
  8. * @return the new <t> element.
  9. */
  10. public static Element appendToken(Element t, String newTokenText) {
  11. if (!t.getNodeName().equals(MaryXML.TOKEN))
  12. throw new DOMException(DOMException.INVALID_ACCESS_ERR, "Only t elements allowed, received " + t.getNodeName() + ".");
  13. Element parent = (Element) t.getParentNode();
  14. Document doc = t.getOwnerDocument();
  15. Element next = getNextSiblingElement(t);
  16. Element newT = MaryXML.createElement(doc, MaryXML.TOKEN);
  17. setTokenText(newT, newTokenText);
  18. parent.insertBefore(newT, next);
  19. return newT;
  20. }

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

  1. /**
  2. * Create a new <t> element and insert it after t.
  3. *
  4. * @param t
  5. * t
  6. * @param newTokenText
  7. * newTokenText
  8. * @return the new <t> element.
  9. */
  10. public static Element appendToken(Element t, String newTokenText) {
  11. if (!t.getNodeName().equals(MaryXML.TOKEN))
  12. throw new DOMException(DOMException.INVALID_ACCESS_ERR, "Only t elements allowed, received " + t.getNodeName() + ".");
  13. Element parent = (Element) t.getParentNode();
  14. Document doc = t.getOwnerDocument();
  15. Element next = getNextSiblingElement(t);
  16. Element newT = MaryXML.createElement(doc, MaryXML.TOKEN);
  17. setTokenText(newT, newTokenText);
  18. parent.insertBefore(newT, next);
  19. return newT;
  20. }

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

  1. private static void classToXML(Document xmldoc, Element parent, Class<?> clazz,
  2. String preAppendToSimpleClassName) throws Exception {
  3. XmlInclude incl=Util.getAnnotation(clazz, XmlInclude.class);
  4. if(incl != null) {
  5. String[] schemas=incl.schema();
  6. for (String schema : schemas) {
  7. Element incl_el = xmldoc.createElement(incl.type() == XmlInclude.Type.IMPORT ? "xs:import" : "xs:include");
  8. if (!incl.namespace().isEmpty())
  9. incl_el.setAttribute("namespace", incl.namespace());
  10. incl_el.setAttribute("schemaLocation", schema);
  11. Node first_child = xmldoc.getDocumentElement().getFirstChild();
  12. if (first_child == null)
  13. xmldoc.getDocumentElement().appendChild(incl_el);
  14. else
  15. xmldoc.getDocumentElement().insertBefore(incl_el, first_child);
  16. }
  17. if(!incl.alias().isEmpty())
  18. xmldoc.getDocumentElement().setAttribute("xmlns:" + incl.alias(), incl.namespace());
  19. }
  20. parent.appendChild(createXMLTree(xmldoc, clazz, preAppendToSimpleClassName));
  21. }

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

  1. first = docElement.getFirstChild();
  2. docElement.insertBefore(filter, first);
  3. final Element filterMapping = doc.createElement("filter-mapping");
  4. append(doc, filterMapping, "filter-name", "gemfire-session-filter");
  5. append(doc, filterMapping, "url-pattern", "/*");
  6. docElement.insertBefore(filterMapping, after(docElement, "filter"));
  7. return doc;

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

  1. boundary.setAttribute("breakindex", String.valueOf(bi));
  2. eIn.insertBefore(boundary, eBefore);

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

  1. boundary.setAttribute("breakindex", String.valueOf(bi));
  2. eIn.insertBefore(boundary, eBefore);

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

  1. while ((boundary = (Element) tw.previousNode()) != null) {
  2. assert boundary.getTagName().equals(MaryXML.BOUNDARY);
  3. firstParagraph.insertBefore(boundary, firstParagraph.getFirstChild());
  4. tw.setCurrentNode(firstParagraph);

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

  1. while ((boundary = (Element) tw.previousNode()) != null) {
  2. assert boundary.getTagName().equals(MaryXML.BOUNDARY);
  3. firstParagraph.insertBefore(boundary, firstParagraph.getFirstChild());
  4. tw.setCurrentNode(firstParagraph);

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

  1. Element newPh = MaryXML.createElement(doc, MaryXML.PHONE);
  2. newPh.setAttribute("p", predicted[lc]);
  3. syllable.insertBefore(newPh, s);

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

  1. Element newPh = MaryXML.createElement(doc, MaryXML.PHONE);
  2. newPh.setAttribute("p", predicted[lc]);
  3. syllable.insertBefore(newPh, s);

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

  1. e.insertBefore(grid, params);

代码示例来源:origin: spring-projects/spring-roo

  1. private Element createModulesElementIfNecessary(final Document pomDocument, final Element root) {
  2. Element modulesElement = XmlUtils.findFirstElement("/project/modules", root);
  3. if (modulesElement == null) {
  4. modulesElement = pomDocument.createElement("modules");
  5. final Element repositories = XmlUtils.findFirstElement("/project/repositories", root);
  6. root.insertBefore(modulesElement, repositories);
  7. }
  8. return modulesElement;
  9. }

相关文章