org.inria.ns.reflex.xml.sax
Class SAXFragmentParser

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.SAXFragmentParser
All Implemented Interfaces:
Localizable, ContentHandler, DTDHandler, EntityResolver, ErrorHandler, DeclHandler, LexicalHandler, XMLFilter, XMLReader

public class SAXFragmentParser
extends SAXFilter

SAXFragmentParser fires SAX events from an XML fragment source that has not necessary a unique root element, or that may have text content around the root element(s).

The XML fragment mustn't contain DTD stuff : it must be a pure mix of XML tags and/or text.

The fragment may begin with a text declaration.

Author:
Philippe Poulard
See Also:
DOMFragmentParser, SAXAdaptableParser

Constructor Summary
SAXFragmentParser(ParserConfiguration parserConfiguration)
          Create a SAX parser for XML fragments.
 
Method Summary
 void attributeDecl(String eName, String aName, String type, String valueDefault, String value)
          Fire a SAX event.
 void characters(char[] ch, int start, int length)
          Fire a SAX event.
 void comment(char[] ch, int start, int length)
          Fire a SAX event.
 void elementDecl(String name, String model)
          Fire a SAX event.
 void endCDATA()
          Fire a SAX event.
 void endDocument()
          Fire a SAX event.
 void endDTD()
          Fire a SAX event.
 void endElement(String uri, String localName, String qName)
          Fire a SAX event.
 void endEntity(String name)
          Fire a SAX event.
 void endPrefixMapping(String prefix)
          Fire a SAX event.
 void externalEntityDecl(String name, String publicId, String systemId)
          Fire a SAX event.
 void flushEvents()
          Flush all events buffered, causing firing several SAX events.
 void ignorableWhitespace(char[] ch, int start, int length)
          Fire a SAX event.
 void internalEntityDecl(String name, String value)
          Fire a SAX event.
 void parse(InputSource input)
          Parse an input source.
 void processingInstruction(String target, String data)
          Fire a SAX event.
 InputSource resolveEntity(String publicId, String systemId)
           
 void startCDATA()
          Fire a SAX event.
 void startDocument()
          Fire a SAX event.
 void startDTD(String name, String publicId, String systemId)
          Fire a SAX event.
 void startElement(String uri, String localName, String qName, Attributes atts)
          Fire a SAX event.
 void startEntity(String name)
          Fire a SAX event.
 void startPrefixMapping(String prefix, String uri)
          Fire a SAX event.
 
Methods inherited from class org.inria.ns.reflex.xml.sax.SAXFilter
getDeclHandler, getLexicalHandler, getLocation, getProperty, isLocalizable, parse, setDeclHandler, setLexicalHandler, setLocation, setProperty
 
Methods inherited from class org.xml.sax.helpers.XMLFilterImpl
error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, notationDecl, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, skippedEntity, 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
setDocumentLocator, skippedEntity
 
Methods inherited from interface org.xml.sax.DTDHandler
notationDecl, unparsedEntityDecl
 

Constructor Detail

SAXFragmentParser

public SAXFragmentParser(ParserConfiguration parserConfiguration)
Create a SAX parser for XML fragments.

Parameters:
configuration - The non-null configuration expected for the parser, if one is needed.
Method Detail

parse

public void parse(InputSource input)
           throws SAXException,
                  IOException
Parse an input source.

Specified by:
parse in interface XMLReader
Overrides:
parse in class XMLFilterImpl
Parameters:
input - The input to parse.
Throws:
SAXException
IOException
See Also:
XMLFilterImpl.parse(org.xml.sax.InputSource)

resolveEntity

public InputSource resolveEntity(String publicId,
                                 String systemId)
                          throws SAXException,
                                 IOException
Specified by:
resolveEntity in interface EntityResolver
Overrides:
resolveEntity in class XMLFilterImpl
Throws:
SAXException
IOException
See Also:
XMLFilterImpl.resolveEntity(java.lang.String, java.lang.String)

flushEvents

public void flushEvents()
                 throws SAXException
Flush all events buffered, causing firing several SAX events.

Throws:
SAXException

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes atts)
                  throws SAXException
Fire a SAX event.

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class XMLFilterImpl
Throws:
SAXException
See Also:
XMLFilterImpl.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
                throws SAXException
Fire a SAX event.

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class XMLFilterImpl
Throws:
SAXException
See Also:
XMLFilterImpl.endElement(java.lang.String, java.lang.String, java.lang.String)

startDocument

public void startDocument()
                   throws SAXException
Fire a SAX event. This event is deferred until real content is encountered.

Specified by:
startDocument in interface ContentHandler
Overrides:
startDocument in class SAXFilter
Throws:
SAXException - The client may throw an exception during processing.
See Also:
flushEvents(), XMLFilterImpl.startDocument()

endDocument

public void endDocument()
                 throws SAXException
Fire a SAX event.

Specified by:
endDocument in interface ContentHandler
Overrides:
endDocument in class SAXFilter
Throws:
SAXException - The client may throw an exception during processing.
See Also:
XMLFilterImpl.endDocument()

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Fire a SAX event. This event is deferred until real content is encountered.

