Class StrictXHTMLValidator
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.apache.tika.sax.ContentHandlerDecorator
org.apache.tika.sax.StrictXHTMLValidator
- All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler
A SAX content handler decorator that enforces XHTML well-formedness on the
incoming event stream. Any parser that emits an event sequence that would
produce malformed XHTML triggers a
SAXException synchronously — the
stack trace points at the parser code that made the offending call, instead
of surfacing later as a parse error on the serialized output.
Invariants enforced:
startDocumentis called at most once.- No SAX events arrive after
endDocument. - Every
endElementmatches the topmost openstartElement(no cross-nesting like<a><b></a></b>). - The element stack is empty when
endDocumentfires (no unclosed elements left dangling by an exception path). - Within a single
startElement, no two attributes share the same (namespaceURI, localName) pair (the bug class that produces<div class="x" class="y">).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(char[] ch, int start, int length) voidvoidendElement(String uri, String localName, String qName) voidendPrefixMapping(String prefix) voidignorableWhitespace(char[] ch, int start, int length) voidprocessingInstruction(String target, String data) voidskippedEntity(String name) voidvoidstartElement(String uri, String localName, String qName, Attributes attrs) voidstartPrefixMapping(String prefix, String uri) Methods inherited from class ContentHandlerDecorator
error, fatalError, handleException, setContentHandler, setDocumentLocator, toString, warningMethods inherited from class DefaultHandler
notationDecl, resolveEntity, unparsedEntityDeclMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ContentHandler
declaration
-
Constructor Details
-
StrictXHTMLValidator
-
-
Method Details
-
startDocument
- Specified by:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classContentHandlerDecorator- Throws:
SAXException
-
endDocument
- Specified by:
endDocumentin interfaceContentHandler- Overrides:
endDocumentin classContentHandlerDecorator- Throws:
SAXException
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException - Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classContentHandlerDecorator- Throws:
SAXException
-
endElement
- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classContentHandlerDecorator- Throws:
SAXException
-
characters
- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classContentHandlerDecorator- Throws:
SAXException
-
ignorableWhitespace
- Specified by:
ignorableWhitespacein interfaceContentHandler- Overrides:
ignorableWhitespacein classContentHandlerDecorator- Throws:
SAXException
-
processingInstruction
- Specified by:
processingInstructionin interfaceContentHandler- Overrides:
processingInstructionin classContentHandlerDecorator- Throws:
SAXException
-
startPrefixMapping
- Specified by:
startPrefixMappingin interfaceContentHandler- Overrides:
startPrefixMappingin classContentHandlerDecorator- Throws:
SAXException
-
endPrefixMapping
- Specified by:
endPrefixMappingin interfaceContentHandler- Overrides:
endPrefixMappingin classContentHandlerDecorator- Throws:
SAXException
-
skippedEntity
- Specified by:
skippedEntityin interfaceContentHandler- Overrides:
skippedEntityin classContentHandlerDecorator- Throws:
SAXException
-