public Element prependChild(Element element) { xomElement.insertChild(element.xomElement, 0); return this; }
public Element prependChild(Element element) { xomElement.insertChild(element.xomElement, 0); return this; }
public Element prependText(String text) { xomElement.insertChild(new nu.xom.Text(text), 0); return this; }
/** 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); }
public Element prependText(String text) { xomElement.insertChild(new nu.xom.Text(text), 0); return this; }
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); } }; }
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); }
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); }
/** 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(); } /**
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()); } } } }
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()); } } } }
/** * 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); } }
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); }
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); }
/** * 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); } }
/** * 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); } }
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); } }
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); } }
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); } }
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); } }