Class 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.xml.sax.helpers.DefaultHandler

        endPrefixMapping, error, fatalError, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, unparsedEntityDecl, warning
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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 stream
        encoding - 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 interface org.xml.sax.ContentHandler
        Overrides:
        startDocument in class org.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 interface org.xml.sax.ContentHandler
        Overrides:
        startPrefixMapping in class org.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 interface org.xml.sax.ContentHandler
        Overrides:
        startElement in class ToTextContentHandler
        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 interface org.xml.sax.ContentHandler
        Overrides:
        endElement in class ToTextContentHandler
        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 interface org.xml.sax.ContentHandler
        Overrides:
        characters in class ToTextContentHandler
        Throws:
        org.xml.sax.SAXException