Package gnu.xml

Class XMLPrinter

    • Field Detail

      • printIndent

        protected int printIndent
      • indentAttributes

        public boolean indentAttributes
        When indenting, should attributes be lined up?
      • canonicalizeCDATA

        public boolean canonicalizeCDATA
      • useEmptyElementTag

        public int useEmptyElementTag
        Handling of empty elements. 0: No element element tags, as required for canonical XML: <br></br>. 1: Use XML-style empty element tags: <br/> 2: Use HTML-compatible empty element tags: <br /> but <p></p>.
      • escapeText

        public boolean escapeText
      • escapeNonAscii

        public boolean escapeNonAscii
      • extended

        public boolean extended
      • doctypeSystem

        public static final ThreadLocation doctypeSystem
        Fluid parameter to control whether a DOCTYPE declaration is emitted. If non-null, this is the the public identifier.
      • doctypePublic

        public static final ThreadLocation doctypePublic
        The system identifier emitted in a DOCTYPE declaration. Has no effect if doctypeSystem returns null. If non-null, this is the the system identifier.
    • Constructor Detail

      • XMLPrinter

        public XMLPrinter​(Writer out,
                          boolean autoFlush)
      • XMLPrinter

        public XMLPrinter​(Writer out)
      • XMLPrinter

        public XMLPrinter​(Consumer out)
    • Method Detail

      • setPrintXMLdecl

        public void setPrintXMLdecl​(boolean value)
      • toString

        public static String toString​(Object value)
        Convert argument to string in XML syntax.
      • setStyle

        public void setStyle​(Object style)
      • setEscapeText

        public void setEscapeText​(boolean v)
      • setEscapeNonAscii

        public void setEscapeNonAscii​(boolean v)
      • setCanonicalizeCDATA

        public void setCanonicalizeCDATA​(boolean v)
      • setUseEmptyElementTag

        public void setUseEmptyElementTag​(int v)
      • setExtended

        public void setExtended​(boolean v)
      • setIndent

        public void setIndent​(int v)
        Controls whether to add extra indentation. -1: don't add indentation; 0: pretty-print (avoid needless newlines); 1: indent (force).
      • closeTag

        public void closeTag()
      • writeQName

        protected void writeQName​(Object name)
      • writeDoctypeIfDefined

        public void writeDoctypeIfDefined​(String tagname)
        Write DOCTYPE using ThreadLocations doctypeSystem and doctypePublic
      • writeDoctype

        public void writeDoctype​(String tagname,
                                 String systemId,
                                 String publicId)
      • isHtmlEmptyElementTag

        public static boolean isHtmlEmptyElementTag​(String name)
      • endAttribute

        public void endAttribute()
        Description copied from interface: Consumer
        End of an attribute or end of an actual parameter. The former use matches a startAttribute; the latter may not, and can be used to separate parameters in a parameter list. This double duty suggsts the method should at least be re-named.
        Specified by:
        endAttribute in interface Consumer
        Overrides:
        endAttribute in class PrintConsumer
      • formatDouble

        public static String formatDouble​(double d)
        Helper to format xs:double according to XPath/XQuery specification.
      • formatFloat

        public static String formatFloat​(float f)
        Helper to format xs:float according to XPath/XQuery specification.
      • formatDecimal

        public static String formatDecimal​(BigDecimal dec)
        Format java.math.BigDecimal as needed for XPath/XQuery's xs:decimal. Specifically this means removing trailing fractional zeros, and a trailing decimal point. However, note that the XML Schema canonical representation does require a decimal point and at least one fractional digit.
      • ignoring

        public boolean ignoring()
        True if consumer is ignoring rest of element. The producer can use this information to skip ahead.
        Specified by:
        ignoring in interface Consumer
        Overrides:
        ignoring in class PrintConsumer
      • write

        public void write​(char[] buf,
                          int off,
                          int len)
        Specified by:
        write in interface Consumer
        Overrides:
        write in class PrintWriter
      • writePosition

        public void writePosition​(AbstractSequence seq,
                                  int ipos)
        Description copied from interface: PositionConsumer
        Consume a single position pair. This PositionConsumer may assume the sequence does no reference management; i.e. that copyPos is trivial and releasePos is a no-op. If that is not the case, use consume(TreePosition) instead.
        Specified by:
        writePosition in interface PositionConsumer
      • writeBaseUri

        public void writeBaseUri​(Object uri)
      • beginComment

        public void beginComment()
      • endComment

        public void endComment()
      • writeComment

        public void writeComment​(String chars)
      • writePosition

        public void writePosition​(SeqPosition position)
        Description copied from interface: PositionConsumer
        Consume node at current position. The caller may invalidate or change the position after consume returns, so if the consumer wants to save it, it needs to copy it.
        Specified by:
        writePosition in interface PositionConsumer