Print an event stream in XML format on a PrintWriter.
canonicalizeCDATA
public boolean canonicalizeCDATA
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.
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.
escapeNonAscii
public boolean escapeNonAscii
escapeText
public boolean escapeText
indentAttributes
public boolean indentAttributes
When indentating, should attributes be lined up?
printIndent
public int printIndent
Controls whether to add extra indentation.
-1: don't add indentation; 0: pretty-print (avoid needless newlines);
1: indent (force).
strict
public boolean strict
useEmptyElementTag
public int useEmptyElementTag
Handling of empty elements.
0: No element element tags, as required for canonical XML:
.
1: Use XML-style empty element tags:
2: Use HTML-compatible empty element tags:
XMLPrinter
public XMLPrinter(OutputStream out)
XMLPrinter
public XMLPrinter(OutputStream out,
boolean autoFlush)
XMLPrinter
public XMLPrinter(OutputStream out,
Path path)
XMLPrinter
public XMLPrinter(Writer out)
XMLPrinter
public XMLPrinter(Writer out,
boolean autoFlush)
XMLPrinter
public XMLPrinter(OutPort out,
boolean autoFlush)
beginComment
public void beginComment()
closeTag
public void closeTag()
consume
public void consume(SeqPosition position)
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.
- consume in interface PositionConsumer
endAttribute
public void endAttribute()
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.
- endAttribute in interface Consumer
- endAttribute in interface OutPort
endComment
public void endComment()
error
public void error(String msg,
String code)
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.
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.
ignoring
public boolean ignoring()
True if consumer is ignoring rest of element.
The producer can use this information to skip ahead.
- ignoring in interface Consumer
- ignoring in interface PrintConsumer
isHtmlEmptyElementTag
public static boolean isHtmlEmptyElementTag(String name)
setPrintXMLdecl
public void setPrintXMLdecl(boolean value)
setStyle
public void setStyle(Object style)
startAttribute
public void startAttribute(Object attrType)
Write a attribute for the current element.
This is only allowed immediately after a startElement.
- startAttribute in interface Consumer
- startAttribute in interface OutPort
toString
public static String toString(Object value)
Convert argument to string in XML syntax.
write
public void write(String str,
int start,
int length)
write
public void write(char[] buf,
int off,
int len)
- write in interface Consumer
writeBaseUri
public void writeBaseUri(Object uri)
writeCDATA
public void writeCDATA(char[] chars,
int offset,
int length)
- writeCDATA in interface XConsumer
writeComment
public void writeComment(String chars)
writeComment
public void writeComment(char[] chars,
int offset,
int length)
- writeComment in interface XConsumer
writePosition
public void writePosition(AbstractSequence seq,
int ipos)
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.
- writePosition in interface PositionConsumer
writeQName
protected void writeQName(Object name)