org.cyberneko.html.parsers

Class DOMFragmentParser

public class DOMFragmentParser extends Object implements XMLDocumentHandler

A DOM parser for HTML fragments.

Version: $Id: DOMFragmentParser.java,v 1.8 2005/02/14 03:56:54 andyc Exp $

Author: Andy Clark

Field Summary
protected static StringCURRENT_ELEMENT_NODE
Current element node.
protected static StringDOCUMENT_FRAGMENT
Document fragment balancing only.
protected static StringERROR_HANDLER
Property identifier: error handler.
protected NodefCurrentNode
Current node.
protected DocumentfDocument
Document.
protected DocumentFragmentfDocumentFragment
DOM document fragment.
protected XMLDocumentSourcefDocumentSource
Document source.
protected booleanfInCDATASection
True if within a CDATA section.
protected XMLParserConfigurationfParserConfiguration
Parser configuration.
protected static String[]RECOGNIZED_FEATURES
Recognized features.
protected static String[]RECOGNIZED_PROPERTIES
Recognized properties.
Constructor Summary
DOMFragmentParser()
Default constructor.
Method Summary
voidcharacters(XMLString text, Augmentations augs)
Characters.
voidcomment(XMLString text, Augmentations augs)
Comment.
voiddoctypeDecl(String root, String pubid, String sysid, Augmentations augs)
Document type declaration.
voidemptyElement(QName element, XMLAttributes attrs, Augmentations augs)
Empty element.
voidendCDATA(Augmentations augs)
End CDATA section.
voidendDocument(Augmentations augs)
End document.
voidendElement(QName element, Augmentations augs)
End element.
voidendGeneralEntity(String name, Augmentations augs)
End general entity.
voidendPrefixMapping(String prefix, Augmentations augs)
End prefix mapping.
XMLDocumentSourcegetDocumentSource()
Returns the document source.
ErrorHandlergetErrorHandler()
Return the current error handler.
booleangetFeature(String featureId)
Query the state of a feature.
ObjectgetProperty(String propertyId)
Query the value of a property.
voidignorableWhitespace(XMLString text, Augmentations augs)
Ignorable whitespace.
voidparse(String systemId, DocumentFragment fragment)
Parses a document fragment.
voidparse(InputSource source, DocumentFragment fragment)
Parses a document fragment.
voidprocessingInstruction(String target, XMLString data, Augmentations augs)
Processing instruction.
voidsetDocumentSource(XMLDocumentSource source)
Sets the document source.
voidsetErrorHandler(ErrorHandler errorHandler)
Allow an application to register an error event handler.
voidsetFeature(String featureId, boolean state)
Set the state of any feature in a SAX2 parser.
voidsetProperty(String propertyId, Object value)
Set the value of any property in a SAX2 parser.
voidstartCDATA(Augmentations augs)
Start CDATA section.
voidstartDocument(XMLLocator locator, String encoding, Augmentations augs)
Start document.
voidstartDocument(XMLLocator locator, String encoding, NamespaceContext nscontext, Augmentations augs)
Start document.
voidstartElement(QName element, XMLAttributes attrs, Augmentations augs)
Start element.
voidstartGeneralEntity(String name, XMLResourceIdentifier id, String encoding, Augmentations augs)
Start general entity.
voidstartPrefixMapping(String prefix, String uri, Augmentations augs)
Start prefix mapping.
voidtextDecl(String version, String encoding, Augmentations augs)
Text declaration.
voidxmlDecl(String version, String encoding, String standalone, Augmentations augs)
XML declaration.

Field Detail

CURRENT_ELEMENT_NODE

protected static final String CURRENT_ELEMENT_NODE
Current element node.

DOCUMENT_FRAGMENT

protected static final String DOCUMENT_FRAGMENT
Document fragment balancing only.

ERROR_HANDLER

protected static final String ERROR_HANDLER
Property identifier: error handler.

fCurrentNode

protected Node fCurrentNode
Current node.

fDocument

protected Document fDocument
Document.

fDocumentFragment

protected DocumentFragment fDocumentFragment
DOM document fragment.

fDocumentSource

protected XMLDocumentSource fDocumentSource
Document source.

fInCDATASection

protected boolean fInCDATASection
True if within a CDATA section.

fParserConfiguration

protected XMLParserConfiguration fParserConfiguration
Parser configuration.

RECOGNIZED_FEATURES

protected static final String[] RECOGNIZED_FEATURES
Recognized features.

RECOGNIZED_PROPERTIES

protected static final String[] RECOGNIZED_PROPERTIES
Recognized properties.

Constructor Detail

DOMFragmentParser

public DOMFragmentParser()
Default constructor.

Method Detail

characters

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

comment

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

doctypeDecl

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

emptyElement

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

endCDATA

public void endCDATA(Augmentations augs)
End CDATA section.

endDocument

public void endDocument(Augmentations augs)
End document.

endElement

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

endGeneralEntity

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

endPrefixMapping

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

getDocumentSource

public XMLDocumentSource getDocumentSource()
Returns the document source.

getErrorHandler

public ErrorHandler getErrorHandler()
Return the current error handler.

Returns: The current error handler, or null if none has been registered.

See Also: DOMFragmentParser

getFeature

public boolean getFeature(String featureId)
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: org.xml.sax.SAXNotRecognizedException If the requested feature is not known. SAXNotSupportedException If the requested feature is known but not supported.

getProperty

public Object getProperty(String propertyId)
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: org.xml.sax.SAXNotRecognizedException If the requested property is not known. SAXNotSupportedException If the requested property is known but not supported.

ignorableWhitespace

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

parse

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

parse

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

processingInstruction

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

setDocumentSource

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

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: java.lang.NullPointerException If the handler argument is null.

See Also: DOMFragmentParser

setFeature

public void setFeature(String featureId, boolean state)
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.

setProperty

public void setProperty(String propertyId, Object value)
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.

startCDATA

public void startCDATA(Augmentations augs)
Start CDATA section.

startDocument

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

startDocument

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

startElement

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

startGeneralEntity

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

startPrefixMapping

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

textDecl

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

xmlDecl

public void xmlDecl(String version, String encoding, String standalone, Augmentations augs)
XML declaration.
(C) Copyright 2002-2005, Andy Clark. All rights reserved.