private void writeDocType(XhtmlNode node) throws IOException { dst.append("<!" + node.getContent() + ">\r\n"); }
private void writeInstruction(XhtmlNode node) throws IOException { dst.append("<?" + node.getContent() + "?>\r\n"); }
private void writeComment(String indent, XhtmlNode node, boolean noPrettyOverride) throws IOException { dst.append(indent + "<!-- " + node.getContent().trim() + " -->" + (pretty && !noPrettyOverride ? "\r\n" : "")); }
public String allText() { if (childNodes == null || childNodes.isEmpty()) return getContent(); StringBuilder b = new StringBuilder(); for (XhtmlNode n : childNodes) if (n.getNodeType() == NodeType.Text) b.append(n.getContent()); else if (n.getNodeType() == NodeType.Element) b.append(n.allText()); return b.toString(); }
private void writeText(XhtmlNode node) throws IOException { for (char c : node.getContent().toCharArray())
private void appendChild(Element e, XhtmlNode node) { if (node.getNodeType() == NodeType.Comment) e.appendChild(e.getOwnerDocument().createComment(node.getContent())); else if (node.getNodeType() == NodeType.DocType) throw new Error("not done yet"); else if (node.getNodeType() == NodeType.Instruction) e.appendChild(e.getOwnerDocument().createProcessingInstruction("", node.getContent())); else if (node.getNodeType() == NodeType.Text) e.appendChild(e.getOwnerDocument().createTextNode(node.getContent())); else if (node.getNodeType() == NodeType.Element) { Element child = e.getOwnerDocument().createElementNS(XHTML_NS, node.getName()); e.appendChild(child); for (XhtmlNode c : node.getChildNodes()) { appendChild(child, c); } } else throw new Error("Unknown node type: "+node.getNodeType().toString()); }
private boolean composePlainText(XhtmlNode x, StringBuilder b, boolean lastWS) { if (x.getNodeType() == NodeType.Text) { String s = x.getContent(); if (!lastWS & (s.startsWith(" ") || s.startsWith("\r") || s.startsWith("\n") || s.endsWith("\t"))) { b.append(" ");
public void compose(IXMLWriter xml, XhtmlNode node, boolean noPrettyOverride) throws IOException { if (node.getNodeType() == NodeType.Comment) xml.comment(node.getContent(), pretty && !noPrettyOverride); else if (node.getNodeType() == NodeType.Element) composeElement(xml, node, noPrettyOverride); else if (node.getNodeType() == NodeType.Text) xml.text(node.getContent()); else throw new Error("Unhandled node type: "+node.getNodeType().toString()); }
private void addNode(List<Piece> list, XhtmlNode c) { if (c.getNodeType() == NodeType.Text) list.add(new Piece(null, c.getContent(), null)); else if (c.getNodeType() == NodeType.Element) { if (c.getName().equals("a")) {
return; case Comment: xml.comment(n.getContent(), true); return; case Text: xml.text(n.getContent()); return; case Element:
private void writeDocType(XhtmlNode node) throws IOException { dst.append("<!" + node.getContent() + ">\r\n"); }
private void writeInstruction(XhtmlNode node) throws IOException { dst.append("<?" + node.getContent() + "?>\r\n"); }
private void writeComment(String indent, XhtmlNode node, boolean noPrettyOverride) throws IOException { dst.append(indent + "<!-- " + node.getContent().trim() + " -->" + (pretty && !noPrettyOverride ? "\r\n" : "")); }
public String allText() { if (childNodes == null || childNodes.isEmpty()) return getContent(); StringBuilder b = new StringBuilder(); for (XhtmlNode n : childNodes) if (n.getNodeType() == NodeType.Text) b.append(n.getContent()); else if (n.getNodeType() == NodeType.Element) b.append(n.allText()); return b.toString(); }
private void writeText(XhtmlNode node) throws IOException { for (char c : node.getContent().toCharArray())
private void appendChild(Element e, XhtmlNode node) { if (node.getNodeType() == NodeType.Comment) e.appendChild(e.getOwnerDocument().createComment(node.getContent())); else if (node.getNodeType() == NodeType.DocType) throw new Error("not done yet"); else if (node.getNodeType() == NodeType.Instruction) e.appendChild(e.getOwnerDocument().createProcessingInstruction("", node.getContent())); else if (node.getNodeType() == NodeType.Text) e.appendChild(e.getOwnerDocument().createTextNode(node.getContent())); else if (node.getNodeType() == NodeType.Element) { Element child = e.getOwnerDocument().createElementNS(XHTML_NS, node.getName()); e.appendChild(child); for (XhtmlNode c : node.getChildNodes()) { appendChild(child, c); } } else throw new Error("Unknown node type: "+node.getNodeType().toString()); }
private boolean composePlainText(XhtmlNode x, StringBuilder b, boolean lastWS) { if (x.getNodeType() == NodeType.Text) { String s = x.getContent(); if (!lastWS & (s.startsWith(" ") || s.startsWith("\r") || s.startsWith("\n") || s.endsWith("\t"))) { b.append(" ");
public void compose(IXMLWriter xml, XhtmlNode node, boolean noPrettyOverride) throws IOException { if (node.getNodeType() == NodeType.Comment) xml.comment(node.getContent(), pretty && !noPrettyOverride); else if (node.getNodeType() == NodeType.Element) composeElement(xml, node, noPrettyOverride); else if (node.getNodeType() == NodeType.Text) xml.text(node.getContent()); else throw new Error("Unhandled node type: "+node.getNodeType().toString()); }
private void addNode(List<Piece> list, XhtmlNode c) { if (c.getNodeType() == NodeType.Text) list.add(new Piece(null, c.getContent(), null)); else if (c.getNodeType() == NodeType.Element) { if (c.getName().equals("a")) {
return; case Comment: xml.comment(n.getContent(), true); return; case Text: xml.text(n.getContent()); return; case Element: