| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfi.iki.hsivonen.gnu.xml.pipeline.DomConsumer
public class DomConsumer
This consumer builds a DOM Document from its input, acting either as a
 pipeline terminus or as an intermediate buffer.  When a document's worth
 of events has been delivered to this consumer, that document is read with
 a DomParser and sent to the next consumer.  It is also available
 as a read-once property.
 
The DOM tree is constructed as faithfully as possible. There are some complications since a DOM should expose behaviors that can't be implemented without API backdoors into that DOM, and because some SAX parsers don't report all the information that DOM permits to be exposed. The general problem areas involve information from the Document Type Declaration (DTD). DOM only represents a limited subset, but has some behaviors that depend on much deeper knowledge of a document's DTD. You shouldn't have much to worry about unless you change handling of "noise" nodes from its default setting (which ignores them all); note if you use JAXP to populate your DOM trees, it wants to save "noise" nodes by default. (Such nodes include ignorable whitespace, comments, entity references and CDATA boundaries.) Otherwise, your main worry will be if you use a SAX parser that doesn't flag ignorable whitespace unless it's validating (few don't).
 The SAX2 events used as input must contain XML Names for elements
 and attributes, with original prefixes.  In SAX2,
 this is optional unless the "namespace-prefixes" parser feature is set.
 Moreover, many application components won't provide completely correct
 structures anyway.  Before you convert a DOM to an output document,
 you should plan to postprocess it to create or repair such namespace
 information. The NSFilter pipeline stage does such work.
 
 Note:  changes late in DOM L2 process made it impractical to
 attempt to create the DocumentType node in any implementation-neutral way,
 much less to populate it (L1 didn't support even creating such nodes).
 To create and populate such a node, subclass the inner
 DomConsumer.Handler class and teach it about the backdoors into
 whatever DOM implementation you want.  It's possible that some revised
 DOM API (L3?) will make this problem solvable again. 
DomParser| Nested Class Summary | |
|---|---|
| static class | DomConsumer.HandlerClass used to intercept various parsing events and use them to populate a DOM document. | 
| Field Summary | |
|---|---|
| private  Class<gnu.xml.dom.DomDocument> | domImpl | 
| private  ErrorHandler | errHandler | 
| private  DomConsumer.Handler | handler | 
| private  boolean | hidingCDATA | 
| private  boolean | hidingComments | 
| private  boolean | hidingReferences | 
| private  boolean | hidingWhitespace | 
| private  gnu.xml.pipeline.EventConsumer | next | 
| Constructor Summary | |
|---|---|
| DomConsumer(Class<gnu.xml.dom.DomDocument> impl)Configures this pipeline terminus to use the specified implementation of DOM when constructing its result value. | |
| DomConsumer(Class impl,
                       gnu.xml.pipeline.EventConsumer n)Configures this consumer as a buffer/filter, using the specified DOM implementation when constructing its result value. | |
| Method Summary | |
|---|---|
| private  Document | emptyDocument() | 
|  ContentHandler | getContentHandler()Returns the document handler being used. | 
|  Document | getDocument()Returns the document constructed from the preceding sequence of events. | 
|  DTDHandler | getDTDHandler()Returns the DTD handler being used. | 
| (package private)  ErrorHandler | getErrorHandler() | 
| (package private)  gnu.xml.pipeline.EventConsumer | getNext() | 
|  Object | getProperty(String id)Returns the lexical handler being used. | 
|  boolean | isHidingCDATA()Returns true if the consumer is saving CDATA boundaries, or false (the default) otherwise. | 
|  boolean | isHidingComments()Returns true if the consumer is hiding comments (the default), and false if they should be placed into the output document. | 
|  boolean | isHidingReferences()Returns true if the consumer is hiding entity references nodes (the default), and false if EntityReference nodes should instead be created. | 
|  boolean | isHidingWhitespace()Returns true if the consumer is hiding ignorable whitespace (the default), and false if such whitespace should be placed into the output document as children of element nodes. | 
|  void | setErrorHandler(ErrorHandler handler) | 
| protected  void | setHandler(DomConsumer.Handler h)This is the hook through which a subclass provides a handler which knows how to access DOM extensions, specific to some implementation, to record additional data in a DOM. | 
|  void | setHidingCDATA(boolean flag)Controls whether the consumer will save CDATA boundaries. | 
|  void | setHidingComments(boolean flag)Controls whether the consumer is hiding comments. | 
|  void | setHidingReferences(boolean flag)Controls whether the consumer will hide entity expansions, or will instead mark them with entity reference nodes. | 
|  void | setHidingWhitespace(boolean flag)Controls whether the consumer hides ignorable whitespace | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
private Class<gnu.xml.dom.DomDocument> domImpl
private boolean hidingCDATA
private boolean hidingComments
private boolean hidingWhitespace
private boolean hidingReferences
private DomConsumer.Handler handler
private ErrorHandler errHandler
private gnu.xml.pipeline.EventConsumer next
| Constructor Detail | 
|---|
public DomConsumer(Class<gnu.xml.dom.DomDocument> impl)
            throws SAXException
impl - class implementing Document
        which publicly exposes a default constructor
SAXException - when there is a problem creating an
        empty DOM document using the specified implementation
public DomConsumer(Class impl,
                   gnu.xml.pipeline.EventConsumer n)
            throws SAXException
 This event consumer acts as a buffer and filter, in that it
 builds a DOM tree and then writes it out when endDocument
 is invoked.  Because of the limitations of DOM, much information
 will as a rule not be seen in that replay.  To get a full fidelity
 copy of the input event stream, use a TeeConsumer.
impl - class implementing Document
        which publicly exposes a default constructornext - receives a "replayed" sequence of parse events when
        the endDocument method is invoked.
SAXException - when there is a problem creating an
        empty DOM document using the specified DOM implementation| Method Detail | 
|---|
protected void setHandler(DomConsumer.Handler h)
private Document emptyDocument()
                        throws SAXException
SAXExceptionpublic final Document getDocument()
public void setErrorHandler(ErrorHandler handler)
setErrorHandler in interface gnu.xml.pipeline.EventConsumerpublic final boolean isHidingReferences()
setHidingReferences(boolean)public final void setHidingReferences(boolean flag)
flag - False if entity reference nodes will appearisHidingReferences()public final boolean isHidingComments()
setHidingComments(boolean)public final void setHidingComments(boolean flag)
isHidingComments()public final boolean isHidingWhitespace()
setHidingWhitespace(boolean)public final void setHidingWhitespace(boolean flag)
isHidingComments()public final boolean isHidingCDATA()
setHidingCDATA(boolean)public final void setHidingCDATA(boolean flag)
flag - True to treat CDATA text differently from other
        text nodesisHidingCDATA()public final ContentHandler getContentHandler()
getContentHandler in interface gnu.xml.pipeline.EventConsumerpublic final DTDHandler getDTDHandler()
getDTDHandler in interface gnu.xml.pipeline.EventConsumer
public final Object getProperty(String id)
                         throws SAXNotRecognizedException
getProperty in interface gnu.xml.pipeline.EventConsumerSAXNotRecognizedExceptiongnu.xml.pipeline.EventConsumer getNext()
ErrorHandler getErrorHandler()
| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||