Class XmlTrim

java.lang.Object
org.libxmq.imp.xml.XmlTrim

public final class XmlTrim extends Object
Whitespace trimming of a DOM loaded from xml or html, exactly like the C version of xmq does after reading xml/html (xmqTrimWhitespace and xmq_fixup_comments_after_readin in xmq.c). All whitespace only text nodes are removed and the incidental indentation is removed from the remaining text and comment nodes.
  • Method Details

    • trimWhitespace

      public static void trimWhitespace(XmlDocument doc)
      Trim the whitespace of all text and comment nodes in the document, like the C function xmqTrimWhitespace.
      Parameters:
      doc - The document to trim.
    • fixupCommentsAfterReadin

      public static void fixupCommentsAfterReadin(XmlDocument doc)
      Remove the dle escapes from comments, like the C function xmq_fixup_comments_after_readin. An xml comment containing -␐- (a dle escaped double dash) is replaced with --.
      Parameters:
      doc - The document to fix.
    • fixupHtmlBeforeWriteout

      public static void fixupHtmlBeforeWriteout(XmlDocument doc)
      Prepare a document for writing as xml or html, like the C function xmq_fixup_html_before_writeout: comments containing -- are escaped with the dle char, cdata sections become text and entity references inside style and script elements are replaced by text.
      Parameters:
      doc - The document to fix.
    • trim_xml_text

      public static String trim_xml_text(String v)
      Trim a text value like the C xmq_trim_quote(v, is_xmq=false, is_comment=false).
      Parameters:
      v - The text value.
      Returns:
      The trimmed value.