org.inria.ns.reflex.processor.catalog
Class CatalogReader

java.lang.Object
  extended by org.xml.sax.helpers.XMLFilterImpl
      extended by org.inria.ns.reflex.xml.sax.SAXFilter
          extended by org.inria.ns.reflex.xml.sax.SAXSafeDocument
              extended by org.inria.ns.reflex.xml.sax.SAXSafeParser
                  extended by org.inria.ns.reflex.processor.catalog.CatalogReader
All Implemented Interfaces:
Localizable, ContentHandler, DTDHandler, EntityResolver, ErrorHandler, DeclHandler, LexicalHandler, XMLFilter, XMLReader

public class CatalogReader
extends SAXSafeParser

A CatalogReader fires SAX events from various input sources :

Usage

Simply call one of the static methods CatalogParser.parseCatalog().

The method CatalogParser.parseCatalog( InputSource ) simply creates a catalog reader and parses the input with it :

// create a reader that fires SAX events from XML catalogs or non-XML catalog
 CatalogReader catalogReader = new CatalogReader();
 // create a DOM catalog from SAX events
 Document domCatalog = catalogReader.parseInput( catalog );
 return CatalogParser.parseCatalog( domCatalog );

The CatalogReader parses XML sources and plain text Catalog formats as well.

Author:
Philippe Poulard

Nested Class Summary
static class CatalogReader.PublicId
          Static methods for dealing with public identifiers.
 
Constructor Summary
CatalogReader()
           
 
Method Summary
 void alternateParse(InputSource input)
          Parse a plain text catalog.
 Document parseInput(InputSource input)
          Parse a catalog to a document.
 
Methods inherited from class org.inria.ns.reflex.xml.sax.SAXSafeParser
parse, startElement
 
Methods inherited from class org.inria.ns.reflex.xml.sax.SAXSafeDocument
characters, endDTD, startDTD
 
Methods inherited from class org.inria.ns.reflex.xml.sax.SAXFilter
attributeDecl, comment, elementDecl, endCDATA, endDocument, endEntity, externalEntityDecl, getDeclHandler, getLexicalHandler, getLocation, getProperty, internalEntityDecl, isLocalizable, parse, setDeclHandler, setLexicalHandler, setLocation, setProperty, startCDATA, startDocument, startEntity
 
Methods inherited from class org.xml.sax.helpers.XMLFilterImpl
endElement, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.ContentHandler
endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startPrefixMapping
 
Methods inherited from interface org.xml.sax.DTDHandler
notationDecl, unparsedEntityDecl
 

Constructor Detail

CatalogReader

public CatalogReader()
              throws SAXException
Parameters:
parserConfiguration -
Throws:
SAXException
Method Detail

parseInput

public Document parseInput(InputSource input)
                    throws SAXException,
                           IOException,
                           TransformerConfigurationException
Parse a catalog to a document. If it fails, the input is parsed as a plain-text catalog file with alternateParse(InputSource).

Parameters:
input - The input source to parse.
Returns:
An XML document, even if the input was a plain-text catalog.
Throws:
TransformerConfigurationException
SAXException
IOException
See Also:
XMLFilterImpl.parse(org.xml.sax.InputSource)

alternateParse

public void alternateParse(InputSource input)
                    throws SAXException,
                           IOException
Parse a plain text catalog.

Specified by:
alternateParse in class SAXSafeParser
Parameters:
input - The input to parse.
Throws:
SAXException
IOException
See Also:
SAXSafeParser.alternateParse(org.xml.sax.InputSource)