uk.me.nxg.xoxa.esis
Class EsisHandler

java.lang.Object
  extended by uk.me.nxg.xoxa.esis.EsisHandler
All Implemented Interfaces:
ContentHandler

public class EsisHandler
extends Object
implements ContentHandler

Writes out a SAX stream in a format based on the sgmls ESIS output.


Constructor Summary
EsisHandler(EsisWriter writer, boolean normalize)
          Creates a SAX ContentHandler which receives a stream of SAX events and writes them out in the ESIS format.
EsisHandler(OutputStream out, boolean normalize)
           
 
Method Summary
 void characters(char[] ch, int start, int length)
          Writes - on the output, followed by the character string with \n, \r and \t escaped.
 void endDocument()
          Writes nothing on the output.
 void endElement(String uri, String localName, String qName)
          Indicates the end of an element.
 void endPrefixMapping(String prefix)
          Writes mprefix on the output
 void ignorableWhitespace(char[] ch, int start, int length)
          Displays ignorable whitespace.
 void processingInstruction(String target, String data)
          Writes ?target data on the output.
 void setDocumentLocator(Locator locator)
          Writes nothing to the output
 void skippedEntity(String name)
          Writes Xname on the output.
 void startDocument()
          Writes nothing on the output
 void startElement(String uri, String localName, String qName, Attributes atts)
          Writes an element-start indicator on the output.
 void startPrefixMapping(String prefix, String uri)
          Writes Mprefix uri on the output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EsisHandler

public EsisHandler(EsisWriter writer,
                   boolean normalize)
            throws IOException
Creates a SAX ContentHandler which receives a stream of SAX events and writes them out in the ESIS format. If the normalize argument is true, then the output is normalised in such a way that ‘equivalent’ XML documents will turn into the same normalized output; if the normalize argument is false, the output is a faithful and completely reversible representation of the input.

Parameters:
writer - the writer which is to receive the output
normalize - true if the output is to be normalized
Throws:
IOException - on IO errors

EsisHandler

public EsisHandler(OutputStream out,
                   boolean normalize)
            throws IOException
Throws:
IOException
Method Detail

setDocumentLocator

public void setDocumentLocator(Locator locator)
Writes nothing to the output

Specified by:
setDocumentLocator in interface ContentHandler

startDocument

public void startDocument()
                   throws SAXException
Writes nothing on the output

Specified by:
startDocument in interface ContentHandler
Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException
Writes nothing on the output. We don't do any schema or DTD validation, so can't output a 'C'

Specified by:
endDocument in interface ContentHandler
Throws:
SAXException

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws SAXException
Writes Mprefix uri on the output. We don't need to alphabetise these, for the sake of normalisation, because in the normalised output, we skip these.

Specified by:
startPrefixMapping in interface ContentHandler
Throws:
SAXException

endPrefixMapping

public void endPrefixMapping(String prefix)
                      throws SAXException
Writes mprefix on the output

Specified by:
endPrefixMapping in interface ContentHandler
Throws:
SAXException

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes atts)
                  throws SAXException
Writes an element-start indicator on the output.

If the element is not in a namespace, then write (<element-name>, and if it is [<namespace-uri> <element-name>.

This is preceded. by the attributes, (unconditionally) normalised into alphabetical order.

Specified by:
startElement in interface ContentHandler
Throws:
SAXException

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
                throws SAXException
Indicates the end of an element.

Specified by:
endElement in interface ContentHandler
Throws:
SAXException
See Also:
startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Writes - on the output, followed by the character string with \n, \r and \t escaped.

Specified by:
characters in interface ContentHandler
Throws:
SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws SAXException
Displays ignorable whitespace.

If we are normalizing, then simply discard this. If not, write = on the output, followed by the whitespace with \n, \r and \t escaped, and any other whitespace characters indicated by \unnn notation.

Specified by:
ignorableWhitespace in interface ContentHandler
Throws:
SAXException

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Writes ?target data on the output. If the target is "signature", however, then discard it.

Specified by:
processingInstruction in interface ContentHandler
Throws:
SAXException

skippedEntity

public void skippedEntity(String name)
                   throws SAXException
Writes Xname on the output. I confess I don't really understand what would generate this, but it doesn't matter right now.

Specified by:
skippedEntity in interface ContentHandler
Throws:
SAXException


Copyright © 2015. All rights reserved.