|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xml.sax.helpers.DefaultHandler net.sf.fikin.xml.sax.SAXSerializer
public class SAXSerializer
SAX serializer
Prints received SAX events into XML document with minimum modifications.
Example:
SAXSerializer out = new SAXSerializer( new BufferedWriter( new FileWriter( file ) ) );
out.parse( input, XMLReaderFactory.createXMLReader() );
created on Aug 12, 2006
Field Summary | |
---|---|
protected boolean |
doIndent
whether to do newline+indent before every startElement ? |
protected int |
elementDepth
Element depth. |
protected boolean |
inCDATA
In CDATA section. |
protected java.lang.String |
indent
what is indent string if do indenting |
protected boolean |
isCanonical
Canonical output. |
protected boolean |
isPreviousStartElement
indicate that previous event was startElement, used to render single tags properly |
protected boolean |
isXML11
Processing XML 1.1 document. |
protected org.xml.sax.Locator |
locator
Document locator. |
protected java.util.Hashtable |
namespaces
parsed namespaces |
protected java.io.BufferedWriter |
output
output stream where result of the transformation is written |
Constructor Summary | |
---|---|
SAXSerializer()
|
|
SAXSerializer(java.io.BufferedWriter out)
|
Method Summary | |
---|---|
void |
characters(char[] ch,
int start,
int length)
copy the data without any processing |
void |
characters(java.lang.String str)
Report an XML comment anywhere in the document. |
void |
comment(char[] ch,
int start,
int length)
Report an XML comment anywhere in the document. |
void |
comment(java.lang.String str)
Report an XML comment anywhere in the document. |
void |
endCDATA()
Report the end of a CDATA section. |
void |
endDocument()
flush the output writer |
void |
endDTD()
Report the end of DTD declarations. |
void |
endElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName)
print closing tag |
void |
endEntity(java.lang.String name)
Report the end of an entity. |
void |
error(org.xml.sax.SAXParseException ex)
Error. |
void |
fatalError(org.xml.sax.SAXParseException ex)
Fatal error. |
org.xml.sax.Locator |
getDocumentLocator()
get document locator |
boolean |
getDoIndent()
|
java.lang.String |
getIndent()
|
boolean |
getIsXML11()
is output xml comatibility version 1.1 or 1.0 |
boolean |
getIsXMLCanonical()
is xml output canonical format |
protected java.util.Hashtable |
getNamespaces()
get parsed namespaces |
java.io.BufferedWriter |
getOutput()
get output stream |
protected java.lang.String |
getXMLVersion()
Extracts the XML version from the Locator. |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
copy the data without any processing |
void |
ignorableWhitespace(java.lang.String str)
Report an XML comment anywhere in the document. |
protected org.xml.sax.SAXException |
newLocationException(java.lang.Exception e)
factory method for exception |
protected org.xml.sax.SAXException |
newLocationException(java.lang.reflect.Method method,
org.xml.sax.Attributes attributes,
java.lang.String msg)
factory method for exception |
protected org.xml.sax.SAXException |
newLocationException(java.lang.String msg)
factory method for exception |
protected org.xml.sax.SAXException |
newLocationException(java.lang.String method,
org.xml.sax.Attributes attributes,
java.lang.Exception e)
factory method for exception |
protected org.xml.sax.SAXException |
newLocationException(java.lang.String method,
org.xml.sax.Attributes attributes,
java.lang.String msg)
factory method for exception |
protected org.xml.sax.SAXException |
newLocationException(java.lang.String msg,
java.lang.Exception e)
factory method for exception |
protected org.xml.sax.SAXException |
newLocationException(java.lang.String method,
int cnt,
java.lang.Exception e)
factory method for exception |
protected org.xml.sax.SAXException |
newLocationException(java.lang.String method,
int cnt,
java.lang.String msg)
factory method for exception |
protected java.lang.String |
normalize(char[] ch,
int offset,
int length,
boolean isAttValue)
Normalizes and prints the given string. |
protected java.lang.String |
normalize(char c,
boolean isAttValue)
Normalizes and prints the given string. |
protected java.lang.String |
normalize(java.lang.String s,
boolean isAttValue)
Normalizes and prints the given string. |
void |
parse(org.xml.sax.InputSource input,
org.xml.sax.XMLReader reader)
process the input via the reader and serialize the events method for convenience |
protected void |
parse(org.xml.sax.InputSource in1,
org.xml.sax.XMLReader reader,
java.lang.String in2)
|
void |
parse(java.lang.String systemId,
org.xml.sax.XMLReader reader)
process the input via the reader and serialize the events method for convenience |
protected void |
printError(java.lang.String type,
org.xml.sax.SAXParseException ex)
Prints the error message. |
protected void |
printIndent(int howmany)
print indent (that many times the nestling of the element) if set so (setDoIndent(true) ) |
void |
processingInstruction(java.lang.String target,
java.lang.String data)
copy the data |
void |
setDocumentLocator(org.xml.sax.Locator locator)
Set Document Locator. |
void |
setDoIndent(boolean flg)
set to false no newline+indent is to be printed before each element by default true |
void |
setIndent(java.lang.String val)
set the indent string, by default it is 3 spaces |
void |
setIsXML11(boolean flg)
set is xml output version 1.1 or to be threated as 1.0 |
void |
setIsXMLCanonical(boolean flg)
set to true if xml output to be in canonical format (i.e. |
void |
setOutput(java.io.BufferedWriter out)
set the output stream |
protected java.util.Iterator |
sortAttributes(org.xml.sax.Attributes attrs)
Returns a sorted list of attributes. |
void |
startCDATA()
Report the start of a CDATA section. |
void |
startDocument()
init the internal state |
void |
startDTD(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId)
Report the start of DTD declarations. |
void |
startElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes attributes)
print tag |
void |
startEntity(java.lang.String name)
Report the beginning of some internal and external XML entities. |
void |
startPrefixMapping(java.lang.String prefix,
java.lang.String uri)
store parsed namespace declaration |
void |
warning(org.xml.sax.SAXParseException ex)
Warning. |
protected void |
writeClosingTag(boolean isEndElementEvent)
writes closing tag of startElement event called from all events except startElement and if it is endElement event then prints out "/>", otherwise ">" |
Methods inherited from class org.xml.sax.helpers.DefaultHandler |
---|
endPrefixMapping, notationDecl, resolveEntity, skippedEntity, unparsedEntityDecl |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.xml.sax.EntityResolver |
---|
resolveEntity |
Methods inherited from interface org.xml.sax.ContentHandler |
---|
endPrefixMapping, skippedEntity |
Methods inherited from interface org.xml.sax.DTDHandler |
---|
notationDecl, unparsedEntityDecl |
Field Detail |
---|
protected java.io.BufferedWriter output
protected java.util.Hashtable namespaces
protected org.xml.sax.Locator locator
protected boolean isCanonical
protected boolean isXML11
protected int elementDepth
protected boolean inCDATA
protected boolean isPreviousStartElement
protected boolean doIndent
protected java.lang.String indent
Constructor Detail |
---|
public SAXSerializer()
public SAXSerializer(java.io.BufferedWriter out)
Method Detail |
---|
public void setOutput(java.io.BufferedWriter out)
public java.io.BufferedWriter getOutput()
protected java.util.Hashtable getNamespaces()
public void setDocumentLocator(org.xml.sax.Locator locator)
setDocumentLocator
in interface org.xml.sax.ContentHandler
setDocumentLocator
in class org.xml.sax.helpers.DefaultHandler
public org.xml.sax.Locator getDocumentLocator()
public void setIsXMLCanonical(boolean flg)
public boolean getIsXMLCanonical()
public void setIsXML11(boolean flg)
public boolean getIsXML11()
public void setDoIndent(boolean flg)
public boolean getDoIndent()
public void setIndent(java.lang.String val)
val
- public java.lang.String getIndent()
public void parse(org.xml.sax.InputSource input, org.xml.sax.XMLReader reader) throws org.xml.sax.SAXException, java.io.IOException
input
- xml documentreader
- used to parse the input (calling its parse(input) method)
org.xml.sax.SAXException
java.io.IOException
public void parse(java.lang.String systemId, org.xml.sax.XMLReader reader) throws org.xml.sax.SAXException, java.io.IOException
systemId
- resolving to the xml documentreader
- used to parse the input (calling its parse(input) method)
org.xml.sax.SAXException
java.io.IOException
protected void parse(org.xml.sax.InputSource in1, org.xml.sax.XMLReader reader, java.lang.String in2) throws org.xml.sax.SAXException, java.io.IOException
org.xml.sax.SAXException
java.io.IOException
protected org.xml.sax.SAXException newLocationException(java.lang.String msg)
protected org.xml.sax.SAXException newLocationException(java.lang.Exception e)
protected org.xml.sax.SAXException newLocationException(java.lang.String msg, java.lang.Exception e)
protected org.xml.sax.SAXException newLocationException(java.lang.String method, int cnt, java.lang.String msg)
protected org.xml.sax.SAXException newLocationException(java.lang.String method, int cnt, java.lang.Exception e)
protected org.xml.sax.SAXException newLocationException(java.lang.reflect.Method method, org.xml.sax.Attributes attributes, java.lang.String msg)
protected org.xml.sax.SAXException newLocationException(java.lang.String method, org.xml.sax.Attributes attributes, java.lang.String msg)
protected org.xml.sax.SAXException newLocationException(java.lang.String method, org.xml.sax.Attributes attributes, java.lang.Exception e)
public void startDocument() throws org.xml.sax.SAXException
startDocument
in interface org.xml.sax.ContentHandler
startDocument
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void endDocument() throws org.xml.sax.SAXException
endDocument
in interface org.xml.sax.ContentHandler
endDocument
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws org.xml.sax.SAXException
startPrefixMapping
in interface org.xml.sax.ContentHandler
startPrefixMapping
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXException
startElement
in interface org.xml.sax.ContentHandler
startElement
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException
endElement
in interface org.xml.sax.ContentHandler
endElement
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException
characters
in interface org.xml.sax.ContentHandler
characters
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void characters(java.lang.String str) throws org.xml.sax.SAXException
characters
in interface SAXHandler
org.xml.sax.SAXException
public void ignorableWhitespace(char[] ch, int start, int length) throws org.xml.sax.SAXException
ignorableWhitespace
in interface org.xml.sax.ContentHandler
ignorableWhitespace
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void ignorableWhitespace(java.lang.String str) throws org.xml.sax.SAXException
ignorableWhitespace
in interface SAXHandler
org.xml.sax.SAXException
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
processingInstruction
in interface org.xml.sax.ContentHandler
processingInstruction
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
startDTD
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
public void endDTD() throws org.xml.sax.SAXException
endDTD
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
public void startEntity(java.lang.String name) throws org.xml.sax.SAXException
startEntity
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
public void endEntity(java.lang.String name) throws org.xml.sax.SAXException
endEntity
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
public void startCDATA() throws org.xml.sax.SAXException
startCDATA
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
public void endCDATA() throws org.xml.sax.SAXException
endCDATA
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
public void comment(char[] ch, int start, int length) throws org.xml.sax.SAXException
comment
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
public void comment(java.lang.String str) throws org.xml.sax.SAXException
comment
in interface SAXHandler
org.xml.sax.SAXException
protected void writeClosingTag(boolean isEndElementEvent) throws java.io.IOException
isEndElementEvent
- is true only when it is called from endElement
event method, all other cases it is false
java.io.IOException
protected java.util.Iterator sortAttributes(org.xml.sax.Attributes attrs)
protected java.lang.String normalize(java.lang.String s, boolean isAttValue)
s
- is the string to normalizeisAttValue
- is true if the string is an attribute value
protected java.lang.String normalize(char[] ch, int offset, int length, boolean isAttValue)
isAttValue
- is true if the string is an attribute value
protected java.lang.String normalize(char c, boolean isAttValue)
c
- is the character to normalizeisAttValue
- is true if the string is an attribute value
protected java.lang.String getXMLVersion()
public void warning(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXException
warning
in interface org.xml.sax.ErrorHandler
warning
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void error(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXException
error
in interface org.xml.sax.ErrorHandler
error
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void fatalError(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXException
fatalError
in interface org.xml.sax.ErrorHandler
fatalError
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
protected void printError(java.lang.String type, org.xml.sax.SAXParseException ex)
protected void printIndent(int howmany) throws java.io.IOException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |