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
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(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcharacters(char[] ch, int start, int length)Writes the given characters to the given character stream.voidendElement(String uri, String localName, String qName)voidstartDocument()Writes the XML prefix.voidstartElement(String uri, String localName, String qName, Attributes atts)voidstartPrefixMapping(String prefix, String uri)-
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
-
-
-
-
Constructor Detail
-
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
public ToXMLContentHandler(String encoding)
-
ToXMLContentHandler
public ToXMLContentHandler()
-
-
Method Detail
-
startDocument
public void startDocument() throws SAXExceptionWrites the XML prefix.- Specified by:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classDefaultHandler- Throws:
SAXException
-
startPrefixMapping
public void startPrefixMapping(String prefix, String uri) throws SAXException
- Specified by:
startPrefixMappingin interfaceContentHandler- Overrides:
startPrefixMappingin classDefaultHandler- Throws:
SAXException
-
startElement
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException
- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classToTextContentHandler- Throws:
SAXException
-
endElement
public void endElement(String uri, String localName, String qName) throws SAXException
- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classToTextContentHandler- Throws:
SAXException
-
characters
public void characters(char[] ch, int start, int length) throws SAXExceptionDescription copied from class:ToTextContentHandlerWrites the given characters to the given character stream.- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classToTextContentHandler- Throws:
SAXException
-
-