|
Qizx fe-4.4p2 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.qizx.xdm.AttributeList
com.qizx.xdm.XMLPushStreamBase
com.qizx.api.util.XMLSerializer
public class XMLSerializer
An implementation of XMLPushStream that serializes into XML, XHTML, HTML or plain text.
Can be used to export a Node
: see Item.export(XMLPushStream)
or a Document
: see Document.export(XMLPushStream)
Field Summary | |
---|---|
static String |
AUTO_DTD
name of option used to inhibit the automatic generation of DOCTYPE (extension): value is a boolean (true by default) that indicates that a DOCTYPE should be generated on documents stored in XML Libraries, having properties System/Public ID. |
static String |
DOCTYPE_PUBLIC
name of option specifying the Public Id of the DTD declaration |
static String |
DOCTYPE_SYSTEM
name of option specifying the System Id of the DTD declaration |
static String |
ENCODING
name of option specifying the output encoding: the value must be a valid encoding name, supported by the JRE. |
static String |
ESCAPE_URI_ATTRIBUTES
name of option escape-uri-attributes (NOT IMPLEMENTED) |
static String |
INCLUDE_CONTENT_TYPE
name of option specifying the Content-Type meta in HTML |
static String |
INDENT
name of option specifying the whether the output is indented: value is a boolean "yes" or "no". |
static String |
INDENT_VALUE
name of option specifying the indentation (extension): value is an integer which represents the number of spaces. |
static String |
MEDIA_TYPE
name of option specifying the media type (NOT IMPLEMENTED) |
static String |
METHOD
name of option specifying the output style: the value must be "XML", "HTML", "XHTML", "TEXT". |
static String |
OMIT_XML_DECLARATION
name of option enabling or disabling the XML declaration. |
static String |
STANDALONE
name of option specifying 'standalone' in the XML declaration. |
static String |
STRIP_COMMENT
name of option specifying the omission of comments (extension): value is a boolean (false by default) that indicates that comments must be stripped (when set to true). |
static String |
STRIP_PI
name of option specifying the omission of processing instructions (extension): value is a boolean (false by default) that indicates that PI must be stripped (when set to true). |
static String |
VERSION
name of option specifying the XML version. |
Fields inherited from interface com.qizx.api.XMLPushStream |
---|
NSCOPY_NOPRESERVE_INHERIT, NSCOPY_NOPRESERVE_NOINHERIT, NSCOPY_PRESERVE_INHERIT, NSCOPY_PRESERVE_NOINHERIT |
Constructor Summary | |
---|---|
XMLSerializer()
Constructs a XMLSerializer with default XML output method. |
|
XMLSerializer(OutputStream output,
String encoding)
Constructs a XMLSerializer with an output stream and an encoding name. |
|
XMLSerializer(String method)
Constructs a XMLSerializer with specification of an output method. |
|
XMLSerializer(Writer output)
Constructs a XMLSerializer with an output writer. |
Method Summary | |
---|---|
void |
flush()
Flush of the output flow. |
String |
getEncoding()
Returns the current encoding. |
int |
getIndent()
|
BufferedWriter |
getOutput()
Gets the current output as a BufferedWriter. |
boolean |
hasAutoDTD()
|
void |
output(Node node)
Serializes a node and its subtree. |
void |
println()
Outputs an end-of-line. |
void |
putAtomText(String value)
Puts the value of an atomic item. |
void |
putComment(String contents)
Puts a Comment event. |
void |
putDocumentEnd()
Puts a Document End event. |
boolean |
putDocumentStart()
Puts a Document Start event. |
void |
putElementEnd(QName name)
Puts an Element End event. |
void |
putNodeCopy(Node node,
int copyNsMode)
Traverse and generate a subtree. |
void |
putProcessingInstruction(String target,
String contents)
Puts a Processing-instruction event. |
void |
putText(String value)
Puts a Text Fragment event. |
void |
reset()
Prepares the serialization of another tree. |
String |
serializeToString(Node node)
Serializes a node and its subtree as a string. |
void |
setEncoding(String encoding)
Sets the option ENCODING. |
void |
setIndent(int value)
Extension: defines the number of spaces used for one level of indentation. |
void |
setOmitXMLDeclaration(boolean omit)
Sets the option OMIT_XML_DECLARATION |
void |
setOption(String option,
String value)
Sets an option. |
void |
setOutput(OutputStream output)
Defines or redefines the output. |
void |
setOutput(OutputStream output,
String encoding)
Defines or redefines the output. |
void |
setOutput(Writer output)
Defines or redefines the output. |
Methods inherited from class com.qizx.xdm.XMLPushStreamBase |
---|
abort, defineContextMappings, getNSPrefix, getNSURI, isAtRoot, maxVolumeReached, noSpace, putAtom, putAttribute, putChars, putDTD, putElementStart, putLongAtom, putNamespace, putNamespaces, putNodeCopy, putNodeText, setCheckNS, setMaxVolume, setTrace |
Methods inherited from class com.qizx.xdm.AttributeList |
---|
addAttribute, getAttributeCount, getIndex, getIndex, getIndex, getLength, getLocalName, getNamespaceContext, getNamespaceCount, getNamespacePrefix, getNamespaceURI, getQName, getType, getType, getType, getURI, getValue, getValue, getValue |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.qizx.api.XMLPushStream |
---|
getNSPrefix, getNSURI, putAtom, putAttribute, putChars, putDTD, putElementStart, putNamespace, putNamespaces |
Field Detail |
---|
public static final String METHOD
public static final String ENCODING
public static final String VERSION
public static final String OMIT_XML_DECLARATION
public static final String STANDALONE
public static final String DOCTYPE_SYSTEM
public static final String DOCTYPE_PUBLIC
public static final String INCLUDE_CONTENT_TYPE
public static final String MEDIA_TYPE
public static final String ESCAPE_URI_ATTRIBUTES
public static final String INDENT
public static final String INDENT_VALUE
public static final String STRIP_PI
public static final String STRIP_COMMENT
public static final String AUTO_DTD
Constructor Detail |
---|
public XMLSerializer()
public XMLSerializer(OutputStream output, String encoding) throws DataModelException
output
- an open output streamencoding
- the name of a supported encoding, or null to use the
default platform encoding
DataModelException
- for an invalid encodingpublic XMLSerializer(Writer output)
Attention: Encoding must be specified separately through options. Should be compatible with the writer.
output
- an open Writer, does not need to be buffered.public XMLSerializer(String method) throws DataModelException
method
- output method name (case-insensitive): XML, XHTML, HTML,
or TEXT.
DataModelException
- when the method name is invalid.Method Detail |
---|
public void setOutput(OutputStream output, String encoding) throws DataModelException
output
- an open output streamencoding
- the name of a supported encoding, or null to use the
default platform encoding
DataModelException
- for an invalid encodingpublic void setOutput(Writer output) throws DataModelException
DataModelException
- for an invalid encodingpublic void setOutput(OutputStream output) throws DataModelException
The encoding is UTF-8.
DataModelException
public BufferedWriter getOutput()
public String getEncoding()
The encoding can have been defined by setOutput or by setOption.
public void setEncoding(String encoding) throws DataModelException
encoding
- a supported encoding or null for UTF-8
DataModelException
- for an invalid encodingpublic boolean hasAutoDTD()
public void setOmitXMLDeclaration(boolean omit)
omit
- true to omit the declarationpublic void output(Node node) throws DataModelException
node
- node to serialize. If it is not a document, the XML header
is not generated.
DataModelException
- wraps an output errorpublic void putNodeCopy(Node node, int copyNsMode) throws DataModelException
com.qizx.xdm.XMLPushStreamBase
putNodeCopy
in interface XMLPushStream
putNodeCopy
in class com.qizx.xdm.XMLPushStreamBase
node
- Node to include in the output flow.copyNsMode
- one of the 4 combinations of PRESERVE and
INHERIT. The normal mode is NSCOPY_PRESERVE_INHERIT.
DataModelException
- reasonspublic String serializeToString(Node node) throws DataModelException
node
- node to serialize. If it is not a document, the XML header
is not generated.
DataModelException
- wraps an output errorpublic void setOption(String option, String value) throws DataModelException
Supported options:
option
- name of the option (see above).value
- option value in string form.
DataModelException
- on bad option name or value.public void setIndent(int value)
value
- the number of spaces for indentation. If < 0, disables
indentation.public int getIndent()
public void reset()
reset
in interface XMLPushStream
reset
in class com.qizx.xdm.XMLPushStreamBase
public void flush() throws DataModelException
It is strongly recommended to call this method at end of a serialization
except if you use output(Node)
which calls it, or if the Node
to serialize is a document-node (because putDocumentEnd calls this
method automatically).
flush
in interface XMLPushStream
flush
in class com.qizx.xdm.XMLPushStreamBase
DataModelException
- wraps a possible output error
(IOException).public boolean putDocumentStart() throws DataModelException
XMLPushStream
putDocumentStart
in interface XMLPushStream
putDocumentStart
in class com.qizx.xdm.XMLPushStreamBase
DataModelException
- reasonspublic void putDocumentEnd() throws DataModelException
XMLPushStream
putDocumentEnd
in interface XMLPushStream
putDocumentEnd
in class com.qizx.xdm.XMLPushStreamBase
DataModelException
- reasonspublic void putElementEnd(QName name) throws DataModelException
XMLPushStream
putElementEnd
in interface XMLPushStream
putElementEnd
in class com.qizx.xdm.XMLPushStreamBase
name
- qualified name of the element
DataModelException
- reasonspublic void putText(String value) throws DataModelException
XMLPushStream
A text fragment should appear inside an element. Consecutive text events are coalesced into one. An empty text fragment is discarded.
putText
in interface XMLPushStream
value
- a fragment of text
DataModelException
- reasonspublic void putAtomText(String value) throws DataModelException
com.qizx.xdm.XMLPushStreamBase
putAtomText
in class com.qizx.xdm.XMLPushStreamBase
DataModelException
public void putProcessingInstruction(String target, String contents) throws DataModelException
XMLPushStream
putProcessingInstruction
in interface XMLPushStream
putProcessingInstruction
in class com.qizx.xdm.XMLPushStreamBase
target
- target (name) of the PIcontents
- contents of the PI
DataModelException
- reasonspublic void putComment(String contents) throws DataModelException
XMLPushStream
putComment
in interface XMLPushStream
putComment
in class com.qizx.xdm.XMLPushStreamBase
contents
- contents of a comment.
DataModelException
- reasonspublic void println()
|
© 2010 Axyana Software | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |