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

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

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

Element.insertBefore介绍

暂无

代码示例

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

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

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

/**
 * Create a new <mtu> element, inserted in the tree at the position of t and enclosing t.
 * 
 * @param t
 *            the <t> element to enclose
 * @param orig
 *            the original text for the MTU, saved in the orig attribute
 * @param accentPosition
 *            optionally, specify an accent position, saved in the accent attribute of the mtu element. If null, no accent
 *            attribute is inserted.
 * @return the newly created MTU element.
 */
public static Element encloseWithMTU(Element t, String orig, String accentPosition) {
  if (!t.getNodeName().equals(MaryXML.TOKEN))
    throw new DOMException(DOMException.INVALID_ACCESS_ERR, "Only t elements allowed, received " + t.getNodeName() + ".");
  Element parent = (Element) t.getParentNode();
  assert parent != null;
  Document doc = t.getOwnerDocument();
  Element mtu = MaryXML.createElement(doc, MaryXML.MTU);
  mtu.setAttribute("orig", orig);
  // Which of the components gets a possible accent:
  if (accentPosition != null)
    mtu.setAttribute("accent", accentPosition);
  parent.insertBefore(mtu, t);
  mtu.appendChild(t);
  return mtu;
}

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

/**
 * Create a new <mtu> element, inserted in the tree at the position of t and enclosing t.
 * 
 * @param t
 *            the <t> element to enclose
 * @param orig
 *            the original text for the MTU, saved in the orig attribute
 * @param accentPosition
 *            optionally, specify an accent position, saved in the accent attribute of the mtu element. If null, no accent
 *            attribute is inserted.
 * @return the newly created MTU element.
 */
public static Element encloseWithMTU(Element t, String orig, String accentPosition) {
  if (!t.getNodeName().equals(MaryXML.TOKEN))
    throw new DOMException(DOMException.INVALID_ACCESS_ERR, "Only t elements allowed, received " + t.getNodeName() + ".");
  Element parent = (Element) t.getParentNode();
  assert parent != null;
  Document doc = t.getOwnerDocument();
  Element mtu = MaryXML.createElement(doc, MaryXML.MTU);
  mtu.setAttribute("orig", orig);
  // Which of the components gets a possible accent:
  if (accentPosition != null)
    mtu.setAttribute("accent", accentPosition);
  parent.insertBefore(mtu, t);
  mtu.appendChild(t);
  return mtu;
}

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

parent.insertBefore(el, insertBefore);

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

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

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

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

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

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

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

/**
 * Create a new <t> element and insert it after t.
 * 
 * @param t
 *            t
 * @param newTokenText
 *            newTokenText
 * @return the new <t> element.
 */
public static Element appendToken(Element t, String newTokenText) {
  if (!t.getNodeName().equals(MaryXML.TOKEN))
    throw new DOMException(DOMException.INVALID_ACCESS_ERR, "Only t elements allowed, received " + t.getNodeName() + ".");
  Element parent = (Element) t.getParentNode();
  Document doc = t.getOwnerDocument();
  Element next = getNextSiblingElement(t);
  Element newT = MaryXML.createElement(doc, MaryXML.TOKEN);
  setTokenText(newT, newTokenText);
  parent.insertBefore(newT, next);
  return newT;
}

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

/**
 * Create a new <t> element and insert it after t.
 * 
 * @param t
 *            t
 * @param newTokenText
 *            newTokenText
 * @return the new <t> element.
 */
public static Element appendToken(Element t, String newTokenText) {
  if (!t.getNodeName().equals(MaryXML.TOKEN))
    throw new DOMException(DOMException.INVALID_ACCESS_ERR, "Only t elements allowed, received " + t.getNodeName() + ".");
  Element parent = (Element) t.getParentNode();
  Document doc = t.getOwnerDocument();
  Element next = getNextSiblingElement(t);
  Element newT = MaryXML.createElement(doc, MaryXML.TOKEN);
  setTokenText(newT, newTokenText);
  parent.insertBefore(newT, next);
  return newT;
}

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

private static void classToXML(Document xmldoc, Element parent, Class<?> clazz,
                String preAppendToSimpleClassName) throws Exception {
  XmlInclude incl=Util.getAnnotation(clazz, XmlInclude.class);
  if(incl != null) {
    String[] schemas=incl.schema();
    for (String schema : schemas) {
      Element incl_el = xmldoc.createElement(incl.type() == XmlInclude.Type.IMPORT ? "xs:import" : "xs:include");
      if (!incl.namespace().isEmpty())
        incl_el.setAttribute("namespace", incl.namespace());
      incl_el.setAttribute("schemaLocation", schema);
      Node first_child = xmldoc.getDocumentElement().getFirstChild();
      if (first_child == null)
        xmldoc.getDocumentElement().appendChild(incl_el);
      else
        xmldoc.getDocumentElement().insertBefore(incl_el, first_child);
    }
    if(!incl.alias().isEmpty())
      xmldoc.getDocumentElement().setAttribute("xmlns:" + incl.alias(), incl.namespace());
  }
  parent.appendChild(createXMLTree(xmldoc, clazz, preAppendToSimpleClassName));
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

e.insertBefore(grid, params);

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

private Element createModulesElementIfNecessary(final Document pomDocument, final Element root) {
 Element modulesElement = XmlUtils.findFirstElement("/project/modules", root);
 if (modulesElement == null) {
  modulesElement = pomDocument.createElement("modules");
  final Element repositories = XmlUtils.findFirstElement("/project/repositories", root);
  root.insertBefore(modulesElement, repositories);
 }
 return modulesElement;
}

相关文章

微信公众号

最新文章

更多