org.apache.cocoon.xml
Interface XMLConsumer

All Superinterfaces:
ContentHandler, LexicalHandler, XMLConsumer
All Known Subinterfaces:
Serializer, Transformer, XMLPipe

public interface XMLConsumer
extends XMLConsumer

This interfaces identifies classes that consume XML data, receiving notification of SAX events.

An XMLConsumer is also a SAX ContentHandler and a SAX LexicalHandler. That means the XMLConsumer has to respect all the contracts with the SAX interfaces. SAX stands for Serialized API for XML. A document start, and each element start must be matched by the corresponding element end or document end. So why does Cocoon use SAX instead of manipulating a DOM? For two main reasons: performance and scalability. A DOM tree is much more heavy on system memory than successive calls to an API. SAX events can be sent as soon as they are read from the originating XML, the parsing and processing can happen essentially at the same time.

Most people's needs will be handled just fine with the ContentHandler interface, as that declares your namespaces. However if you need lexical support to resolve entity names and such, you need the LexicalHandler interface. The AbstractXMLConsumer base class can make implementing this interface easier so that you only need to override the events you intend to do anything with.

Version:
$Id: XMLConsumer.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Methods inherited from interface org.xml.sax.ContentHandler
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping
 
Methods inherited from interface org.xml.sax.ext.LexicalHandler
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity
 



Copyright © 1999-2008 The Apache Software Foundation. All Rights Reserved.