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, startEntityprotected 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"UnsupportedEncodingExceptionpublic ContentPrinter(OutputStream out, String selectedEncoding, boolean pretty) throws UnsupportedEncodingException
out - where to print the output toselectedEncoding - pretty - whether to insert indentationsUnsupportedEncodingExceptionpublic 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 tagUnsupportedEncodingExceptionpublic ContentPrinter(OutputStream out, String selectedEncoding, Set<NamespaceName> noindent) throws UnsupportedEncodingException
out - where to print the output toselectedEncoding - noindent - elements in which no identation may happenUnsupportedEncodingExceptionpublic 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 happenUnsupportedEncodingExceptionpublic 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 LexicalHandlercomment in class DefaultContentHandlerSAXExceptionpublic void comment(String s, boolean linefeed) throws SAXException
SAXExceptionpublic void comment(String s) throws SAXException
SAXExceptionpublic void ignorableWhitespace(char[] ch,
int start,
int length)
throws SAXException
ignorableWhitespace in interface ContentHandlerignorableWhitespace in class DefaultContentHandlerSAXExceptionpublic void characters(char[] ch,
int start,
int length)
characters in interface ContentHandlercharacters in class DefaultContentHandlerpublic void endElement(String namespaceURI, String localName, String qName)
endElement in interface ContentHandlerendElement in class DefaultContentHandlerpublic void processingInstruction(String target, String data)
processingInstruction in interface ContentHandlerprocessingInstruction in class DefaultContentHandlerpublic void skippedEntity(String name)
skippedEntity in interface ContentHandlerskippedEntity in class DefaultContentHandlerpublic void startDocument()
startDocument in interface ContentHandlerstartDocument in class DefaultContentHandlerpublic void startElement(String namespaceURI, String localName, String qName, Attributes atts)
startElement in interface ContentHandlerstartElement in class DefaultContentHandlerpublic void startPrefixMapping(String prefix, String uri)
startPrefixMapping in interface ContentHandlerstartPrefixMapping in class DefaultContentHandlerpublic void endPrefixMapping(String prefix)
endPrefixMapping in interface ContentHandlerendPrefixMapping in class DefaultContentHandlerprotected void flushPending()
public void flush()
public void endDocument()
endDocument in interface ContentHandlerendDocument in class DefaultContentHandlerprotected void indent()
see also the complete user documentation .