org.cyberneko.html.parsers
Class DOMFragmentParser

java.lang.Object
  extended byorg.cyberneko.html.parsers.DOMFragmentParser
All Implemented Interfaces:
XMLDocumentHandler

public class DOMFragmentParser
extends Object
implements XMLDocumentHandler

A DOM parser for HTML fragments.

Version:
$Id$
Author:
Andy Clark

Field Summary
protected static String CURRENT_ELEMENT_NODE
          Current element node.
protected static String DOCUMENT_FRAGMENT
          Document fragment balancing only.
protected static String ERROR_HANDLER
          Property identifier: error handler.
protected  Node fCurrentNode
          Current node.
protected  Document fDocument
          Document.
protected  DocumentFragment fDocumentFragment
          DOM document fragment.
protected  XMLDocumentSource fDocumentSource
          Document source.
protected  boolean fInCDATASection
          True if within a CDATA section.
protected  XMLParserConfiguration fParserConfiguration
          Parser configuration.
protected static String[] RECOGNIZED_FEATURES
          Recognized features.
protected static String[] RECOGNIZED_PROPERTIES
          Recognized properties.
 
Constructor Summary
DOMFragmentParser()
          Default constructor.
 
Method Summary
 void characters(XMLString text, Augmentations augs)
          Characters.
 void comment(XMLString text, Augmentations augs)
          Comment.
 void doctypeDecl(String root, String pubid, String sysid, Augmentations augs)
          Document type declaration.
 void emptyElement(QName element, XMLAttributes attrs, Augmentations augs)
          Empty element.
 void endCDATA(Augmentations augs)
          End CDATA section.
 void endDocument(Augmentations augs)
          End document.
 void endElement(QName element, Augmentations augs)
          End element.
 void endGeneralEntity(String name, Augmentations augs)
          End general entity.
 void endPrefixMapping(String prefix, Augmentations augs)
          End prefix mapping.
 XMLDocumentSource getDocumentSource()
          Returns the document source.
 ErrorHandler getErrorHandler()
          Return the current error handler.
 boolean getFeature(String featureId)
          Query the state of a feature.
 Object getProperty(String propertyId)
          Query the value of a property.
 void ignorableWhitespace(XMLString text, Augmentations augs)
          Ignorable whitespace.
 void parse(InputSource source, DocumentFragment fragment)
          Parses a document fragment.
 void parse(String systemId, DocumentFragment fragment)
          Parses a document fragment.
 void processingInstruction(String target, XMLString data, Augmentations augs)
          Processing instruction.
 void setDocumentSource(XMLDocumentSource source)
          Sets the document source.
 void setErrorHandler(ErrorHandler errorHandler)
          Allow an application to register an error event handler.
 void setFeature(String featureId, boolean state)
          Set the state of any feature in a SAX2 parser.
 void setProperty(String propertyId, Object value)
          Set the value of any property in a SAX2 parser.
 void startCDATA(Augmentations augs)
          Start CDATA section.
 void startDocument(XMLLocator locator, String encoding, Augmentations augs)
          Start document.
 void startDocument(XMLLocator locator, String encoding, NamespaceContext nscontext, Augmentations augs)
          Start document.
 void startElement(QName element, XMLAttributes attrs, Augmentations augs)
          Start element.
 void startGeneralEntity(String name, XMLResourceIdentifier id, String encoding, Augmentations augs)
          Start general entity.
 void startPrefixMapping(String prefix, String uri, Augmentations augs)
          Start prefix mapping.
 void textDecl(String version, String encoding, Augmentations augs)
          Text declaration.
 void xmlDecl(String version, String encoding, String standalone, Augmentations augs)
          XML declaration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOCUMENT_FRAGMENT

protected static final String DOCUMENT_FRAGMENT
Document fragment balancing only.

See Also:
Constant Field Values

RECOGNIZED_FEATURES

protected static final String[] RECOGNIZED_FEATURES
Recognized features.


ERROR_HANDLER

protected static final String ERROR_HANDLER
Property identifier: error handler.

See Also:
Constant Field Values

CURRENT_ELEMENT_NODE

