public class HTMLTagBalancer extends Object implements XMLDocumentFilter, HTMLComponent
This component recognizes the following features:
This component recognizes the following properties:
HTMLElements| Modifier and Type | Class and Description |
|---|---|
static class |
HTMLTagBalancer.Info
Element info for each start element.
|
static class |
HTMLTagBalancer.InfoStack
Unsynchronized stack of element information.
|
| Modifier and Type | Field and Description |
|---|---|
protected static String |
AUGMENTATIONS
Include infoset augmentations.
|
protected static String |
DOCUMENT_FRAGMENT
Document fragment balancing only.
|
protected static String |
DOCUMENT_FRAGMENT_DEPRECATED
Document fragment balancing only (deprecated).
|
protected static String |
ERROR_REPORTER
Error reporter.
|
protected boolean |
fAllowSelfclosingIframe
Allows self closing iframe tags.
|
protected boolean |
fAllowSelfclosingTags
Allows self closing tags.
|
protected boolean |
fAugmentations
Include infoset augmentations.
|
protected boolean |
fDocumentFragment
Document fragment balancing only.
|
protected XMLDocumentHandler |
fDocumentHandler
The document handler.
|
protected XMLDocumentSource |
fDocumentSource
The document source.
|
protected HTMLTagBalancer.InfoStack |
fElementStack
The element stack.
|
protected HTMLErrorReporter |
fErrorReporter
Error reporter.
|
protected boolean |
fIgnoreOutsideContent
Ignore outside content.
|
protected HTMLTagBalancer.InfoStack |
fInlineStack
The inline stack.
|
protected short |
fNamesAttrs
Modify HTML attribute names.
|
protected short |
fNamesElems
Modify HTML element names.
|
protected boolean |
fNamespaces
Namespaces.
|
protected boolean |
fOpenedForm
True if a form is in the stack (allow to discard opening of nested forms)
|
protected boolean |
fOpenedSvg
True if a svg is in the stack (no parent checking takes place)
|
static String |
FRAGMENT_CONTEXT_STACK
<font color="red">EXPERIMENTAL: may change in next release</font><br/>
Name of the property holding the stack of elements in which context a document fragment should be parsed.
|
protected boolean |
fReportErrors
Report errors.
|
protected boolean |
fSeenAnything
True if seen anything.
|
protected boolean |
fSeenBodyElement
True if seen
body element. |
protected boolean |
fSeenDoctype
True if root element has been seen.
|
protected boolean |
fSeenHeadElement
True if seen
head element. |
protected boolean |
fSeenRootElement
True if root element has been seen.
|
protected boolean |
fSeenRootElementEnd
True if seen the end of the document element.
|
protected boolean |
fTemplateFragment
Template document fragment balancing only.
|
protected static String |
IGNORE_OUTSIDE_CONTENT
Ignore outside content.
|
protected static String |
NAMES_ATTRS
Modify HTML attribute names: { "upper", "lower", "default" }.
|
protected static String |
NAMES_ELEMS
Modify HTML element names: { "upper", "lower", "default" }.
|
protected static short |
NAMES_LOWERCASE
Lowercase HTML names.
|
protected static short |
NAMES_MATCH
Match HTML element names.
|
protected static short |
NAMES_NO_CHANGE
Don't modify HTML names.
|
protected static short |
NAMES_UPPERCASE
Uppercase HTML names.
|
protected static String |
NAMESPACES
Namespaces.
|
protected static String |
REPORT_ERRORS
Report errors.
|
protected static HTMLEventInfo |
SYNTHESIZED_ITEM
Synthesized event info item.
|
protected HTMLTagBalancingListener |
tagBalancingListener |
| Modifier and Type | Method and Description |
|---|---|
protected void |
callEndElement(QName element,
Augmentations augs) |
protected void |
callStartElement(QName element,
XMLAttributes attrs,
Augmentations augs) |
void |
characters(XMLString text,
Augmentations augs)
Characters.
|
void |
comment(XMLString text,
Augmentations augs)
Comment.
|
void |
doctypeDecl(String rootElementName,
String publicId,
String systemId,
Augmentations augs)
Doctype declaration.
|
protected XMLAttributes |
emptyAttributes() |
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 entity.
|
XMLDocumentHandler |
getDocumentHandler()
Returns the document handler.
|
XMLDocumentSource |
getDocumentSource()
Returns the document source.
|
protected HTMLElements.Element |
getElement(QName elementName) |
protected int |
getElementDepth(HTMLElements.Element element) |
Boolean |
getFeatureDefault(String featureId)
Returns the default state for a feature.
|
protected static short |
getNamesValue(String value) |
protected int |
getParentDepth(HTMLElements.Element[] parents,
short bounds) |
Object |
getPropertyDefault(String propertyId)
Returns the default state for a property.
|
String[] |
getRecognizedFeatures()
Returns recognized features.
|
String[] |
getRecognizedProperties()
Returns recognized properties.
|
void |
ignorableWhitespace(XMLString text,
Augmentations augs)
Ignorable whitespace.
|
protected static String |
modifyName(String name,
short mode) |
void |
processingInstruction(String target,
XMLString data,
Augmentations augs)
Processing instruction.
|
void |
reset(XMLComponentManager manager)
Resets the component.
|
void |
setDocumentHandler(XMLDocumentHandler handler)
Sets the document handler.
|
void |
setDocumentSource(XMLDocumentSource source)
Sets the document source.
|
void |
setFeature(String featureId,
boolean state)
Sets a feature.
|
void |
setProperty(String propertyId,
Object value)
Sets a property.
|
void |
startCDATA(Augmentations augs)
Start CDATA section.
|
void |
startDocument(XMLLocator locator,
String encoding,
NamespaceContext nscontext,
Augmentations augs)
Start document.
|
void |
startElement(QName elem,
XMLAttributes attrs,
Augmentations augs)
Start element.
|
void |
startGeneralEntity(String name,
XMLResourceIdentifier id,
String encoding,
Augmentations augs)
Start entity.
|
protected Augmentations |
synthesizedAugs() |
void |
textDecl(String version,
String encoding,
Augmentations augs)
Text declaration.
|
void |
xmlDecl(String version,
String encoding,
String standalone,
Augmentations augs)
XML declaration.
|
protected static final String NAMESPACES
protected static final String AUGMENTATIONS
protected static final String REPORT_ERRORS
protected static final String DOCUMENT_FRAGMENT_DEPRECATED
protected static final String DOCUMENT_FRAGMENT
protected static final String IGNORE_OUTSIDE_CONTENT
protected static final String NAMES_ELEMS
protected static final String NAMES_ATTRS
protected static final String ERROR_REPORTER
public static final String FRAGMENT_CONTEXT_STACK
protected static final short NAMES_NO_CHANGE
protected static final short NAMES_MATCH
protected static final short NAMES_UPPERCASE
protected static final short NAMES_LOWERCASE
protected static final HTMLEventInfo SYNTHESIZED_ITEM
protected boolean fNamespaces
protected boolean fAugmentations
protected boolean fReportErrors
protected boolean fDocumentFragment
protected boolean fTemplateFragment
protected boolean fIgnoreOutsideContent
protected boolean fAllowSelfclosingIframe
protected boolean fAllowSelfclosingTags
protected short fNamesElems
protected short fNamesAttrs
protected HTMLErrorReporter fErrorReporter
protected XMLDocumentSource fDocumentSource
protected XMLDocumentHandler fDocumentHandler
protected final HTMLTagBalancer.InfoStack fElementStack
protected final HTMLTagBalancer.InfoStack fInlineStack
protected boolean fSeenAnything
protected boolean fSeenDoctype
protected boolean fSeenRootElement
protected boolean fSeenRootElementEnd
protected boolean fSeenHeadElement
head element.protected boolean fSeenBodyElement
body element.protected boolean fOpenedForm
protected boolean fOpenedSvg
protected HTMLTagBalancingListener tagBalancingListener
public Boolean getFeatureDefault(String featureId)
getFeatureDefault in interface HTMLComponentgetFeatureDefault in interface XMLComponentfeatureId - The feature identifier.public Object getPropertyDefault(String propertyId)
getPropertyDefault in interface HTMLComponentgetPropertyDefault in interface XMLComponentpropertyId - The property identifier.public String[] getRecognizedFeatures()
getRecognizedFeatures in interface XMLComponentpublic String[] getRecognizedProperties()
getRecognizedProperties in interface XMLComponentpublic void reset(XMLComponentManager manager) throws XMLConfigurationException
reset in interface XMLComponentmanager - The component manager.XMLConfigurationExceptionpublic void setFeature(String featureId, boolean state) throws XMLConfigurationException
setFeature in interface XMLComponentfeatureId - The feature identifier.state - The state of the feature.XMLConfigurationException - Thrown for configuration error.
In general, components should
only throw this exception if
it is really
a critical error.public void setProperty(String propertyId, Object value) throws XMLConfigurationException
setProperty in interface XMLComponentpropertyId - The property identifier.value - The value of the property.XMLConfigurationException - Thrown for configuration error.
In general, components should
only throw this exception if
it is really
a critical error.public void setDocumentHandler(XMLDocumentHandler handler)
setDocumentHandler in interface XMLDocumentSourcehandler - the new handlerpublic XMLDocumentHandler getDocumentHandler()
getDocumentHandler in interface XMLDocumentSourcepublic void startDocument(XMLLocator locator, String encoding, NamespaceContext nscontext, Augmentations augs) throws XNIException
startDocument in interface XMLDocumentHandlerlocator - The document locator, or null if the document
location cannot be reported during the parsing of
this document. However, it is strongly
recommended that a locator be supplied that can at
least report the system identifier of the document.encoding - The auto-detected IANA encoding name of the entity
stream. This value will be null in those situations
where the entity encoding is not auto-detected (e.g.
internal entities or a document entity that is parsed
from a java.io.Reader).nscontext - The namespace context in effect at the start of this
document. This object represents the current context.
Implementors of this class are responsible for
copying the namespace bindings from the the current
context (and its parent contexts) if that information
is important.augs - Additional information that may include infoset
augmentationsXNIException - Thrown by handler to signal an error.public void xmlDecl(String version, String encoding, String standalone, Augmentations augs) throws XNIException
xmlDecl in interface XMLDocumentHandlerversion - The XML version.encoding - The IANA encoding name of the document, or null if not
specified.standalone - The standalone value, or null if not specified.augs - Additional information that may include infoset
augmentationsXNIException - Thrown by handler to signal an error.public void doctypeDecl(String rootElementName, String publicId, String systemId, Augmentations augs) throws XNIException
doctypeDecl in interface XMLDocumentHandlerrootElementName - The name of the root element.publicId - The public identifier if an external DTD or null if the
external DTD is specified using SYSTEM.systemId - The system identifier if an external DTD, null otherwise.augs - Additional information that may include infoset
augmentationsXNIException - Thrown by handler to signal an error.public void endDocument(Augmentations augs) throws XNIException
endDocument in interface XMLDocumentHandleraugs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void comment(XMLString text, Augmentations augs) throws XNIException
comment in interface XMLDocumentHandlertext - The text in the comment.augs - Additional information that may include infoset augmentationsXNIException - Thrown by application to signal an error.public void processingInstruction(String target, XMLString data, Augmentations augs) throws XNIException
processingInstruction in interface XMLDocumentHandlertarget - The target.data - The data or null if none specified.augs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void startElement(QName elem, XMLAttributes attrs, Augmentations augs) throws XNIException
startElement in interface XMLDocumentHandlerelem - The name of the element.attrs - The element attributes.augs - Additional information that may include infoset
augmentationsXNIException - Thrown by handler to signal an error.public void emptyElement(QName element, XMLAttributes attrs, Augmentations augs) throws XNIException
emptyElement in interface XMLDocumentHandlerelement - The name of the element.attrs - The element attributes.augs - Additional information that may include infoset
augmentationsXNIException - Thrown by handler to signal an error.public void startGeneralEntity(String name, XMLResourceIdentifier id, String encoding, Augmentations augs) throws XNIException
startGeneralEntity in interface XMLDocumentHandlername - The name of the general entity.id - The resource identifier.encoding - The auto-detected IANA encoding name of the entity stream.
This value will be null in those situations where the
entity encoding is not auto-detected (e.g. internal
entities or a document entity that is parsed from a
java.io.Reader).augs - Additional information that may include infoset
augmentationsXNIException - Thrown by handler to signal an error.public void textDecl(String version, String encoding, Augmentations augs) throws XNIException
textDecl in interface XMLDocumentHandlerversion - The XML version, or null if not specified.encoding - The IANA encoding name of the entity.augs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void endGeneralEntity(String name, Augmentations augs) throws XNIException
endGeneralEntity in interface XMLDocumentHandlername - The name of the entity.augs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void startCDATA(Augmentations augs) throws XNIException
startCDATA in interface XMLDocumentHandleraugs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void endCDATA(Augmentations augs) throws XNIException
endCDATA in interface XMLDocumentHandleraugs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void characters(XMLString text, Augmentations augs) throws XNIException
characters in interface XMLDocumentHandlertext - The content.augs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void ignorableWhitespace(XMLString text, Augmentations augs) throws XNIException
ignorableWhitespace in interface XMLDocumentHandlertext - The ignorable whitespace.augs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void endElement(QName element, Augmentations augs) throws XNIException
endElement in interface XMLDocumentHandlerelement - The name of the element.augs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void setDocumentSource(XMLDocumentSource source)
setDocumentSource in interface XMLDocumentHandlersource - the new sourcepublic XMLDocumentSource getDocumentSource()
getDocumentSource in interface XMLDocumentHandlerprotected HTMLElements.Element getElement(QName elementName)
protected final void callStartElement(QName element, XMLAttributes attrs, Augmentations augs) throws XNIException
XNIExceptionprotected final void callEndElement(QName element, Augmentations augs) throws XNIException
XNIExceptionprotected final int getElementDepth(HTMLElements.Element element)
element - The element.protected int getParentDepth(HTMLElements.Element[] parents, short bounds)
parents - The parent elements.bounds - boundsprotected final XMLAttributes emptyAttributes()
protected final Augmentations synthesizedAugs()
protected static short getNamesValue(String value)
Copyright © 2023 Gargoyle Software Inc.. All rights reserved.