public class ContentPrinter extends DefaultContentHandler
ContentHandler
and
LexicalHandler
.
PrintStream
or sim.
Modifier and Type | Field and Description |
---|---|
protected int |
attcol |
protected boolean |
beforeFirstElement |
protected boolean |
declareXml |
protected XMLDocumentIdentifier |
dtdDocId |
protected int |
indent |
protected int |
maxwidth |
static String |
newAttLineIndent |
static int |
newAttLineIndentLen |
protected boolean |
noendtags
Only for compact debugging output: endtags are omitted and reflected
by indentation only.
|
protected Set<NamespaceName> |
noindent |
protected boolean |
openTagPending |
protected PrintWriter |
out |
protected boolean |
pretty |
protected boolean |
reindent |
protected String |
selectedEncoding |
static String |
surrogateErrorIndication |
static String |
xml_version |
Constructor and Description |
---|
ContentPrinter(OutputStream out,
String selectedEncoding)
Insert an encoder with the given encoding name between the
output and the selected drain.
|
ContentPrinter(OutputStream out,
String selectedEncoding,
boolean pretty) |
ContentPrinter(OutputStream out,
String selectedEncoding,
boolean pretty,
boolean noend)
Creates a ContentPrinter which can omit all end tags.
|
ContentPrinter(OutputStream out,
String selectedEncoding,
Set<NamespaceName> noindent)
Creates a ContentPrinter which inserts indentation ONLY inside of
elements which do not have mixed contents.
|
ContentPrinter(PrintWriter out) |
ContentPrinter(PrintWriter out,
boolean pretty) |
ContentPrinter(PrintWriter out,
boolean pretty,
boolean noend) |
ContentPrinter(PrintWriter out,
Set<NamespaceName> noindent)
Creates a ContentPrinter which inserts indentation ONLY inside of
elements which do not have mixed contents.
|
Modifier and Type | Method and Description |
---|---|
void |
characters(char[] ch,
int start,
int length) |
void |
comment(char[] ch,
int start,
int length)
Print comment to output; assume no double dashes and no trailing dash
are contained [XSLT 1.0:7.4]
FIXME indentation etc. |
void |
comment(String s) |
void |
comment(String s,
boolean linefeed) |
protected void |
doWrite(char[] ch,
int start,
int length,
boolean inAtt,
boolean replaceDoubleQuote)
Prints character data in text contents (ie.
|
void |
endDocument() |
void |
endElement(String namespaceURI,
String localName,
String qName) |
void |
endPrefixMapping(String prefix) |
void |
flush() |
protected void |
flushPending()
close the open tag of an element.
|
void |
ignorableWhitespace(char[] ch,
int start,
int length) |
protected void |
indent()
Start a new line and advance to the column given by
indent ,
the current identation depth, reflecting open and close element events. |
protected void |
printAtt(String name,
String v) |
void |
processingInstruction(String target,
String data) |
ContentPrinter |
setDeclareXml(boolean declareXml)
Whether an XML type declaration shall be printed at the start of the
generaterd output.
|
ContentPrinter |
setDtdDocId(XMLDocumentIdentifier dtdDocId)
The dtd adress of the doctype declaration which will be printed
inserted in the generated output, iff !=null
|
ContentPrinter |
setLineWidth(int maxwidth) |
void |
skippedEntity(String name) |
void |
startDocument() |
void |
startElement(String namespaceURI,
String localName,
String qName,
Attributes atts) |
void |
startPrefixMapping(String prefix,
String uri) |
endCDATA, endDTD, endEntity, setDocumentLocator, startCDATA, startDTD, startEntity
protected PrintWriter out
protected boolean pretty
protected boolean noendtags
protected Set<NamespaceName> noindent
protected String selectedEncoding
protected transient boolean declareXml
protected transient XMLDocumentIdentifier dtdDocId
protected transient int maxwidth
public static final String xml_version
public static final String surrogateErrorIndication
public static final String newAttLineIndent
public static final int newAttLineIndentLen
protected transient boolean beforeFirstElement
protected transient boolean reindent
protected transient int indent
protected transient int attcol
protected transient boolean openTagPending
public ContentPrinter(OutputStream out, String selectedEncoding) throws UnsupportedEncodingException
XML 1.0
"UnsupportedEncodingException
public ContentPrinter(OutputStream out, String selectedEncoding, boolean pretty) throws UnsupportedEncodingException
out
- where to print the output toselectedEncoding
- pretty
- whether to insert indentationsUnsupportedEncodingException
public ContentPrinter(OutputStream out, String selectedEncoding, boolean pretty, boolean noend) throws UnsupportedEncodingException
pretty==true
, as a more compact rendering
for human readers, e.g. for debugging.out
- where to print the output toselectedEncoding
- pretty
- whether to insert indentations (always or-ed with "noend")noend
- whether to leave out the end tagUnsupportedEncodingException
public ContentPrinter(OutputStream out, String selectedEncoding, Set<NamespaceName> noindent) throws UnsupportedEncodingException
out
- where to print the output toselectedEncoding
- noindent
- elements in which no identation may happenUnsupportedEncodingException
public ContentPrinter(PrintWriter out)
public ContentPrinter(PrintWriter out, boolean pretty)
public ContentPrinter(PrintWriter out, boolean pretty, boolean noend)
public ContentPrinter(PrintWriter out, Set<NamespaceName> noindent) throws UnsupportedEncodingException
out
- where to print the output tonoindent
- elements in which no identation may happenUnsupportedEncodingException
public ContentPrinter setDeclareXml(boolean declareXml)
public ContentPrinter setDtdDocId(XMLDocumentIdentifier dtdDocId)
public ContentPrinter setLineWidth(int maxwidth)
protected void doWrite(char[] ch, int start, int length, boolean inAtt, boolean replaceDoubleQuote)
surrogateErrorIndication
is inserted in the outout.public void comment(char[] ch, int start, int length) throws SAXException
comment
in interface LexicalHandler
comment
in class DefaultContentHandler
SAXException
public void comment(String s, boolean linefeed) throws SAXException
SAXException
public void comment(String s) throws SAXException
SAXException
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
ignorableWhitespace
in interface ContentHandler
ignorableWhitespace
in class DefaultContentHandler
SAXException
public void characters(char[] ch, int start, int length)
characters
in interface ContentHandler
characters
in class DefaultContentHandler
public void endElement(String namespaceURI, String localName, String qName)
endElement
in interface ContentHandler
endElement
in class DefaultContentHandler
public void processingInstruction(String target, String data)
processingInstruction
in interface ContentHandler
processingInstruction
in class DefaultContentHandler
public void skippedEntity(String name)
skippedEntity
in interface ContentHandler
skippedEntity
in class DefaultContentHandler
public void startDocument()
startDocument
in interface ContentHandler
startDocument
in class DefaultContentHandler
public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
startElement
in interface ContentHandler
startElement
in class DefaultContentHandler
public void startPrefixMapping(String prefix, String uri)
startPrefixMapping
in interface ContentHandler
startPrefixMapping
in class DefaultContentHandler
public void endPrefixMapping(String prefix)
endPrefixMapping
in interface ContentHandler
endPrefixMapping
in class DefaultContentHandler
protected void flushPending()
public void flush()
public void endDocument()
endDocument
in interface ContentHandler
endDocument
in class DefaultContentHandler
protected void indent()
see also the complete user documentation .