Package org.apache.tika.sax
Class ToXMLContentHandler
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.apache.tika.sax.ToTextContentHandler
org.apache.tika.sax.ToXMLContentHandler
- All Implemented Interfaces:
ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
- Direct Known Subclasses:
ToHTMLContentHandler
SAX event handler that serializes the XML document to a character stream.
The incoming SAX events are expected to be well-formed (properly nested,
etc.) and to explicitly include namespace declaration attributes and
corresponding namespace prefixes in element and attribute names.
- Since:
- Apache Tika 0.10
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
-
Constructor Summary
ConstructorsConstructorDescriptionToXMLContentHandler
(OutputStream stream, String encoding) Creates an XML serializer that writes to the given byte stream using the given character encoding.ToXMLContentHandler
(String encoding) -
Method Summary
Modifier and TypeMethodDescriptionvoid
characters
(char[] ch, int start, int length) Writes the given characters to the given character stream.void
endElement
(String uri, String localName, String qName) void
Writes the XML prefix.void
startElement
(String uri, String localName, String qName, Attributes atts) void
startPrefixMapping
(String prefix, String uri) protected void
write
(char ch) Writes the given character as-is.protected void
Writes the given string of character as-is.Methods inherited from class org.apache.tika.sax.ToTextContentHandler
endDocument, ignorableWhitespace, toString
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, error, fatalError, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, unparsedEntityDecl, warning
-
Field Details
-
namespaces
-
inStartElement
protected boolean inStartElement
-
-
Constructor Details
-
ToXMLContentHandler
public ToXMLContentHandler(OutputStream stream, String encoding) throws UnsupportedEncodingException Creates an XML serializer that writes to the given byte stream using the given character encoding.- Parameters:
stream
- output streamencoding
- output encoding- Throws:
UnsupportedEncodingException
- if the encoding is unsupported
-
ToXMLContentHandler
-
ToXMLContentHandler
public ToXMLContentHandler()
-
-
Method Details
-
startDocument
Writes the XML prefix.- Specified by:
startDocument
in interfaceContentHandler
- Overrides:
startDocument
in classDefaultHandler
- Throws:
SAXException
-
startPrefixMapping
- Specified by:
startPrefixMapping
in interfaceContentHandler
- Overrides:
startPrefixMapping
in classDefaultHandler
- Throws:
SAXException
-
startElement
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException - Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classToTextContentHandler
- Throws:
SAXException
-
endElement
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classToTextContentHandler
- Throws:
SAXException
-
characters
Description copied from class:ToTextContentHandler
Writes the given characters to the given character stream.- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classToTextContentHandler
- Throws:
SAXException
-
write
Writes the given character as-is.- Parameters:
ch
- character to be written- Throws:
SAXException
- if the character could not be written
-
write
Writes the given string of character as-is.- Parameters:
string
- string of character to be written- Throws:
SAXException
- if the character string could not be written
-