| java.lang.Object org.cyberneko.html.HTMLTagBalancer
HTMLTagBalancer | public class HTMLTagBalancer implements XMLDocumentFilter,HTMLComponent(Code) | | Balances tags in an HTML document. This component receives document events
and tries to correct many common mistakes that human (and computer) HTML
document authors make. This tag balancer can:
- add missing parent elements;
- automatically close elements with optional end tags; and
- handle mis-matched inline element tags.
This component recognizes the following features:
- http://cyberneko.org/html/features/augmentations
- http://cyberneko.org/html/features/report-errors
- http://cyberneko.org/html/features/balance-tags/document-fragment
- http://cyberneko.org/html/features/balance-tags/ignore-outside-content
This component recognizes the following properties:
- http://cyberneko.org/html/properties/names/elems
- http://cyberneko.org/html/properties/names/attrs
- http://cyberneko.org/html/properties/error-reporter
See Also: HTMLElements author: Andy Clark version: $Id: HTMLTagBalancer.java,v 1.20 2005/02/14 04:06:22 andyc Exp $ |
Inner Class :public static class Info | |
Inner Class :public static class InfoStack | |
Method Summary | |
final protected void | callEndElement(QName element, Augmentations augs) Call document handler end element. | final protected void | callStartElement(QName element, XMLAttributes attrs, Augmentations augs) Call document handler start element. | public void | characters(XMLString text, Augmentations augs) Characters. | public void | comment(XMLString text, Augmentations augs) Comment. | public void | doctypeDecl(String rootElementName, String publicId, String systemId, Augmentations augs) Doctype declaration. | final protected XMLAttributes | emptyAttributes() Returns a set of empty attributes. | public void | emptyElement(QName elem, XMLAttributes attrs, Augmentations augs) Empty element. | public void | endCDATA(Augmentations augs) End CDATA section. | public void | endDocument(Augmentations augs) End document. | public void | endElement(QName element, Augmentations augs) End element. | public void | endGeneralEntity(String name, Augmentations augs) End entity. | public void | endPrefixMapping(String prefix, Augmentations augs) End prefix mapping. | public XMLDocumentHandler | getDocumentHandler() Returns the document handler. | public XMLDocumentSource | getDocumentSource() Returns the document source. | protected HTMLElements.Element | getElement(String name) Returns an HTML element. | final protected int | getElementDepth(HTMLElements.Element element) Returns the depth of the open tag associated with the specified
element name or -1 if no matching element is found. | public Boolean | getFeatureDefault(String featureId) Returns the default state for a feature. | final protected static short | getNamesValue(String value) Converts HTML names string value to constant value. | protected int | getParentDepth(HTMLElements.Element[] parents, short bounds) Returns the depth of the open tag associated with the specified
element parent names or -1 if no matching element is found. | public Object | getPropertyDefault(String propertyId) Returns the default state for a property. | public String[] | getRecognizedFeatures() Returns recognized features. | public String[] | getRecognizedProperties() Returns recognized properties. | public void | ignorableWhitespace(XMLString text, Augmentations augs) Ignorable whitespace. | final protected static String | modifyName(String name, short mode) Modifies the given name based on the specified mode. | public void | processingInstruction(String target, XMLString data, Augmentations augs) Processing instruction. | public void | reset(XMLComponentManager manager) Resets the component. | public void | setDocumentHandler(XMLDocumentHandler handler) Sets the document handler. | public void | setDocumentSource(XMLDocumentSource source) Sets the document source. | public void | setFeature(String featureId, boolean state) Sets a feature. | public void | setProperty(String propertyId, Object value) Sets a property. | void | setTagBalancingListener(HTMLTagBalancingListener tagBalancingListener) | public void | startCDATA(Augmentations augs) Start CDATA section. | public void | startDocument(XMLLocator locator, String encoding, NamespaceContext nscontext, Augmentations augs) Start document. | public void | startDocument(XMLLocator locator, String encoding, Augmentations augs) Start document. | public void | startElement(QName elem, XMLAttributes attrs, Augmentations augs) Start element. | public void | startGeneralEntity(String name, XMLResourceIdentifier id, String encoding, Augmentations augs) Start entity. | public void | startPrefixMapping(String prefix, String uri, Augmentations augs) Start prefix mapping. | final protected Augmentations | synthesizedAugs() Returns an augmentations object with a synthesized item added. | public void | textDecl(String version, String encoding, Augmentations augs) Text declaration. | public void | xmlDecl(String version, String encoding, String standalone, Augmentations augs) XML declaration. |
AUGMENTATIONS | final protected static String AUGMENTATIONS(Code) | | Include infoset augmentations.
|
DOCUMENT_FRAGMENT | final protected static String DOCUMENT_FRAGMENT(Code) | | Document fragment balancing only.
|
DOCUMENT_FRAGMENT_DEPRECATED | final protected static String DOCUMENT_FRAGMENT_DEPRECATED(Code) | | Document fragment balancing only (deprecated).
|
ERROR_REPORTER | final protected static String ERROR_REPORTER(Code) | | Error reporter.
|
IGNORE_OUTSIDE_CONTENT | final protected static String IGNORE_OUTSIDE_CONTENT(Code) | | Ignore outside content.
|
NAMESPACES | final protected static String NAMESPACES(Code) | | Namespaces.
|
NAMES_ATTRS | final protected static String NAMES_ATTRS(Code) | | Modify HTML attribute names: { "upper", "lower", "default" }.
|
NAMES_ELEMS | final protected static String NAMES_ELEMS(Code) | | Modify HTML element names: { "upper", "lower", "default" }.
|
NAMES_LOWERCASE | final protected static short NAMES_LOWERCASE(Code) | | Lowercase HTML names.
|
NAMES_MATCH | final protected static short NAMES_MATCH(Code) | | Match HTML element names.
|
NAMES_NO_CHANGE | final protected static short NAMES_NO_CHANGE(Code) | | Don't modify HTML names.
|
NAMES_UPPERCASE | final protected static short NAMES_UPPERCASE(Code) | | Uppercase HTML names.
|
REPORT_ERRORS | final protected static String REPORT_ERRORS(Code) | | Report errors.
|
SYNTHESIZED_ITEM | final protected static HTMLEventInfo SYNTHESIZED_ITEM(Code) | | Synthesized event info item.
|
fAugmentations | protected boolean fAugmentations(Code) | | Include infoset augmentations.
|
fDocumentFragment | protected boolean fDocumentFragment(Code) | | Document fragment balancing only.
|
fDocumentHandler | protected XMLDocumentHandler fDocumentHandler(Code) | | The document handler.
|
fDocumentSource | protected XMLDocumentSource fDocumentSource(Code) | | The document source.
|
fElementStack | final protected InfoStack fElementStack(Code) | | The element stack.
|
fIgnoreOutsideContent | protected boolean fIgnoreOutsideContent(Code) | | Ignore outside content.
|
fInlineStack | final protected InfoStack fInlineStack(Code) | | The inline stack.
|
fNamesAttrs | protected short fNamesAttrs(Code) | | Modify HTML attribute names.
|
fNamesElems | protected short fNamesElems(Code) | | Modify HTML element names.
|
fNamespaces | protected boolean fNamespaces(Code) | | Namespaces.
|
fOpenedForm | protected boolean fOpenedForm(Code) | | True if a form is in the stack (allow to discard opening of nested forms)
|
fReportErrors | protected boolean fReportErrors(Code) | | Report errors.
|
fSeenAnything | protected boolean fSeenAnything(Code) | | True if seen anything. Important for xml declaration.
|
fSeenBodyElement | protected boolean fSeenBodyElement(Code) | | True if seen <body< element.
|
fSeenDoctype | protected boolean fSeenDoctype(Code) | | True if root element has been seen.
|
fSeenHeadElement | protected boolean fSeenHeadElement(Code) | | True if seen <head< element.
|
fSeenRootElement | protected boolean fSeenRootElement(Code) | | True if root element has been seen.
|
fSeenRootElementEnd | protected boolean fSeenRootElementEnd(Code) | | True if seen the end of the document element. In other words,
this variable is set to false until the end </HTML>
tag is seen (or synthesized). This is used to ensure that
extraneous events after the end of the document element do not
make the document stream ill-formed.
|
callEndElement | final protected void callEndElement(QName element, Augmentations augs) throws XNIException(Code) | | Call document handler end element.
|
callStartElement | final protected void callStartElement(QName element, XMLAttributes attrs, Augmentations augs) throws XNIException(Code) | | Call document handler start element.
|
characters | public void characters(XMLString text, Augmentations augs) throws XNIException(Code) | | Characters.
|
comment | public void comment(XMLString text, Augmentations augs) throws XNIException(Code) | | Comment.
|
doctypeDecl | public void doctypeDecl(String rootElementName, String publicId, String systemId, Augmentations augs) throws XNIException(Code) | | Doctype declaration.
|
emptyAttributes | final protected XMLAttributes emptyAttributes()(Code) | | Returns a set of empty attributes.
|
emptyElement | public void emptyElement(QName elem, XMLAttributes attrs, Augmentations augs) throws XNIException(Code) | | Empty element.
|
endCDATA | public void endCDATA(Augmentations augs) throws XNIException(Code) | | End CDATA section.
|
endDocument | public void endDocument(Augmentations augs) throws XNIException(Code) | | End document.
|
endElement | public void endElement(QName element, Augmentations augs) throws XNIException(Code) | | End element.
|
endGeneralEntity | public void endGeneralEntity(String name, Augmentations augs) throws XNIException(Code) | | End entity.
|
endPrefixMapping | public void endPrefixMapping(String prefix, Augmentations augs) throws XNIException(Code) | | End prefix mapping.
|
getDocumentHandler | public XMLDocumentHandler getDocumentHandler()(Code) | | Returns the document handler.
|
getDocumentSource | public XMLDocumentSource getDocumentSource()(Code) | | Returns the document source.
|
getElementDepth | final protected int getElementDepth(HTMLElements.Element element)(Code) | | Returns the depth of the open tag associated with the specified
element name or -1 if no matching element is found.
Parameters: element - The element. |
getFeatureDefault | public Boolean getFeatureDefault(String featureId)(Code) | | Returns the default state for a feature.
|
getParentDepth | protected int getParentDepth(HTMLElements.Element[] parents, short bounds)(Code) | | Returns the depth of the open tag associated with the specified
element parent names or -1 if no matching element is found.
Parameters: parents - The parent elements. |
getPropertyDefault | public Object getPropertyDefault(String propertyId)(Code) | | Returns the default state for a property.
|
getRecognizedFeatures | public String[] getRecognizedFeatures()(Code) | | Returns recognized features.
|
getRecognizedProperties | public String[] getRecognizedProperties()(Code) | | Returns recognized properties.
|
ignorableWhitespace | public void ignorableWhitespace(XMLString text, Augmentations augs) throws XNIException(Code) | | Ignorable whitespace.
|
modifyName | final protected static String modifyName(String name, short mode)(Code) | | Modifies the given name based on the specified mode.
|
processingInstruction | public void processingInstruction(String target, XMLString data, Augmentations augs) throws XNIException(Code) | | Processing instruction.
|
reset | public void reset(XMLComponentManager manager) throws XMLConfigurationException(Code) | | Resets the component.
|
setDocumentHandler | public void setDocumentHandler(XMLDocumentHandler handler)(Code) | | Sets the document handler.
|
setDocumentSource | public void setDocumentSource(XMLDocumentSource source)(Code) | | Sets the document source.
|
setFeature | public void setFeature(String featureId, boolean state) throws XMLConfigurationException(Code) | | Sets a feature.
|
setProperty | public void setProperty(String propertyId, Object value) throws XMLConfigurationException(Code) | | Sets a property.
|
startCDATA | public void startCDATA(Augmentations augs) throws XNIException(Code) | | Start CDATA section.
|
startDocument | public void startDocument(XMLLocator locator, String encoding, NamespaceContext nscontext, Augmentations augs) throws XNIException(Code) | | Start document.
|
startDocument | public void startDocument(XMLLocator locator, String encoding, Augmentations augs) throws XNIException(Code) | | Start document.
|
startElement | public void startElement(QName elem, XMLAttributes attrs, Augmentations augs) throws XNIException(Code) | | Start element.
|
startGeneralEntity | public void startGeneralEntity(String name, XMLResourceIdentifier id, String encoding, Augmentations augs) throws XNIException(Code) | | Start entity.
|
startPrefixMapping | public void startPrefixMapping(String prefix, String uri, Augmentations augs) throws XNIException(Code) | | Start prefix mapping.
|
synthesizedAugs | final protected Augmentations synthesizedAugs()(Code) | | Returns an augmentations object with a synthesized item added.
|
textDecl | public void textDecl(String version, String encoding, Augmentations augs) throws XNIException(Code) | | Text declaration.
|
xmlDecl | public void xmlDecl(String version, String encoding, String standalone, Augmentations augs) throws XNIException(Code) | | XML declaration.
|
|
|