| java.lang.Object org.jdom.output.SAXOutputter
SAXOutputter | public class SAXOutputter (Code) | | Outputs a JDOM document as a stream of SAX2 events.
Most ContentHandler callbacks are supported. Both
ignorableWhitespace() and skippedEntity() have not
been implemented. The
JDOMLocator class returned by
SAXOutputter.getLocator exposes the current node being operated
upon.
At this time, it is not possible to access notations and unparsed entity
references in a DTD from JDOM. Therefore, DTDHandler callbacks
have not been implemented yet.
The ErrorHandler callbacks have not been implemented, since
these are supposed to be invoked when the document is parsed and at this
point the document exists in memory and is known to have no errors.
version: $Revision: 1.2 $, $Date: 2005/05/03 07:02:04 $ author: Brett McLaughlin author: Jason Hunter author: Fred Trimble author: Bradley S. Huffman |
Method Summary | |
protected XMLReader | createParser()
Creates a SAX XMLReader. | public ContentHandler | getContentHandler() Returns the registered ContentHandler . | public DTDHandler | getDTDHandler() Return the registered DTDHandler . | public DeclHandler | getDeclHandler() Return the registered DeclHandler . | public EntityResolver | getEntityResolver() Return the registered EntityResolver . | public ErrorHandler | getErrorHandler() Return the registered ErrorHandler . | public boolean | getFeature(String name) This will look up the value of a SAX feature.
Parameters: name - String the feature name, which is afully-qualified URI. | public LexicalHandler | getLexicalHandler() Return the registered LexicalHandler . | public JDOMLocator | getLocator() Returns a JDOMLocator object referencing the node currently
being processed by this outputter. | public Object | getProperty(String name) This will look up the value of a SAX property.
Parameters: name - String the property name, which is afully-qualified URI. | public boolean | getReportDTDEvents() Returns whether DTD events will be reported. | public boolean | getReportNamespaceDeclarations() Returns whether attribute namespace declarations shall be reported as
"xmlns" attributes. | public void | output(Document document) This will output the JDOM Document , firing off the
SAX events that have been registered. | public void | output(List nodes) This will output a list of JDOM nodes as a document, firing
off the SAX events that have been registered.
Warning: This method may output ill-formed XML
documents if the list contains top-level objects that are not
legal at the document level (e.g. | public void | output(Element node) This will output a single JDOM element as a document, firing
off the SAX events that have been registered. | public void | outputFragment(List nodes) This will output a list of JDOM nodes as a fragment of an XML
document, firing off the SAX events that have been registered.
Warning: This method does not call the
ContentHandler.setDocumentLocator ,
ContentHandler.startDocument and
ContentHandler.endDocument callbacks on the
SAXOutputter.setContentHandler ContentHandler . | public void | outputFragment(Content node) This will output a single JDOM nodes as a fragment of an XML
document, firing off the SAX events that have been registered.
Warning: This method does not call the
ContentHandler.setDocumentLocator ,
ContentHandler.startDocument and
ContentHandler.endDocument callbacks on the
SAXOutputter.setContentHandler ContentHandler . | public void | setContentHandler(ContentHandler contentHandler) This will set the ContentHandler . | public void | setDTDHandler(DTDHandler dtdHandler) This will set the DTDHandler . | public void | setDeclHandler(DeclHandler declHandler) This will set the DeclHandler . | public void | setEntityResolver(EntityResolver entityResolver) This will set the EntityResolver . | public void | setErrorHandler(ErrorHandler errorHandler) This will set the ErrorHandler . | public void | setFeature(String name, boolean value) This will set the state of a SAX feature. | public void | setLexicalHandler(LexicalHandler lexicalHandler) This will set the LexicalHandler . | public void | setProperty(String name, Object value) This will set the value of a SAX property. | public void | setReportDTDEvents(boolean reportDtdEvents) This will define whether to report DTD events to SAX DeclHandlers
and LexicalHandlers if these handlers are registered and the
document to output includes a DocType declaration. | public void | setReportNamespaceDeclarations(boolean declareNamespaces) This will define whether attribute namespace declarations shall be
reported as "xmlns" attributes. |
SAXOutputter | public SAXOutputter()(Code) | | This will create a SAXOutputter without any
registered handler. The application is then responsible for
registering them using the setXxxHandler() methods.
|
SAXOutputter | public SAXOutputter(ContentHandler contentHandler)(Code) | | This will create a SAXOutputter with the
specified ContentHandler .
Parameters: contentHandler - contains ContentHandler callback methods |
SAXOutputter | public SAXOutputter(ContentHandler contentHandler, ErrorHandler errorHandler, DTDHandler dtdHandler, EntityResolver entityResolver)(Code) | | This will create a SAXOutputter with the
specified SAX2 handlers. At this time, only ContentHandler
and EntityResolver are supported.
Parameters: contentHandler - contains ContentHandler callback methods Parameters: errorHandler - contains ErrorHandler callback methods Parameters: dtdHandler - contains DTDHandler callback methods Parameters: entityResolver - contains EntityResolver callback methods |
SAXOutputter | public SAXOutputter(ContentHandler contentHandler, ErrorHandler errorHandler, DTDHandler dtdHandler, EntityResolver entityResolver, LexicalHandler lexicalHandler)(Code) | | This will create a SAXOutputter with the
specified SAX2 handlers. At this time, only ContentHandler
and EntityResolver are supported.
Parameters: contentHandler - contains ContentHandler callback methods Parameters: errorHandler - contains ErrorHandler callback methods Parameters: dtdHandler - contains DTDHandler callback methods Parameters: entityResolver - contains EntityResolver callback methods Parameters: lexicalHandler - contains LexicalHandler callbacks. |
createParser | protected XMLReader createParser() throws Exception(Code) | |
Creates a SAX XMLReader.
XMLReader a SAX2 parser. throws: Exception - if no parser can be created. |
getContentHandler | public ContentHandler getContentHandler()(Code) | | Returns the registered ContentHandler .
the current ContentHandler ornull if none was registered. |
getDTDHandler | public DTDHandler getDTDHandler()(Code) | | Return the registered DTDHandler .
the current DTDHandler ornull if none was registered. |
getDeclHandler | public DeclHandler getDeclHandler()(Code) | | Return the registered DeclHandler .
the current DeclHandler ornull if none was registered. |
getEntityResolver | public EntityResolver getEntityResolver()(Code) | | Return the registered EntityResolver .
the current EntityResolver ornull if none was registered. |
getErrorHandler | public ErrorHandler getErrorHandler()(Code) | | Return the registered ErrorHandler .
the current ErrorHandler ornull if none was registered. |
getLexicalHandler | public LexicalHandler getLexicalHandler()(Code) | | Return the registered LexicalHandler .
the current LexicalHandler ornull if none was registered. |
getLocator | public JDOMLocator getLocator()(Code) | | Returns a JDOMLocator object referencing the node currently
being processed by this outputter. The returned object is a
snapshot of the location information and can thus safely be
memorized for later use.
This method allows direct access to the location information
maintained by SAXOutputter without requiring to implement
XMLFilter . (In SAX, locators are only available
though the ContentHandler interface).
Note that location information is only available while
SAXOutputter is outputting nodes. Hence this method should
only be used by objects taking part in the output processing
such as ErrorHandler s.
a JDOMLocator object referencing the node currentlybeing processed or null if no outputoperation is being performed. |
getReportDTDEvents | public boolean getReportDTDEvents()(Code) | | Returns whether DTD events will be reported.
whether DTD events will be reported |
getReportNamespaceDeclarations | public boolean getReportNamespaceDeclarations()(Code) | | Returns whether attribute namespace declarations shall be reported as
"xmlns" attributes.
whether attribute namespace declarations shall be reported as"xmlns" attributes. |
output | public void output(Document document) throws JDOMException(Code) | | This will output the JDOM Document , firing off the
SAX events that have been registered.
Parameters: document - JDOM Document to output. throws: JDOMException - if any error occurred. |
output | public void output(List nodes) throws JDOMException(Code) | | This will output a list of JDOM nodes as a document, firing
off the SAX events that have been registered.
Warning: This method may output ill-formed XML
documents if the list contains top-level objects that are not
legal at the document level (e.g. Text or CDATA nodes, multiple
Element nodes, etc.). Thus, it should only be used to output
document portions towards ContentHandlers capable of accepting
such ill-formed documents (such as XSLT processors).
Parameters: nodes - List of JDOM nodes to output. throws: JDOMException - if any error occurred. See Also: SAXOutputter.output(org.jdom.Document) |
output | public void output(Element node) throws JDOMException(Code) | | This will output a single JDOM element as a document, firing
off the SAX events that have been registered.
Parameters: node - the Element node to output. throws: JDOMException - if any error occurred. |
setContentHandler | public void setContentHandler(ContentHandler contentHandler)(Code) | | This will set the ContentHandler .
Parameters: contentHandler - contains ContentHandler callback methods. |
setDTDHandler | public void setDTDHandler(DTDHandler dtdHandler)(Code) | | This will set the DTDHandler .
Parameters: dtdHandler - contains DTDHandler callback methods. |
setDeclHandler | public void setDeclHandler(DeclHandler declHandler)(Code) | | This will set the DeclHandler .
Parameters: declHandler - contains declaration callback methods. |
setEntityResolver | public void setEntityResolver(EntityResolver entityResolver)(Code) | | This will set the EntityResolver .
Parameters: entityResolver - contains EntityResolver callback methods. |
setErrorHandler | public void setErrorHandler(ErrorHandler errorHandler)(Code) | | This will set the ErrorHandler .
Parameters: errorHandler - contains ErrorHandler callback methods. |
setFeature | public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException(Code) | | This will set the state of a SAX feature.
All XMLReaders are required to support setting to true and to false.
SAXOutputter currently supports the following SAX core features:
http://xml.org/sax/features/namespaces
- description:
true indicates
namespace URIs and unprefixed local names for element and
attribute names will be available
- access: read/write, but always
true !
http://xml.org/sax/features/namespace-prefixes
- description:
true indicates
XML 1.0 names (with prefixes) and attributes (including xmlns*
attributes) will be available
- access: read/write
http://xml.org/sax/features/validation
- description: controls whether SAXOutputter
is reporting DTD-related events; if
true , the
DocType internal subset will be parsed to fire DTD events
- access: read/write, defaults to
true
Parameters: name - String the feature name, which is afully-qualified URI. Parameters: value - boolean the requested state of thefeature (true or false). throws: SAXNotRecognizedException - when SAXOutputter does notrecognize the feature name. throws: SAXNotSupportedException - when SAXOutputter recognizesthe feature name but cannot set the requested value. |
setLexicalHandler | public void setLexicalHandler(LexicalHandler lexicalHandler)(Code) | | This will set the LexicalHandler .
Parameters: lexicalHandler - contains lexical callback methods. |
setProperty | public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException(Code) | | This will set the value of a SAX property.
This method is also the standard mechanism for setting extended
handlers.
SAXOutputter currently supports the following SAX properties:
http://xml.org/sax/properties/lexical-handler
- data type:
org.xml.sax.ext.LexicalHandler
- description: An optional extension handler for
lexical events like comments.
- access: read/write
http://xml.org/sax/properties/declaration-handler
- data type:
org.xml.sax.ext.DeclHandler
- description: An optional extension handler for
DTD-related events other than notations and unparsed entities.
- access: read/write
Parameters: name - String the property name, which is afully-qualified URI. Parameters: value - Object the requested value for the property. throws: SAXNotRecognizedException - when SAXOutputter does not recognizethe property name. throws: SAXNotSupportedException - when SAXOutputter recognizes theproperty name but cannot set the requested value. |
setReportDTDEvents | public void setReportDTDEvents(boolean reportDtdEvents)(Code) | | This will define whether to report DTD events to SAX DeclHandlers
and LexicalHandlers if these handlers are registered and the
document to output includes a DocType declaration.
Parameters: reportDtdEvents - whether to notify DTD events. |
setReportNamespaceDeclarations | public void setReportNamespaceDeclarations(boolean declareNamespaces)(Code) | | This will define whether attribute namespace declarations shall be
reported as "xmlns" attributes. This flag defaults to false
and behaves as the "namespace-prefixes" SAX core feature.
Parameters: declareNamespaces - whether attribute namespace declarationsshall be reported as "xmlns" attributes. |
|
|