|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.caucho.xml.XmlPrinter
Controls printing of XML documents.
Typical use:
Node node = ...;
OutputStream os = Vfs.openWrite("test.xml");
XmlPrinter printer = new XmlPrinter(os);
printer.print(node);
Constructor Summary | |
XmlPrinter()
Create an XmlPrinter. |
|
XmlPrinter(java.io.OutputStream os)
Creates a new XmlPrinter writing to an output stream. |
|
XmlPrinter(java.io.Writer writer)
Creates a new XmlPrinter writing to a writer. |
Method Summary | |
void |
addCdataElement(java.lang.String elt)
|
void |
attribute(java.lang.String uri,
java.lang.String localName,
java.lang.String qName,
java.lang.String value)
Prints an attribute |
void |
cdata(char[] buffer,
int offset,
int length)
|
void |
cdata(java.lang.String text)
|
void |
comment(java.lang.String data)
Prints a comment |
void |
endDocument()
|
void |
endElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName)
Prints the end tag of an element |
void |
finishAttributes()
Complete printing of the attributes when the open tag completes. |
boolean |
getEscapeText()
Returns true if the text is currently being escaped |
boolean |
getEscaping()
Returns the current XML escaping. |
com.caucho.java.LineMap |
getLineMap()
|
void |
init(WriteStream os)
Initialize the XmlPrinter with the write stream. |
boolean |
isPretty()
|
void |
print(Node node)
|
void |
printHtml(Node node)
Prints the node as HTML |
static void |
printHtml(java.io.OutputStream os,
Node node)
Prints the node as HTML |
void |
printNode(Node node)
|
void |
printPrettyXml(Node node)
|
static void |
printPrettyXml(java.io.OutputStream os,
Node node)
Prints the node as indented HTML |
java.lang.String |
printString(Node node)
Prints the node as XML to a string. |
void |
printXml(Node node)
Prints the node as XML. |
static void |
printXml(java.io.OutputStream os,
Node node)
Prints the node as XML. |
void |
processingInstruction(java.lang.String name,
java.lang.String data)
Prints a processing instruction |
void |
setEncoding(java.lang.String encoding)
|
void |
setEscapeText(boolean isEscaped)
Sets true if the text should be escaped, else it will be printed verbatim. |
void |
setEscaping(boolean escapeText)
Sets to true if XML entities like < should be escaped as <. |
void |
setLineMap(java.lang.String filename)
|
void |
setLocation(java.lang.String filename,
int line,
int column)
Sets the current location. |
void |
setMethod(java.lang.String method)
Sets the output methods, like the XSL <xsl:output method='method'/>. |
void |
setMimeType(java.lang.String mimeType)
|
void |
setPretty(boolean isPretty)
|
void |
setPrintDeclaration(boolean printDeclaration)
|
void |
setPublicId(java.lang.String id)
|
void |
setStandalone(java.lang.String standalone)
|
void |
setSystemId(java.lang.String id)
|
void |
setVersion(java.lang.String version)
|
void |
startDocument()
|
void |
startDocument(Document document)
|
void |
startElement(java.lang.String url,
java.lang.String localName,
java.lang.String qName)
Called at the start of a new element. |
void |
text(char[] buffer,
int offset,
int length)
Prints text. |
void |
text(java.lang.String text)
Prints text. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public XmlPrinter()
public XmlPrinter(java.io.OutputStream os)
os
- output stream serving as the destinationpublic XmlPrinter(java.io.Writer writer)
writer
- destination of the serialized nodeMethod Detail |
public void init(WriteStream os)
os
- WriteStream containing the results.public static void printXml(java.io.OutputStream os, Node node) throws java.io.IOException
os
- destination output streamnode
- source DOM nodepublic static void printHtml(java.io.OutputStream os, Node node) throws java.io.IOException
os
- destination output streamnode
- source DOM nodepublic static void printPrettyXml(java.io.OutputStream os, Node node) throws java.io.IOException
os
- destination output streamnode
- source DOM nodepublic void printXml(Node node) throws java.io.IOException
node
- source DOM nodepublic void printHtml(Node node) throws java.io.IOException
public void printPrettyXml(Node node) throws java.io.IOException
public java.lang.String printString(Node node) throws java.io.IOException
node
- the source nodepublic void setEscaping(boolean escapeText)
escapeText
- set to true if entities should be escaped.public boolean getEscaping()
public void setMethod(java.lang.String method)
public void setVersion(java.lang.String version)
public void setEncoding(java.lang.String encoding)
public void setMimeType(java.lang.String mimeType)
public void setPretty(boolean isPretty)
public boolean isPretty()
public void setPrintDeclaration(boolean printDeclaration)
public void setStandalone(java.lang.String standalone)
public void setSystemId(java.lang.String id)
public void setPublicId(java.lang.String id)
public void setLineMap(java.lang.String filename)
public com.caucho.java.LineMap getLineMap()
public void addCdataElement(java.lang.String elt)
public void printNode(Node node) throws java.io.IOException
public void print(Node node) throws java.io.IOException
public void startDocument(Document document) throws java.io.IOException
public void startDocument() throws java.io.IOException
startDocument
in interface XMLWriter
public void endDocument() throws java.io.IOException
endDocument
in interface XMLWriter
public void setLocation(java.lang.String filename, int line, int column)
setLocation
in interface XMLWriter
public void startElement(java.lang.String url, java.lang.String localName, java.lang.String qName) throws java.io.IOException
startElement
in interface XMLWriter
url
- the namespace urllocalName
- the local nameqName
- the qualified namepublic void attribute(java.lang.String uri, java.lang.String localName, java.lang.String qName, java.lang.String value) throws java.io.IOException
attribute
in interface XMLWriter
uri
- namespace urilocalName
- localname of the attributeqName
- qualified name of the attributevalue
- value of the attribute.public void finishAttributes() throws java.io.IOException
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) throws java.io.IOException
endElement
in interface XMLWriter
uri
- the namespace uri of the elementlocalName
- the localname of the element tagqName
- qualified name of the elementpublic void processingInstruction(java.lang.String name, java.lang.String data) throws java.io.IOException
processingInstruction
in interface XMLWriter
name
- the name of the processing instructiondata
- the processing instruction datapublic void comment(java.lang.String data) throws java.io.IOException
comment
in interface XMLWriter
data
- the comment datapublic boolean getEscapeText()
getEscapeText
in interface XMLWriter
public void setEscapeText(boolean isEscaped)
setEscapeText
in interface XMLWriter
public void text(java.lang.String text) throws java.io.IOException
text
in interface XMLWriter
public void text(char[] buffer, int offset, int length) throws java.io.IOException
text
in interface XMLWriter
public void cdata(java.lang.String text) throws java.io.IOException
cdata
in interface XMLWriter
public void cdata(char[] buffer, int offset, int length) throws java.io.IOException
cdata
in interface XMLWriter
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |