org.ccil.cowan.tagsoup

Class Parser

public class Parser extends DefaultHandler implements ScanHandler, XMLReader, LexicalHandler

The SAX parser class.
Field Summary
static StringautoDetectorProperty
Specifies the AutoDetector (for encoding detection) this Parser uses.
static StringbogonsEmptyFeature
A value of "true" indicates that the parser will give unknown elements a content model of EMPTY; a value of "false", a content model of ANY.
static StringdefaultAttributesFeature
A value of "true" indicates that the parser will return default attribute values for missing attributes that have default values.
static StringexternalGeneralEntitiesFeature
Reports whether this parser processes external general entities (it doesn't).
static StringexternalParameterEntitiesFeature
Reports whether this parser processes external parameter entities (it doesn't).
static StringignorableWhitespaceFeature
A value of "true" indicates that the parser will transmit whitespace in element-only content via the SAX ignorableWhitespace callback.
static StringignoreBogonsFeature
A value of "true" indicates that the parser will ignore unknown elements.
static StringisStandaloneFeature
May be examined only during a parse, after the startDocument() callback has been completed; read-only.
static StringlexicalHandlerParameterEntitiesFeature
A value of "true" indicates that the LexicalHandler will report the beginning and end of parameter entities (it won't).
static StringlexicalHandlerProperty
Used to see some syntax events that are essential in some applications: comments, CDATA delimiters, selected general entity inclusions, and the start and end of the DTD (and declaration of document element name).
static StringnamespacePrefixesFeature
A value of "true" indicates that XML qualified names (with prefixes) and attributes (including xmlns* attributes) will be available.
static StringnamespacesFeature
A value of "true" indicates namespace URIs and unprefixed local names for element and attribute names will be available.
static StringresolveDTDURIsFeature
A value of "true" indicates that system IDs in declarations will be absolutized (relative to their base URIs) before reporting.
static StringrestartElementsFeature
A value of "true" indicates that the parser will attempt to restart the restartable elements.
static StringscannerProperty
Specifies the Scanner object this Parser uses.
static StringschemaProperty
Specifies the Schema object this Parser uses.
static StringstringInterningFeature
Has a value of "true" if all XML names (for elements, prefixes, attributes, entities, notations, and local names), as well as Namespace URIs, will have been interned using java.lang.String.intern.
static StringtranslateColonsFeature
A value of "true" indicates that the parser will translate colons into underscores in names.
static StringunicodeNormalizationCheckingFeature
Controls whether the parser reports Unicode normalization errors as described in section 2.13 and Appendix B of the XML 1.1 Recommendation.
static StringuseAttributes2Feature
Returns "true" if the Attributes objects passed by this parser in ContentHandler.startElement() implement the org.xml.sax.ext.Attributes2 interface.
static StringuseEntityResolver2Feature
Returns "true" if, when setEntityResolver is given an object implementing the org.xml.sax.ext.EntityResolver2 interface, those new methods will be used.
static StringuseLocator2Feature
Returns "true" if the Locator objects passed by this parser in ContentHandler.setDocumentLocator() implement the org.xml.sax.ext.Locator2 interface.
static StringvalidationFeature
Controls whether the parser is reporting all validity errors (We don't report any validity errors.)
static StringxmlnsURIsFeature
Controls whether, when the namespace-prefixes feature is set, the parser treats namespace declaration attributes as being in the http://www.w3.org/2000/xmlns/ namespace.
static StringXML11Feature
Returns "true" if the parser supports both XML 1.1 and XML 1.0.
Method Summary
voidadup(char[] buff, int offset, int length)
voidaname(char[] buff, int offset, int length)
voidaval(char[] buff, int offset, int length)
voidcmnt(char[] buff, int offset, int length)
voidcomment(char[] ch, int start, int length)
voiddecl(char[] buff, int offset, int length)
Parsing the complete XML Document Type Definition is way too complex, but for many simple cases we can extract something useful from it. doctypedecl ::= '
voidendCDATA()
voidendDTD()
voidendEntity(String name)
voidentity(char[] buff, int offset, int length)
voideof(char[] buff, int offset, int length)
voidetag(char[] buff, int offset, int length)
voidetag_basic(char[] buff, int offset, int length)
booleanetag_cdata(char[] buff, int offset, int length)
ContentHandlergetContentHandler()
DTDHandlergetDTDHandler()
chargetEntity()
EntityResolvergetEntityResolver()
ErrorHandlergetErrorHandler()
booleangetFeature(String name)
ObjectgetProperty(String name)
voidgi(char[] buff, int offset, int length)
voidparse(InputSource input)
voidparse(String systemid)
voidpcdata(char[] buff, int offset, int length)
voidpi(char[] buff, int offset, int length)
voidpitarget(char[] buff, int offset, int length)
voidsetContentHandler(ContentHandler handler)
voidsetDTDHandler(DTDHandler handler)
voidsetEntityResolver(EntityResolver resolver)
voidsetErrorHandler(ErrorHandler handler)
voidsetFeature(String name, boolean value)
voidsetProperty(String name, Object value)
voidstagc(char[] buff, int offset, int length)
voidstage(char[] buff, int offset, int length)
voidstartCDATA()
voidstartDTD(String name, String publicid, String systemid)
voidstartEntity(String name)

Field Detail

autoDetectorProperty

public static final String autoDetectorProperty
Specifies the AutoDetector (for encoding detection) this Parser uses.

bogonsEmptyFeature

public static final String bogonsEmptyFeature
A value of "true" indicates that the parser will give unknown elements a content model of EMPTY; a value of "false", a content model of ANY.

defaultAttributesFeature

public static final String defaultAttributesFeature
A value of "true" indicates that the parser will return default attribute values for missing attributes that have default values.

externalGeneralEntitiesFeature

public static final String externalGeneralEntitiesFeature
Reports whether this parser processes external general entities (it doesn't).

externalParameterEntitiesFeature

public static final String externalParameterEntitiesFeature
Reports whether this parser processes external parameter entities (it doesn't).

ignorableWhitespaceFeature

public static final String ignorableWhitespaceFeature
A value of "true" indicates that the parser will transmit whitespace in element-only content via the SAX ignorableWhitespace callback. Normally this is not done, because HTML is an SGML application and SGML suppresses such whitespace.

ignoreBogonsFeature

public static final String ignoreBogonsFeature
A value of "true" indicates that the parser will ignore unknown elements.

isStandaloneFeature

public static final String isStandaloneFeature
May be examined only during a parse, after the startDocument() callback has been completed; read-only. The value is true if the document specified standalone="yes" in its XML declaration, and otherwise is false. (It's always false.)

lexicalHandlerParameterEntitiesFeature

public static final String lexicalHandlerParameterEntitiesFeature
A value of "true" indicates that the LexicalHandler will report the beginning and end of parameter entities (it won't).

lexicalHandlerProperty

public static final String lexicalHandlerProperty
Used to see some syntax events that are essential in some applications: comments, CDATA delimiters, selected general entity inclusions, and the start and end of the DTD (and declaration of document element name). The Object must implement org.xml.sax.ext.LexicalHandler.

namespacePrefixesFeature

public static final String namespacePrefixesFeature
A value of "true" indicates that XML qualified names (with prefixes) and attributes (including xmlns* attributes) will be available. We don't support this value.

namespacesFeature

public static final String namespacesFeature
A value of "true" indicates namespace URIs and unprefixed local names for element and attribute names will be available.

resolveDTDURIsFeature

public static final String resolveDTDURIsFeature
A value of "true" indicates that system IDs in declarations will be absolutized (relative to their base URIs) before reporting. (This returns true but doesn't actually do anything.)

restartElementsFeature

public static final String restartElementsFeature
A value of "true" indicates that the parser will attempt to restart the restartable elements.

scannerProperty

public static final String scannerProperty
Specifies the Scanner object this Parser uses.

schemaProperty

public static final String schemaProperty
Specifies the Schema object this Parser uses.

stringInterningFeature

public static final String stringInterningFeature
Has a value of "true" if all XML names (for elements, prefixes, attributes, entities, notations, and local names), as well as Namespace URIs, will have been interned using java.lang.String.intern. This supports fast testing of equality/inequality against string constants, rather than forcing slower calls to String.equals(). (We always intern.)

translateColonsFeature

public static final String translateColonsFeature
A value of "true" indicates that the parser will translate colons into underscores in names.

unicodeNormalizationCheckingFeature

public static final String unicodeNormalizationCheckingFeature
Controls whether the parser reports Unicode normalization errors as described in section 2.13 and Appendix B of the XML 1.1 Recommendation. (We don't normalize.)

useAttributes2Feature

public static final String useAttributes2Feature
Returns "true" if the Attributes objects passed by this parser in ContentHandler.startElement() implement the org.xml.sax.ext.Attributes2 interface. (They don't.)

useEntityResolver2Feature

public static final String useEntityResolver2Feature
Returns "true" if, when setEntityResolver is given an object implementing the org.xml.sax.ext.EntityResolver2 interface, those new methods will be used. (They won't be.)

useLocator2Feature

public static final String useLocator2Feature
Returns "true" if the Locator objects passed by this parser in ContentHandler.setDocumentLocator() implement the org.xml.sax.ext.Locator2 interface. (They don't.)

validationFeature

public static final String validationFeature
Controls whether the parser is reporting all validity errors (We don't report any validity errors.)

xmlnsURIsFeature

public static final String xmlnsURIsFeature
Controls whether, when the namespace-prefixes feature is set, the parser treats namespace declaration attributes as being in the http://www.w3.org/2000/xmlns/ namespace. (It doesn't.)

XML11Feature

public static final String XML11Feature
Returns "true" if the parser supports both XML 1.1 and XML 1.0. (Always false.)

Method Detail

adup

public void adup(char[] buff, int offset, int length)

aname

public void aname(char[] buff, int offset, int length)

aval

public void aval(char[] buff, int offset, int length)

cmnt

public void cmnt(char[] buff, int offset, int length)

comment

public void comment(char[] ch, int start, int length)

decl

public void decl(char[] buff, int offset, int length)
Parsing the complete XML Document Type Definition is way too complex, but for many simple cases we can extract something useful from it. doctypedecl ::= '' DeclSep ::= PEReference | S intSubset ::= (markupdecl | DeclSep)* markupdecl ::= elementdecl | AttlistDecl | EntityDecl | NotationDecl | PI | Comment ExternalID ::= 'SYSTEM' S SystemLiteral | 'PUBLIC' S PubidLiteral S SystemLiteral

endCDATA

public void endCDATA()

endDTD

public void endDTD()

endEntity

public void endEntity(String name)

entity

public void entity(char[] buff, int offset, int length)

eof

public void eof(char[] buff, int offset, int length)

etag

public void etag(char[] buff, int offset, int length)

etag_basic

public void etag_basic(char[] buff, int offset, int length)

etag_cdata

public boolean etag_cdata(char[] buff, int offset, int length)

getContentHandler

public ContentHandler getContentHandler()

getDTDHandler

public DTDHandler getDTDHandler()

getEntity

public char getEntity()

getEntityResolver

public EntityResolver getEntityResolver()

getErrorHandler

public ErrorHandler getErrorHandler()

getFeature

public boolean getFeature(String name)

getProperty

public Object getProperty(String name)

gi

public void gi(char[] buff, int offset, int length)

parse

public void parse(InputSource input)

parse

public void parse(String systemid)

pcdata

public void pcdata(char[] buff, int offset, int length)

pi

public void pi(char[] buff, int offset, int length)

pitarget

public void pitarget(char[] buff, int offset, int length)

setContentHandler

public void setContentHandler(ContentHandler handler)

setDTDHandler

public void setDTDHandler(DTDHandler handler)

setEntityResolver

public void setEntityResolver(EntityResolver resolver)

setErrorHandler

public void setErrorHandler(ErrorHandler handler)

setFeature

public void setFeature(String name, boolean value)

setProperty

public void setProperty(String name, Object value)

stagc

public void stagc(char[] buff, int offset, int length)

stage

public void stage(char[] buff, int offset, int length)

startCDATA

public void startCDATA()

startDTD

public void startDTD(String name, String publicid, String systemid)

startEntity

public void startEntity(String name)
Licence: Academic Free License 3.0 and/or GPL 2.0