public class CmsXmlSaxWriter
extends org.xml.sax.helpers.DefaultHandler
implements org.xml.sax.ext.LexicalHandler
This can be used for writing large XML files where keeping a DOM structure in memory might cause out-of-memory issues, like e.g. when writing the OpenCms export files.
It can also be used if a is needed that should
generate a XML / HTML file from a series of SAX events.ContentHandler
| 构造器和说明 |
|---|
CmsXmlSaxWriter()
Creates a SAX event handler that generates XML / HTML Strings from the events caught
using a new
and the OpenCms default encoding. |
CmsXmlSaxWriter(java.lang.String encoding)
Creates a SAX event handler that generates XML / HTML Strings from the events caught
using a new
and the given encoding. |
CmsXmlSaxWriter(java.io.Writer writer)
Creates a SAX event handler that generates XML / HTML Strings from the events caught
using a new
and the given encoding. |
CmsXmlSaxWriter(java.io.Writer writer,
java.lang.String encoding)
A SAX event handler that generates XML / HTML Strings from the events caught and writes them
to the given Writer.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
characters(char[] buf,
int offset,
int len) |
void |
comment(char[] ch,
int start,
int length) |
void |
endCDATA() |
void |
endDocument() |
void |
endDTD() |
void |
endElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qualifiedName) |
void |
endEntity(java.lang.String name) |
java.lang.String |
getEncoding()
Returns the encoding this XML Sax writer was initialized with.
|
java.io.Writer |
getWriter()
Returns the Writer where the XML is written to.
|
boolean |
isEscapeUnknownChars()
Returns
true if charactes that are not part of the selected encoding
are to be replaced with the HTML { entity representation
in the generated output (not in CDATA elements). |
boolean |
isEscapeXml()
Returns
true if XML entities are to be encoded in the generated output (not in CDATA elements). |
void |
setEncoding(java.lang.String value)
Sets the encoding to use for the generated output.
|
void |
setEscapeUnknownChars(boolean value)
If set to
true, then charactes that are not part of the selected encoding
are to be replaced with the XML { entity representation
in the generated output (not in CDATA elements). |
void |
setEscapeXml(boolean value)
If set to
true, then
XML entities are to be encoded in the generated output (not in CDATA elements). |
void |
startCDATA() |
void |
startDocument() |
void |
startDTD(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId) |
void |
startElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qualifiedName,
org.xml.sax.Attributes attributes) |
void |
startEntity(java.lang.String name) |
public CmsXmlSaxWriter()
StringWriter and the OpenCms default encoding.public CmsXmlSaxWriter(java.lang.String encoding)
StringWriter and the given encoding.encoding - the encoding for the XML filepublic CmsXmlSaxWriter(java.io.Writer writer)
StringWriter and the given encoding.writer - the Writer to write to output topublic CmsXmlSaxWriter(java.io.Writer writer,
java.lang.String encoding)
writer - the Writer to write to output toencoding - the encoding for the XML filepublic void characters(char[] buf,
int offset,
int len)
throws org.xml.sax.SAXException
characters 在接口中 org.xml.sax.ContentHandlercharacters 在类中 org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXExceptionContentHandler.characters(char[], int, int)public void comment(char[] ch,
int start,
int length)
comment 在接口中 org.xml.sax.ext.LexicalHandlerLexicalHandler.comment(char[], int, int)public void endCDATA()
throws org.xml.sax.SAXException
endCDATA 在接口中 org.xml.sax.ext.LexicalHandlerorg.xml.sax.SAXExceptionLexicalHandler.endCDATA()public void endDocument()
throws org.xml.sax.SAXException
endDocument 在接口中 org.xml.sax.ContentHandlerendDocument 在类中 org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXExceptionContentHandler.endDocument()public void endDTD()
endDTD 在接口中 org.xml.sax.ext.LexicalHandlerLexicalHandler.endDTD()public void endElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qualifiedName)
throws org.xml.sax.SAXException
endElement 在接口中 org.xml.sax.ContentHandlerendElement 在类中 org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXExceptionContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)public void endEntity(java.lang.String name)
endEntity 在接口中 org.xml.sax.ext.LexicalHandlerLexicalHandler.endEntity(java.lang.String)public java.lang.String getEncoding()
public java.io.Writer getWriter()
public boolean isEscapeUnknownChars()
true if charactes that are not part of the selected encoding
are to be replaced with the HTML { entity representation
in the generated output (not in CDATA elements).true if charactes that are not part of the selected encoding
are to be replaced with the HTML entity representationpublic boolean isEscapeXml()
true if XML entities are to be encoded in the generated output (not in CDATA elements).true if XML entities are to be encoded in the generated output (not in CDATA elements)public void setEncoding(java.lang.String value)
value - the encoding to use for the generated outputpublic void setEscapeUnknownChars(boolean value)
true, then charactes that are not part of the selected encoding
are to be replaced with the XML { entity representation
in the generated output (not in CDATA elements).value - indicates to escape unknown characters with XML entities or notpublic void setEscapeXml(boolean value)
true, then
XML entities are to be encoded in the generated output (not in CDATA elements).value - indicates to to escape characters with XML entities or notpublic void startCDATA()
startCDATA 在接口中 org.xml.sax.ext.LexicalHandlerLexicalHandler.startCDATA()public void startDocument()
throws org.xml.sax.SAXException
startDocument 在接口中 org.xml.sax.ContentHandlerstartDocument 在类中 org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXExceptionContentHandler.startDocument()public void startDTD(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId)
throws org.xml.sax.SAXException
startDTD 在接口中 org.xml.sax.ext.LexicalHandlerorg.xml.sax.SAXExceptionLexicalHandler.startDTD(java.lang.String, java.lang.String, java.lang.String)public void startElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qualifiedName,
org.xml.sax.Attributes attributes)
throws org.xml.sax.SAXException
startElement 在接口中 org.xml.sax.ContentHandlerstartElement 在类中 org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXExceptionContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)public void startEntity(java.lang.String name)
startEntity 在接口中 org.xml.sax.ext.LexicalHandlerLexicalHandler.startEntity(java.lang.String)