protected static final String CURRENT_ELEMENT_NODE
Current element node.

See Also:
Constant Field Values

RECOGNIZED_PROPERTIES

protected static final String[] RECOGNIZED_PROPERTIES
Recognized properties.


fParserConfiguration

protected XMLParserConfiguration fParserConfiguration
Parser configuration.


fDocumentSource

protected XMLDocumentSource fDocumentSource
Document source.


fDocumentFragment

protected DocumentFragment fDocumentFragment
DOM document fragment.


fDocument

protected Document fDocument
Document.


fCurrentNode

protected Node fCurrentNode
Current node.


fInCDATASection

protected boolean fInCDATASection
True if within a CDATA section.

Constructor Detail

DOMFragmentParser

public DOMFragmentParser()
Default constructor.

Method Detail

parse

public void parse(String systemId,
                  DocumentFragment fragment)
           throws SAXException,
                  IOException
Parses a document fragment.

Throws:
SAXException
IOException

parse

public void parse(InputSource source,
                  DocumentFragment fragment)
           throws SAXException,
                  IOException
Parses a document fragment.

Throws:
SAXException
IOException

setErrorHandler

public void setErrorHandler(ErrorHandler errorHandler)
Allow an application to register an error event handler.

If the application does not register an error handler, all error events reported by the SAX parser will be silently ignored; however, normal processing may not continue. It is highly recommended that all SAX applications implement an error handler to avoid unexpected bugs.

Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.

Parameters:
errorHandler - The error handler.
Throws:
NullPointerException - If the handler argument is null.
See Also:
getErrorHandler()

getErrorHandler

public ErrorHandler getErrorHandler()
Return the current error handler.

Returns:
The current error handler, or null if none has been registered.
See Also:
setErrorHandler(org.xml.sax.ErrorHandler)

setFeature

public void setFeature(String featureId,
                       boolean state)
                throws SAXNotRecognizedException,
                       SAXNotSupportedException
Set the state of any feature in a SAX2 parser. The parser might not recognize the feature, and if it does recognize it, it might not be able to fulfill the request.

Parameters:
featureId - The unique identifier (URI) of the feature.
state - The requested state of the feature (true or false).
Throws:
SAXNotRecognizedException - If the requested feature is not known.
SAXNotSupportedException - If the requested feature is known, but the requested state is not supported.

getFeature

public boolean getFeature(String featureId)
                   throws SAXNotRecognizedException,
                          SAXNotSupportedException
Query the state of a feature. Query the current state of any feature in a SAX2 parser. The parser might not recognize the feature.

Parameters:
featureId - The unique identifier (URI) of the feature being set.
Returns:
The current state of the feature.
Throws:
SAXNotRecognizedException - If the requested feature is not known.
SAXNotSupportedException - If the requested feature is known but not supported.

setProperty

public void setProperty(String propertyId,
                        Object value)
                 throws SAXNotRecognizedException,
                        SAXNotSupportedException
Set the value of any property in a SAX2 parser. The parser might not recognize the property, and if it does recognize it, it might not support the requested value.

Parameters:
propertyId - The unique identifier (URI) of the property being set.
value - The value to which the property is being set.
Throws:
SAXNotRecognizedException - If the requested property is not known.
SAXNotSupportedException - If the requested property is known, but the requested value is not supported.

getProperty

public Object getProperty(String propertyId)
                   throws SAXNotRecognizedException,
                          SAXNotSupportedException
Query the value of a property. Return the current value of a property in a SAX2 parser. The parser might not recognize the property.

Parameters:
propertyId - The unique identifier (URI) of the property being set.
Returns:
The current value of the property.
Throws:
SAXNotRecognizedException - If the requested property is not known.
SAXNotSupportedException - If the requested property is known but not supported.

setDocumentSource

public void setDocumentSource(XMLDocumentSource source)
Sets the document source.

Specified by:
setDocumentSource in interface XMLDocumentHandler

getDocumentSource

public XMLDocumentSource getDocumentSource()
Returns the document source.

Specified by:
getDocumentSource in interface XMLDocumentHandler

startDocument

