protected void _element(final Element element) throws IOException { String nodeName = resolveNodeName(element); appendable.append('<'); appendable.append(nodeName); int attrCount = element.getAttributesCount(); if (attrCount != 0) { for (int i = 0; i < attrCount; i++) { Attribute attr = element.getAttribute(i); appendable.append(' '); renderAttribute(element, attr, appendable); } } int childCount = element.getChildNodesCount(); if (element.selfClosed && childCount == 0) { appendable.append("/>"); return; } appendable.append('>'); if (element.voidElement) { return; } if (childCount != 0) { elementBody(element); } appendable.append("</"); appendable.append(nodeName); appendable.append('>'); }
/** * Renders attribute. */ protected void renderAttribute(final Node node, final Attribute attribute, final Appendable appendable) throws IOException { String name = resolveAttributeName(node, attribute); String value = attribute.getValue(); appendable.append(name); if (value != null) { appendable.append('='); appendable.append('\"'); appendable.append(HtmlEncoder.attributeDoubleQuoted(value)); appendable.append('\"'); } }
protected NodeVisitor createRenderer(final Appendable appendable) { return new LagartoHtmlRendererNodeVisitor(appendable); }
@Override public void element(final Element element) { try { _element(element); } catch (IOException ioex) { throw new LagartoDOMException(ioex); } }
@Override protected void elementBody(Element element) throws IOException { boolean hasXML = element.hasAttribute("xml-attrib"); // detects XML content if (hasXML) { configXML(); } super.elementBody(element); if (hasXML) { configHtml(); } }
@Override public void document(Document document) { configHtml(); super.document(document); }
public void element(Element element) { try { _element(element); } catch (IOException ioex) { throw new LagartoDOMException(ioex); } }
protected void _element(final Element element) throws IOException { String nodeName = resolveNodeName(element); appendable.append('<'); appendable.append(nodeName); int attrCount = element.getAttributesCount(); if (attrCount != 0) { for (int i = 0; i < attrCount; i++) { Attribute attr = element.getAttribute(i); appendable.append(' '); renderAttribute(element, attr, appendable); } } int childCount = element.getChildNodesCount(); if (element.selfClosed && childCount == 0) { appendable.append("/>"); return; } appendable.append('>'); if (element.voidElement) { return; } if (childCount != 0) { elementBody(element); } appendable.append("</"); appendable.append(nodeName); appendable.append('>'); }
@Override protected String resolveAttributeName(Node node, Attribute attribute) { String attributeName = attribute.getRawName(); if (attributeName.contains("_") || attributeName.contains("-")) { return attributeName; } return super.resolveAttributeName(node, attribute); }
@Override public void element(final Element element) { try { _element(element); } catch (IOException ioex) { throw new LagartoDOMException(ioex); } }
protected NodeVisitor createRenderer(final Appendable appendable) { return new LagartoHtmlRendererNodeVisitor(appendable); }
protected void _element(Element element) throws IOException { String nodeName = resolveNodeName(element); appendable.append('<'); appendable.append(nodeName); int attrCount = element.getAttributesCount(); if (attrCount != 0) { for (int i = 0; i < attrCount; i++) { Attribute attr = element.getAttribute(i); appendable.append(' '); renderAttribute(element, attr, appendable); } } int childCount = element.getChildNodesCount(); if (element.selfClosed && childCount == 0) { appendable.append("/>"); return; } appendable.append('>'); if (element.voidElement) { return; } if (childCount != 0) { elementBody(element); } appendable.append("</"); appendable.append(nodeName); appendable.append('>'); }
/** * Renders attribute. */ protected void renderAttribute(final Node node, final Attribute attribute, final Appendable appendable) throws IOException { String name = resolveAttributeName(node, attribute); String value = attribute.getValue(); appendable.append(name); if (value != null) { appendable.append('='); appendable.append('\"'); appendable.append(HtmlEncoder.attributeDoubleQuoted(value)); appendable.append('\"'); } }
protected NodeVisitor createRenderer(Appendable appendable) { return new LagartoHtmlRendererNodeVisitor(appendable); }
/** * Renders attribute. */ protected void renderAttribute(Node node, Attribute attribute, Appendable appendable) throws IOException { String name = resolveAttributeName(node, attribute); String value = attribute.getValue(); appendable.append(name); if (value != null) { appendable.append('='); appendable.append('\"'); appendable.append(HtmlEncoder.attributeDoubleQuoted(value)); appendable.append('\"'); } }