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:
org.xml.sax.ContentHandler
,org.xml.sax.DTDHandler
,org.xml.sax.EntityResolver
,org.xml.sax.ErrorHandler
- Direct Known Subclasses:
ToHTMLContentHandler
public class ToXMLContentHandler extends ToTextContentHandler
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
-
-
Constructor Summary
Constructors Constructor Description ToXMLContentHandler()
ToXMLContentHandler(java.io.OutputStream stream, java.lang.String encoding)
Creates an XML serializer that writes to the given byte stream using the given character encoding.ToXMLContentHandler(java.lang.String encoding)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
characters(char[] ch, int start, int length)
Writes the given characters to the given character stream.void
endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
void
startDocument()
Writes the XML prefix.void
startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
void
startPrefixMapping(java.lang.String prefix, java.lang.String uri)
-
Methods inherited from class org.apache.tika.sax.ToTextContentHandler
endDocument, ignorableWhitespace, toString
-
-
-
-
Constructor Detail
-
ToXMLContentHandler
public ToXMLContentHandler(java.io.OutputStream stream, java.lang.String encoding) throws java.io.UnsupportedEncodingException
Creates an XML serializer that writes to the given byte stream using the given character encoding.- Parameters:
stream
- output streamencoding
- output encoding- Throws:
java.io.UnsupportedEncodingException
- if the encoding is unsupported
-
ToXMLContentHandler
public ToXMLContentHandler(java.lang.String encoding)
-
ToXMLContentHandler
public ToXMLContentHandler()
-
-
Method Detail
-
startDocument
public void startDocument() throws org.xml.sax.SAXException
Writes the XML prefix.- Specified by:
startDocument
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startDocument
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
startPrefixMapping
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws org.xml.sax.SAXException
- Specified by:
startPrefixMapping
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startPrefixMapping
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
startElement
public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts) throws org.xml.sax.SAXException
- Specified by:
startElement
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startElement
in classToTextContentHandler
- Throws:
org.xml.sax.SAXException
-
endElement
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException
- Specified by:
endElement
in interfaceorg.xml.sax.ContentHandler
- Overrides:
endElement
in classToTextContentHandler
- Throws:
org.xml.sax.SAXException
-
characters
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException
Description copied from class:ToTextContentHandler
Writes the given characters to the given character stream.- Specified by:
characters
in interfaceorg.xml.sax.ContentHandler
- Overrides:
characters
in classToTextContentHandler
- Throws:
org.xml.sax.SAXException
-
-