public void startDocument(XMLLocator locator,
                          String encoding,
                          Augmentations augs)
                   throws XNIException
Start document.

Throws:
XNIException

startDocument

public void startDocument(XMLLocator locator,
                          String encoding,
                          NamespaceContext nscontext,
                          Augmentations augs)
                   throws XNIException
Start document.

Specified by:
startDocument in interface XMLDocumentHandler
Throws:
XNIException

xmlDecl

public void xmlDecl(String version,
                    String encoding,
                    String standalone,
                    Augmentations augs)
             throws XNIException
XML declaration.

Specified by:
xmlDecl in interface XMLDocumentHandler
Throws:
XNIException

doctypeDecl

public void doctypeDecl(String root,
                        String pubid,
                        String sysid,
                        Augmentations augs)
                 throws XNIException
Document type declaration.

Specified by:
doctypeDecl in interface XMLDocumentHandler
Throws:
XNIException

processingInstruction

public void processingInstruction(String target,
                                  XMLString data,
                                  Augmentations augs)
                           throws XNIException
Processing instruction.

Specified by:
processingInstruction in interface XMLDocumentHandler
Throws:
XNIException

comment

public void comment(XMLString text,
                    Augmentations augs)
             throws XNIException
Comment.

Specified by:
comment in interface XMLDocumentHandler
Throws:
XNIException

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri,
                               Augmentations augs)
                        throws XNIException
Start prefix mapping. @deprecated Since Xerces 2.2.0.

Throws:
XNIException

endPrefixMapping

public void endPrefixMapping(String prefix,
                             Augmentations augs)
                      throws XNIException
End prefix mapping. @deprecated Since Xerces 2.2.0.

Throws:
XNIException

startElement

public void startElement(QName element,
                         XMLAttributes attrs,
                         Augmentations augs)
                  throws XNIException
Start element.

Specified by:
startElement in interface XMLDocumentHandler
Throws:
XNIException

emptyElement

public void emptyElement(QName element,
                         XMLAttributes attrs,
                         Augmentations augs)
                  throws XNIException
Empty element.

Specified by:
emptyElement in interface XMLDocumentHandler
Throws:
XNIException

characters

public void characters(XMLString text,
                       Augmentations augs)
                throws XNIException
Characters.

Specified by:
characters in interface XMLDocumentHandler
Throws:
XNIException

ignorableWhitespace

public void ignorableWhitespace(XMLString text,
                                Augmentations augs)
                         throws XNIException
Ignorable whitespace.

Specified by:
ignorableWhitespace in interface XMLDocumentHandler
Throws:
XNIException

startGeneralEntity

public void startGeneralEntity(String name,
                               XMLResourceIdentifier id,
                               String encoding,
                               Augmentations augs)
                        throws XNIException
Start general entity.

Specified by:
startGeneralEntity in interface XMLDocumentHandler
Throws:
XNIException

textDecl

public void textDecl(String version,
                     String encoding,
                     Augmentations augs)
              throws XNIException
Text declaration.

Specified by:
textDecl in interface XMLDocumentHandler
Throws:
XNIException

endGeneralEntity

public void endGeneralEntity(String name,
                             Augmentations augs)
                      throws XNIException
End general entity.

Specified by:
endGeneralEntity in interface XMLDocumentHandler
Throws:
XNIException

startCDATA

public void startCDATA(Augmentations augs)
                throws XNIException
Start CDATA section.

Specified by:
startCDATA in interface XMLDocumentHandler
Throws:
XNIException

endCDATA

public void endCDATA(Augmentations augs)
              throws XNIException
End CDATA section.

Specified by:
endCDATA in interface XMLDocumentHandler
Throws:
XNIException

endElement

public void endElement(QName element,
                       Augmentations augs)
                throws XNIException
End element.

Specified by:
endElement in interface XMLDocumentHandler
Throws:
XNIException

endDocument

public void endDocument(Augmentations augs)
                 throws XNIException
End document.

Specified by:
endDocument in interface XMLDocumentHandler
Throws:
XNIException


(C) Copyright 2002-2004, Andy Clark. All rights reserved.