Specified by:
characters in interface ContentHandler
Overrides:
characters in class XMLFilterImpl
Throws:
SAXException
See Also:
flushEvents(), XMLFilterImpl.characters(char[], int, int)

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws SAXException
Fire a SAX event. This event is deferred until real content is encountered.

Specified by:
ignorableWhitespace in interface ContentHandler
Overrides:
ignorableWhitespace in class XMLFilterImpl
Throws:
SAXException
See Also:
flushEvents(), XMLFilterImpl.ignorableWhitespace(char[], int, int)

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Fire a SAX event. This event is deferred until real content is encountered.

Specified by:
processingInstruction in interface ContentHandler
Overrides:
processingInstruction in class XMLFilterImpl
Throws:
SAXException
See Also:
flushEvents(), XMLFilterImpl.processingInstruction(java.lang.String, java.lang.String)

comment

public void comment(char[] ch,
                    int start,
                    int length)
             throws SAXException
Fire a SAX event. This event is deferred until real content is encountered.

Specified by:
comment in interface LexicalHandler
Overrides:
comment in class SAXFilter
Throws:
SAXException
See Also:
flushEvents(), SAXFilter.comment(char[], int, int)

endCDATA

public void endCDATA()
              throws SAXException
Fire a SAX event. This event is deferred until real content is encountered.

Specified by:
endCDATA in interface LexicalHandler
Overrides:
endCDATA in class SAXFilter
Throws:
SAXException
See Also:
flushEvents(), SAXFilter.endCDATA()

startCDATA

public void startCDATA()
                throws SAXException
Fire a SAX event. This event is deferred until real content is encountered.

Specified by:
startCDATA in interface LexicalHandler
Overrides:
startCDATA in class SAXFilter
Throws:
SAXException
See Also:
flushEvents(), SAXFilter.startCDATA()

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws SAXException
Fire a SAX event. This event is deferred until real content is encountered.

Specified by:
startPrefixMapping in interface ContentHandler
Overrides:
startPrefixMapping in class XMLFilterImpl
Throws:
SAXException
See Also:
flushEvents(), XMLFilterImpl.startPrefixMapping(java.lang.String, java.lang.String)

endPrefixMapping

public void endPrefixMapping(String prefix)
                      throws SAXException
Fire a SAX event. This event is deferred until real content is encountered.

Specified by:
endPrefixMapping in interface ContentHandler
Overrides:
endPrefixMapping in class XMLFilterImpl
Throws:
SAXException
See Also:
flushEvents(), XMLFilterImpl.startPrefixMapping(java.lang.String, java.lang.String)

startDTD

public void startDTD(String name,
                     String publicId,
                     String systemId)
              throws SAXException
Description copied from class: SAXFilter
Fire a SAX event.

Specified by:
startDTD in interface LexicalHandler
Overrides:
startDTD in class SAXFilter
Throws:
SAXException
See Also:
LexicalHandler.startDTD(java.lang.String, java.lang.String, java.lang.String)

endDTD

public void endDTD()
            throws SAXException
Description copied from class: SAXFilter
Fire a SAX event.

Specified by:
endDTD in interface LexicalHandler
Overrides:
endDTD in class SAXFilter
Throws:
SAXException
See Also:
LexicalHandler.endDTD()

startEntity

public void startEntity(String name)
                 throws SAXException
Description copied from class: SAXFilter
Fire a SAX event.

Specified by:
startEntity in interface LexicalHandler
Overrides:
startEntity in class SAXFilter
Throws:
SAXException
See Also:
LexicalHandler.startEntity(java.lang.String)

endEntity

public void endEntity(String name)
               throws SAXException
Description copied from class: SAXFilter
Fire a SAX event.

Specified by:
endEntity in interface LexicalHandler
Overrides:
endEntity in class SAXFilter
Throws:
SAXException
See Also:
LexicalHandler.endEntity(java.lang.String)

elementDecl

public void elementDecl(String name,
                        String model)
                 throws SAXException
Description copied from class: SAXFilter
Fire a SAX event.

Specified by:
elementDecl in interface DeclHandler
Overrides:
elementDecl in class SAXFilter
Throws:
SAXException
See Also:
DeclHandler.elementDecl(java.lang.String, java.lang.String)

attributeDecl

public void attributeDecl(String eName,
                          String aName,
                          String type,
                          String valueDefault,
                          String value)
                   throws SAXException
Description copied from class: SAXFilter
Fire a SAX event.

Specified by:
attributeDecl in interface DeclHandler
Overrides:
attributeDecl in class SAXFilter
Throws:
SAXException
See Also:
DeclHandler.attributeDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

internalEntityDecl

public void internalEntityDecl(String name,
                               String value)
                        throws SAXException
Description copied from class: SAXFilter
Fire a SAX event.

Specified by:
internalEntityDecl in interface DeclHandler
Overrides:
internalEntityDecl in class SAXFilter
Throws:
SAXException
See Also:
DeclHandler.internalEntityDecl(java.lang.String, java.lang.String)

externalEntityDecl

public void externalEntityDecl(String name,
                               String publicId,
                               String systemId)
                        throws SAXException
Description copied from class: SAXFilter
Fire a SAX event.

Specified by:
externalEntityDecl in interface DeclHandler
Overrides:
externalEntityDecl in class SAXFilter
Throws:
SAXException
See Also:
DeclHandler.externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)