com.aliasi.xml
Class WellFormedFilter

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by com.aliasi.xml.SimpleElementHandler
          extended by com.aliasi.xml.SAXFilterHandler
              extended by com.aliasi.xml.ElementStackFilter
                  extended by com.aliasi.xml.WellFormedFilter
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

Deprecated. Use any old parser with appropriate properties.

@Deprecated
public class WellFormedFilter
extends ElementStackFilter

A WellFormedFilter performs basic checks that a document is well-formed XML and throws an exception as soon as an event is detected that would lead to an ill-formed document. Unless exceptions are thrown, events are otherwise passed to the contained handler. Checks performed include:

The WellFormedFilter is stateful. To use it again for a new document, call the method reset().

Warning: This filter only checks well-formedness, not validity with respect to a document type definition (DTD).

Warning: Not every way in which a document can be ill-formed is checked by this filter. Events ignored include:

Since:
LingPipe1.0
Version:
3.9.1
Author:
Bob Carpenter

Field Summary
 
Fields inherited from class com.aliasi.xml.SAXFilterHandler
mHandler
 
Fields inherited from class com.aliasi.xml.SimpleElementHandler
CDATA_ATTS_TYPE, EMPTY_ATTS, NO_OP_DEFAULT_HANDLER
 
Constructor Summary
WellFormedFilter()
          Deprecated. Construct a well-formedness filter with no specified handler.
WellFormedFilter(DefaultHandler handler)
          Deprecated. Construct a well-formedness filter and sets the contained handler to the specified value.
 
Method Summary
 void characters(char[] cs, int start, int length)
          Deprecated. Tests that the specified slice of characters is a well-formed sequence of unicode characters, and delegates the call to the contained handler.
 void endDocument()
          Deprecated. Tests that the document has been opened and contains a single top-level element that is closed, and delegates the call to the contained handler.
 void endElement(String namespaceURI, String localName, String qName)
          Deprecated. Tests that this end element has a matching start element, and delegates the call to the contained handler.
 void processingInstruction(String target, String data)
          Deprecated. Tests that the specified target and data are well-formed unicode sequences and delegates to the contained handler.
 void reset()
          Deprecated. Resets the state of the filter to accept a new document.
 void startDocument()
          Deprecated. Tests that the document has not already been started, and delegates the call to the contained handler.
 void startElement(String namespaceURI, String localName, String qName, Attributes atts)
          Deprecated. Tests that the start element has a well-formed qualified name, and that all attribute qualified names and values are well-formed, then delegates to the contained handler.
 
Methods inherited from class com.aliasi.xml.ElementStackFilter
currentAttributes, currentElement, getAttributesStack, getElementStack, noElement
 
Methods inherited from class com.aliasi.xml.SAXFilterHandler
endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, resolveEntity, setDocumentLocator, setHandler, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class com.aliasi.xml.SimpleElementHandler
addSimpleAttribute, characters, characters, characters, characters, createAttributes, createAttributes, createAttributes, createAttributes, createAttributes, createAttributes, endSimpleElement, endSimpleElement, startEndSimpleElement, startEndSimpleElement, startSimpleElement, startSimpleElement, startSimpleElement, startSimpleElement, startSimpleElement, startSimpleElement, startSimpleElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WellFormedFilter

public WellFormedFilter(DefaultHandler handler)
Deprecated. 
Construct a well-formedness filter and sets the contained handler to the specified value. This handler will be passed all events received by the well-formedness filter that do not throw exceptions due to not being well-formed.

Parameters:
handler - Handler to which filtered events are passed.

WellFormedFilter

public WellFormedFilter()
Deprecated. 
Construct a well-formedness filter with no specified handler. Until a handler is set with SAXFilterHandler.setHandler(DefaultHandler), well-formedness checks will be carried out and throw exceptions, but the events will otherwise be ignored.

Method Detail

reset

public final void reset()
Deprecated. 
Resets the state of the filter to accept a new document. Use this method in between runs to re-use this filter.


processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Deprecated. 
Tests that the specified target and data are well-formed unicode sequences and delegates to the contained handler. Throws an exception, if not well formed.

Specified by:
processingInstruction in interface ContentHandler
Overrides:
processingInstruction in class SAXFilterHandler
Parameters:
target - Target of the instruction.
data - Value of the instruction, or null.
Throws:
SAXException - If this call leads to an ill-formed document.

startDocument

public void startDocument()
                   throws SAXException
Deprecated. 
Tests that the document has not already been started, and delegates the call to the contained handler. If the document was previously started, throws an exception.

Specified by:
startDocument in interface ContentHandler
Overrides:
startDocument in class ElementStackFilter
Throws:
SAXException - If this call leads to an ill-formed document.

endDocument

public void endDocument()
                 throws SAXException
Deprecated. 
Tests that the document has been opened and contains a single top-level element that is closed, and delegates the call to the contained handler. Otherwise, throws an exception if the end is premature.

Specified by:
endDocument in interface ContentHandler
Overrides:
endDocument in class SAXFilterHandler
Throws:
SAXException - If this call leads to an ill-formed document.

startElement

public void startElement(String namespaceURI,
                         String localName,
                         String qName,
                         Attributes atts)
                  throws SAXException
Deprecated. 
Tests that the start element has a well-formed qualified name, and that all attribute qualified names and values are well-formed, then delegates to the contained handler. Throws an exception if the document has not been started and not ended, or if this element would start a second top-level element.

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class ElementStackFilter
Parameters:
namespaceURI - The URI of the namespace for this element.
localName - The local name (without prefix) for this element.
qName - The qualified name (with prefix, if any) for this element.
atts - The attributes for this element.
Throws:
SAXException - If this call leads to an ill-formed document.

endElement

public void endElement(String namespaceURI,
                       String localName,
                       String qName)
                throws SAXException
Deprecated. 
Tests that this end element has a matching start element, and delegates the call to the contained handler. If there is no matching start element, an exception is raised.

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class ElementStackFilter
Parameters:
namespaceURI - The URI of the namespace for this element.
localName - The local name (without prefix) for this element.
qName - The qualified name (with prefix, if any) for this element.
Throws:
SAXException - If this call leads to an ill-formed document.

characters

public void characters(char[] cs,
                       int start,
                       int length)
                throws SAXException
Deprecated. 
Tests that the specified slice of characters is a well-formed sequence of unicode characters, and delegates the call to the contained handler.

Specified by:
characters in interface ContentHandler
Overrides:
characters in class SAXFilterHandler
Parameters:
cs - Character array from which to draw characters.
start - Index of first character to print.
length - Number of characters to print.
Throws:
SAXException - If this call leads to an ill-formed document.