本文整理了Java中nu.xom.Element.insertChild()
方法的一些代码示例,展示了Element.insertChild()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.insertChild()
方法的具体详情如下:
包路径:nu.xom.Element
类名称:Element
方法名:insertChild
暂无
代码示例来源:origin: org.concordion/concordion
public Element prependChild(Element element) {
xomElement.insertChild(element.xomElement, 0);
return this;
}
代码示例来源:origin: concordion/concordion
public Element prependChild(Element element) {
xomElement.insertChild(element.xomElement, 0);
return this;
}
代码示例来源:origin: org.concordion/concordion
public Element prependText(String text) {
xomElement.insertChild(new nu.xom.Text(text), 0);
return this;
}
代码示例来源:origin: org.xml-cml/cmlxom
/** override insertChild.
* if newNode has parent detach()es first
* @param newNode
* @param pos
*/
public void insertChild(Node newNode, int pos) {
newNode.detach();
super.insertChild(newNode, pos);
}
代码示例来源:origin: concordion/concordion
public Element prependText(String text) {
xomElement.insertChild(new nu.xom.Text(text), 0);
return this;
}
代码示例来源:origin: com.io7m.kstructural/io7m-kstructural-frontend
private KSBrandAppender(
final Optional<Element> in_brand_top,
final Optional<Element> in_brand_bottom)
{
this.brand_start = NullCheck.notNull(in_brand_top);
this.brand_end = NullCheck.notNull(in_brand_bottom);
this.appender_start = (e) -> {
if (this.brand_start.isPresent()) {
e.insertChild(this.brand_start.get().copy(), 0);
}
};
this.appender_end = (e) -> {
if (this.brand_end.isPresent()) {
e.insertChild(this.brand_end.get().copy(), 0);
}
};
}
代码示例来源:origin: concordion/concordion
public void appendSister(Element element) {
nu.xom.Element xomParentElement = (nu.xom.Element) xomElement.getParent();
int elementIndex = xomParentElement.indexOf(xomElement);
xomParentElement.insertChild(element.xomElement, elementIndex + 1);
}
代码示例来源:origin: org.concordion/concordion
public void appendSister(Element element) {
nu.xom.Element xomParentElement = (nu.xom.Element) xomElement.getParent();
int elementIndex = xomParentElement.indexOf(xomElement);
xomParentElement.insertChild(element.xomElement, elementIndex + 1);
}
代码示例来源:origin: org.xml-cml/cmlxom
/** replace current element by its child nodes.
* does not work for root node
*
*/
public void replaceByChildren() {
Node parent = this.getParent();
if (parent == null) {
} else if (!(parent instanceof Element)) {
} else {
Element parentElement = (Element) parent;
int idx = parentElement.indexOf(this);
List<Node> nodeList = new ArrayList<Node>();
for (int i = 0; i < this.getChildCount(); i++) {
nodeList.add(this.getChild(i));
}
for (int i = 0; i < nodeList.size(); i++) {
Node node = nodeList.get(i);
node.detach();
parentElement.insertChild(node, idx + i);
}
}
this.detach();
}
/**
代码示例来源:origin: teiid/teiid
private static void appendNodes(Element elem, Nodes nodes) {
if (nodes != null) {
int size = nodes.size();
for (int i=0; i < size; i++) {
Node node = nodes.get(i);
if (node instanceof Attribute) {
elem.addAttribute((Attribute) node);
} else {
elem.insertChild(node, elem.getChildCount());
}
}
}
}
代码示例来源:origin: org.teiid/saxon-xom
private static void appendNodes(Element elem, Nodes nodes) {
if (nodes != null) {
int size = nodes.size();
for (int i=0; i < size; i++) {
Node node = nodes.get(i);
if (node instanceof Attribute) {
elem.addAttribute((Attribute) node);
} else {
elem.insertChild(node, elem.getChildCount());
}
}
}
}
代码示例来源:origin: org.xml-cml/cmlxom
/**
* transfers children of 'from' to 'to'.
*
* @param from
* (will be left with no children)
* @param to
* (will gain 'from' children appended after any existing
* children
*/
public static void transferChildren(Element from, Element to) {
int nc = from.getChildCount();
int tc = to.getChildCount();
for (int i = nc - 1; i >= 0; i--) {
Node child = from.getChild(i);
child.detach();
to.insertChild(child, tc);
}
}
代码示例来源:origin: org.concordion/concordion
private void addContentTypeMetadata(Element head) {
Element meta = new Element("meta");
meta.addAttribute(new Attribute("http-equiv", "content-type"));
meta.addAttribute(new Attribute("content", "text/html; charset=UTF-8"));
head.insertChild(meta, 0);
}
代码示例来源:origin: concordion/concordion
private void addContentTypeMetadata(Element head) {
Element meta = new Element("meta");
meta.addAttribute(new Attribute("http-equiv", "content-type"));
meta.addAttribute(new Attribute("content", "text/html; charset=UTF-8"));
head.insertChild(meta, 0);
}
代码示例来源:origin: org.concordion/concordion
/**
* Improves the structure of an HTML document. If the <head> section
* is missing, one is added at the top of the document and any nodes
* in front of the <body> section are moved into it.
*/
public void beforeParsing(Document document) {
Element html = document.getRootElement();
Check.isTrue("html".equals(html.getLocalName()),
"Only <html> documents are supported (<" + html.getLocalName() + "> is not)");
if (!hasHeadSection(html)) {
Element head = new Element("head");
copyNodesBeforeBodyIntoHead(html, head);
html.insertChild(head, 0);
}
}
代码示例来源:origin: concordion/concordion
/**
* Improves the structure of an HTML document. If the <head> section
* is missing, one is added at the top of the document and any nodes
* in front of the <body> section are moved into it.
*/
public void beforeParsing(Document document) {
Element html = document.getRootElement();
Check.isTrue("html".equals(html.getLocalName()),
"Only <html> documents are supported (<" + html.getLocalName() + "> is not)");
if (!hasHeadSection(html)) {
Element head = new Element("head");
copyNodesBeforeBodyIntoHead(html, head);
html.insertChild(head, 0);
}
}
代码示例来源:origin: org.concordion/concordion
public void beforeParsing(Document document) {
Element html = document.getRootElement();
Element head = html.getFirstChildElement("head");
Check.notNull(head, "<head> section is missing from document");
Element script = new Element("script");
script.addAttribute(new Attribute("type", "text/javascript") );
script.appendChild(javaScript);
head.insertChild(script, 0);
}
}
代码示例来源:origin: concordion/concordion
public void beforeParsing(Document document) {
Element html = document.getRootElement();
Element head = html.getFirstChildElement("head");
Check.notNull(head, "<head> section is missing from document");
Element script = new Element("script");
script.addAttribute(new Attribute("type", "text/javascript") );
script.appendChild(javaScript);
head.insertChild(script, 0);
}
}
代码示例来源:origin: concordion/concordion
public void beforeParsing(Document document) {
Element html = document.getRootElement();
Element head = html.getFirstChildElement("head");
Check.notNull(head, "<head> section is missing from document");
Element style = new Element("style");
String updatedStylesheetContent = updateConcordionNamespacePrefix(html, stylesheetContent);
style.appendChild(updatedStylesheetContent);
if (appendChild) {
head.appendChild(style);
} else {
head.insertChild(style, 0);
}
}
代码示例来源:origin: org.concordion/concordion
public void beforeParsing(Document document) {
Element html = document.getRootElement();
Element head = html.getFirstChildElement("head");
Check.notNull(head, "<head> section is missing from document");
Element style = new Element("style");
String updatedStylesheetContent = updateConcordionNamespacePrefix(html, stylesheetContent);
style.appendChild(updatedStylesheetContent);
if (appendChild) {
head.appendChild(style);
} else {
head.insertChild(style, 0);
}
}
内容来源于网络,如有侵权,请联系作者删除!