|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.cdmckay.coffeedom.output.SAXOutputter
public class SAXOutputter
Outputs a CoffeeDOM document as a stream of SAX2 events.
Most ContentHandler callbacks are supported. Both
ignorableWhitespace()
and skippedEntity()
have not been implemented. The
class returned by CoffeeDOMLocator
exposes the current node being operated upon.
getLocator()
At this time, it is not possible to access notations and unparsed entity references in a DTD from CoffeeDOM.
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.
Constructor Summary | |
---|---|
SAXOutputter()
This will create a SAXOutputter without any registered handler. |
|
SAXOutputter(ContentHandler contentHandler)
This will create a SAXOutputter with the specified ContentHandler . |
|
SAXOutputter(ContentHandler contentHandler,
ErrorHandler errorHandler,
DTDHandler dtdHandler,
EntityResolver entityResolver)
This will create a SAXOutputter with the specified SAX2 handlers. |
|
SAXOutputter(ContentHandler contentHandler,
ErrorHandler errorHandler,
DTDHandler dtdHandler,
EntityResolver entityResolver,
LexicalHandler lexicalHandler)
This will create a SAXOutputter with the specified SAX2 handlers. |
Method Summary | |
---|---|
protected XMLReader |
createParser()
Creates a SAX XMLReader. |
ContentHandler |
getContentHandler()
Returns the registered ContentHandler . |
DeclHandler |
getDeclHandler()
Return the registered DeclHandler . |
DTDHandler |
getDTDHandler()
Return the registered DTDHandler . |
EntityResolver |
getEntityResolver()
Return the registered EntityResolver . |
ErrorHandler |
getErrorHandler()
Return the registered ErrorHandler . |
boolean |
getFeature(String name)
This will look up the value of a SAX feature. |
LexicalHandler |
getLexicalHandler()
Return the registered LexicalHandler . |
CoffeeDOMLocator |
getLocator()
Returns a CoffeeDOMLocator object referencing the node currently being processed by this outputter. |
Object |
getProperty(String name)
This will look up the value of a SAX property. |
boolean |
getReportDTDEvents()
Returns whether DTD events will be reported. |
boolean |
getReportNamespaceDeclarations()
Returns whether attribute namespace declarations shall be reported as "xmlns" attributes. |
void |
output(Document document)
This will output the CoffeeDOM Document , firing off the SAX events that have been registered. |
void |
output(Element node)
This will output a single CoffeeDOM element as a document, firing off the SAX events that have been registered. |
void |
output(List<Content> nodes)
This will output a list of CoffeeDOM nodes as a document, firing off the SAX events that have been registered. |
void |
outputFragment(Content node)
This will output a single CoffeeDOM nodes as a fragment of an XML document, firing off the SAX events that have been registered. |
void |
outputFragment(List<Content> nodes)
This will output a list of CoffeeDOM nodes as a fragment of an XML document, firing off the SAX events that have been registered. |
void |
setContentHandler(ContentHandler contentHandler)
This will set the ContentHandler . |
void |
setDeclHandler(DeclHandler declHandler)
This will set the DeclHandler . |
void |
setDTDHandler(DTDHandler dtdHandler)
This will set the DTDHandler . |
void |
setEntityResolver(EntityResolver entityResolver)
This will set the EntityResolver . |
void |
setErrorHandler(ErrorHandler errorHandler)
This will set the ErrorHandler . |
void |
setFeature(String name,
boolean value)
This will set the state of a SAX feature. |
void |
setLexicalHandler(LexicalHandler lexicalHandler)
This will set the LexicalHandler . |
void |
setProperty(String name,
Object value)
This will set the value of a SAX property. |
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. |
void |
setReportNamespaceDeclarations(boolean declareNamespaces)
This will define whether attribute namespace declarations shall be reported as "xmlns" attributes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SAXOutputter()
SAXOutputter
without any registered handler. The application is then responsible
for registering them using the setXxxHandler()
methods.
public SAXOutputter(ContentHandler contentHandler)
SAXOutputter
with the specified ContentHandler
.
contentHandler
- contains ContentHandler
callback methodspublic SAXOutputter(ContentHandler contentHandler, ErrorHandler errorHandler, DTDHandler dtdHandler, EntityResolver entityResolver)
SAXOutputter
with the specified SAX2 handlers. At this time, only
ContentHandler
and EntityResolver
are supported.
contentHandler
- contains ContentHandler
callback methodserrorHandler
- contains ErrorHandler
callback methodsdtdHandler
- contains DTDHandler
callback methodsentityResolver
- contains EntityResolver
callback methodspublic SAXOutputter(ContentHandler contentHandler, ErrorHandler errorHandler, DTDHandler dtdHandler, EntityResolver entityResolver, LexicalHandler lexicalHandler)
SAXOutputter
with the specified SAX2 handlers. At this time, only
ContentHandler
and EntityResolver
are supported.
contentHandler
- contains ContentHandler
callback methodserrorHandler
- contains ErrorHandler
callback methodsdtdHandler
- contains DTDHandler
callback methodsentityResolver
- contains EntityResolver
callback methodslexicalHandler
- contains LexicalHandler
callbacks.Method Detail |
---|
public void setContentHandler(ContentHandler contentHandler)
ContentHandler
.
contentHandler
- contains ContentHandler
callback methods.public ContentHandler getContentHandler()
ContentHandler
.
ContentHandler
or null
if none was registered.public void setErrorHandler(ErrorHandler errorHandler)
ErrorHandler
.
errorHandler
- contains ErrorHandler
callback methods.public ErrorHandler getErrorHandler()
ErrorHandler
.
ErrorHandler
or null
if none was registered.public void setDTDHandler(DTDHandler dtdHandler)
DTDHandler
.
dtdHandler
- contains DTDHandler
callback methods.public DTDHandler getDTDHandler()
DTDHandler
.
DTDHandler
or null
if none was registered.public void setEntityResolver(EntityResolver entityResolver)
EntityResolver
.
entityResolver
- contains EntityResolver callback methods.public EntityResolver getEntityResolver()
EntityResolver
.
EntityResolver
or null
if none was registered.public void setLexicalHandler(LexicalHandler lexicalHandler)
LexicalHandler
.
lexicalHandler
- contains lexical callback methods.public LexicalHandler getLexicalHandler()
LexicalHandler
.
LexicalHandler
or null
if none was registered.public void setDeclHandler(DeclHandler declHandler)
DeclHandler
.
declHandler
- contains declaration callback methods.public DeclHandler getDeclHandler()
DeclHandler
.
DeclHandler
or null
if none was registered.public boolean getReportNamespaceDeclarations()
public void setReportNamespaceDeclarations(boolean declareNamespaces)
false
and behaves as the "namespace-prefixes" SAX core feature.
declareNamespaces
- whether attribute namespace declarations shall be reported as "xmlns" attributes.public boolean getReportDTDEvents()
public void setReportDTDEvents(boolean reportDtdEvents)
reportDtdEvents
- whether to notify DTD events.public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException
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
true
indicates namespace URIs and unprefixed local names for element and attribute names will be availabletrue
!http://xml.org/sax/features/namespace-prefixes
true
indicates XML 1.0 names (with prefixes) and attributes
(including xmlns* attributes) will be availablehttp://xml.org/sax/features/validation
true
, the DocType internal subset will be parsed to
fire DTD eventstrue
name
- String
the feature name, which is a fully-qualified URI.value
- boolean
the requested state of the feature (true or false).
SAXNotRecognizedException
- when SAXOutputter does not recognize the feature name.
SAXNotSupportedException
- when SAXOutputter recognizes the feature name but cannot set the requested
value.public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException
name
- String
the feature name, which is a fully-qualified URI.
boolean
the current state of the feature (true or false).
SAXNotRecognizedException
- when SAXOutputter does not recognize the feature name.
SAXNotSupportedException
- when SAXOutputter recognizes the feature name but determine its value at this
time.public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException
SAXOutputter currently supports the following SAX properties:
http://xml.org/sax/properties/lexical-handler
org.xml.sax.ext.LexicalHandler
http://xml.org/sax/properties/declaration-handler
org.xml.sax.ext.DeclHandler
name
- String
the property name, which is a fully-qualified URI.value
- Object
the requested value for the property.
SAXNotRecognizedException
- when SAXOutputter does not recognize the property name.
SAXNotSupportedException
- when SAXOutputter recognizes the property name but cannot set the requested
value.public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException
name
- String
the property name, which is a fully-qualified URI.
Object
the current value of the property.
SAXNotRecognizedException
- when SAXOutputter does not recognize the property name.
SAXNotSupportedException
- when SAXOutputter recognizes the property name but cannot determine its value
at this time.public void output(Document document) throws CoffeeDOMException
CoffeeDOM Document
, firing off the SAX events that have been registered.
document
- CoffeeDOM Document
to output.
CoffeeDOMException
- if any error occurred.public void output(List<Content> nodes) throws CoffeeDOMException
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).
nodes
- List
of CoffeeDOM nodes to output.
CoffeeDOMException
- if any error occurred.output(org.cdmckay.coffeedom.Document)
public void output(Element node) throws CoffeeDOMException
node
- the Element
node to output.
CoffeeDOMException
- if any error occurred.public void outputFragment(List<Content> nodes) throws CoffeeDOMException
Warning: This method does not call the ContentHandler.setDocumentLocator(org.xml.sax.Locator)
, ContentHandler.startDocument()
and ContentHandler.endDocument()
callbacks on the setContentHandler(org.xml.sax.ContentHandler)
ContentHandler}. The user shall invoke these methods directly prior/after outputting the document
fragments.
nodes
- List
of CoffeeDOM nodes to output.
CoffeeDOMException
- if any error occurred.outputFragment(org.cdmckay.coffeedom.Content)
public void outputFragment(Content node) throws CoffeeDOMException
Warning: This method does not call the ContentHandler.setDocumentLocator(org.xml.sax.Locator)
, ContentHandler.startDocument()
and ContentHandler.endDocument()
callbacks on the setContentHandler(org.xml.sax.ContentHandler)
ContentHandler}. The user shall invoke these methods directly prior/after outputting the document
fragments.
node
- the Content
node to output.
CoffeeDOMException
- if any error occurred.outputFragment(java.util.List)
protected XMLReader createParser() throws Exception
Creates a SAX XMLReader.
XMLReader
a SAX2 parser.
Exception
- if no parser can be created.public CoffeeDOMLocator getLocator()
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).
ErrorHandler
s.
null
if no output
operation is being performed.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |