public static void addReturnBeforeChild(Element e, Node child) { if (!ignoreLineBreaks) { Document doc = e.getOwnerDocument(); e.insertBefore(doc.createTextNode("\n"), child); } }
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); } }
/** * 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; }
/** * 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; }
parent.insertBefore(el, insertBefore);
grandParent.insertBefore(mtu, parent); grandParent.removeChild(parent);
grandParent.insertBefore(mtu, parent); grandParent.removeChild(parent);
grandParent.insertBefore(mtu, parent); grandParent.removeChild(parent);
/** * 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; }
/** * 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; }
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)); }
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;
boundary.setAttribute("breakindex", String.valueOf(bi)); eIn.insertBefore(boundary, eBefore);
boundary.setAttribute("breakindex", String.valueOf(bi)); eIn.insertBefore(boundary, eBefore);
while ((boundary = (Element) tw.previousNode()) != null) { assert boundary.getTagName().equals(MaryXML.BOUNDARY); firstParagraph.insertBefore(boundary, firstParagraph.getFirstChild()); tw.setCurrentNode(firstParagraph);
while ((boundary = (Element) tw.previousNode()) != null) { assert boundary.getTagName().equals(MaryXML.BOUNDARY); firstParagraph.insertBefore(boundary, firstParagraph.getFirstChild()); tw.setCurrentNode(firstParagraph);
Element newPh = MaryXML.createElement(doc, MaryXML.PHONE); newPh.setAttribute("p", predicted[lc]); syllable.insertBefore(newPh, s);
Element newPh = MaryXML.createElement(doc, MaryXML.PHONE); newPh.setAttribute("p", predicted[lc]); syllable.insertBefore(newPh, s);
e.insertBefore(grid, params);
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; }