Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## gnu.xml.pipeline
Class WellFormednessFilter

    java.lang.Object
      |
      +--gnu.xml.pipeline.EventFilter
            |
            +--gnu.xml.pipeline.WellFormednessFilter

All Implemented Interfaces:
  ContentHandler, DeclHandler, DTDHandler, EventConsumer, LexicalHandler

public final class WellFormednessFilter
extends EventFilter

This filter reports fatal exceptions in the case of event streams that are not well formed. The rules currently tested include:

- setDocumentLocator ... may be called only before startDocument
- startDocument/endDocument ... must be paired, and all other calls (except setDocumentLocator) must be nested within these.
- startElement/endElement ... must be correctly paired, and may never appear within CDATA sections.
- comment ... can't contain "--"
- character data ... can't contain "]]>"
- whitespace ... can't contain CR
- whitespace and character data must be within an element
- processing instruction ... can't contain "?>" or CR
- startCDATA/endCDATA ... must be correctly paired.

Other checks for event stream correctness may be provided in the future. For example, insisting that entity boundaries nest correctly, namespace scopes nest correctly, namespace values never contain relative URIs, attributes don't have "<" characters; and more.

Version:
  $Date: 2001/11/09 22:53:17 $
Author:
  David Brownell

Fields inherited from class gnu.xml.pipeline.EventFilter
`DECL_HANDLER, FEATURE_URI, LEXICAL_HANDLER, PROPERTY_URI`

Constructor Summary
`WellFormednessFilter()` Swallows all events after performing well formedness checks.
`WellFormednessFilter(EventConsumer consumer)` Passes events through to the specified consumer, after first processing them.

Method Summary
`void` | `characters(char[] ch, int start, int length)` SAX2: passes this callback to the next consumer, if any
`void` | `comment(char[] ch, int start, int length)` SAX2: passes this callback to the next consumer, if any
`void` | `endCDATA()` SAX2: passes this callback to the next consumer, if any
`void` | `endDocument()` SAX2: passes this callback to the next consumer, if any
`void` | `endDTD()` SAX2: passes this callback to the next consumer, if any
`void` | `endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)` SAX2: passes this callback to the next consumer, if any
`void` | `ignorableWhitespace(char[] ch, int start, int length)` SAX2: passes this callback to the next consumer, if any
`void` | `notationDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)` SAX1: passes this callback to the next consumer, if any
`void` | `processingInstruction(java.lang.String target, java.lang.String data)` SAX2: passes this callback to the next consumer, if any
`void` | `reset()` Resets state as if any preceding event stream was well formed.
`void` | `setDocumentLocator(Locator locator)` Throws an exception when called after startDocument.
`void` | `startCDATA()` SAX2: passes this callback to the next consumer, if any
`void` | `startDocument()` SAX2: passes this callback to the next consumer, if any
`void` | `startDTD(java.lang.String root, java.lang.String publicId, java.lang.String systemId)` SAX2: passes this callback to the next consumer, if any
`void` | `startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, Attributes atts)` SAX2: passes this callback to the next consumer, if any
`void` | `unparsedEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String notationName)` SAX1: passes this callback to the next consumer, if any

Methods inherited from class gnu.xml.pipeline.EventFilter
`attributeDecl, bind, chainTo, elementDecl, endEntity, endPrefixMapping, externalEntityDecl, getContentHandler, getDocumentLocator, getDTDHandler, getErrorHandler, getNext, getProperty, internalEntityDecl, setContentHandler, setDTDHandler, setErrorHandler, setProperty, skippedEntity, startEntity, startPrefixMapping`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### WellFormednessFilter

    public WellFormednessFilter()

  Swallows all events after performing well formedness checks.

### WellFormednessFilter

    public WellFormednessFilter(EventConsumer consumer)

  Passes events through to the specified consumer, after first processing them.

Method Detail

### reset

    public void reset()

  Resets state as if any preceding event stream was well formed. Particularly useful if it ended through some sort of error, and the endDocument call wasn't made.

### setDocumentLocator

    public void setDocumentLocator(Locator locator)

  Throws an exception when called after startDocument.
  Overrides:
    `setDocumentLocator` in class `EventFilter`
  Parameters:
    `locator` - the locator, to be used in error reporting or relative URI resolution.
  Throws:
    `IllegalStateException` - when called after the document has already been started

### startDocument

    public void startDocument()
                       throws SAXException

  Description copied from class: `EventFilter`
  SAX2: passes this callback to the next consumer, if any
  Overrides:
    `startDocument` in class `EventFilter`
  Following copied from interface: `org.xml.sax.ContentHandler`
  Throws:
    `SAXException` - Any SAX exception, possibly wrapping another exception.
  See Also:
    `ContentHandler.endDocument()`

### startElement

    public void startElement(java.lang.String uri,
                             java.lang.String localName,
                             java.lang.String qName,
                             Attributes atts)
                      throws SAXException

  Description copied from class: `EventFilter`
  SAX2: passes this callback to the next consumer, if any
  Overrides:
    `startElement` in class `EventFilter`
  Following copied from interface: `org.xml.sax.ContentHandler`
  Parameters:
    `uri` - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
    `localName` - The local name (without prefix), or the empty string if Namespace processing is not being performed.
    `qName` - The qualified name (with prefix), or the empty string if qualified names are not available.
    `atts` - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
  Throws:
    `SAXException` - Any SAX exception, possibly wrapping another exception.
  See Also:
    `ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)`, `Attributes`

### endElement

    public void endElement(java.lang.String uri,
                           java.lang.String localName,
                           java.lang.String qName)
                    throws SAXException

  Description copied from class: `EventFilter`
  SAX2: passes this callback to the next consumer, if any
  Overrides:
    `endElement` in class `EventFilter`
  Following copied from interface: `org.xml.sax.ContentHandler`
  Parameters:
    `uri` - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
    `localName` - The local name (without prefix), or the empty string if Namespace processing is not being performed.
    `qName` - The qualified XML 1.0 name (with prefix), or the empty string if qualified names are not available.
  Throws:
    `SAXException` - Any SAX exception, possibly wrapping another exception.

### endDocument

    public void endDocument()
                     throws SAXException

  Description copied from class: `EventFilter`
  SAX2: passes this callback to the next consumer, if any
  Overrides:
    `endDocument` in class `EventFilter`
  Following copied from interface: `org.xml.sax.ContentHandler`
  Throws:
    `SAXException` - Any SAX exception, possibly wrapping another exception.
  See Also:
    `ContentHandler.startDocument()`

### startDTD

    public void startDTD(java.lang.String root,
                         java.lang.String publicId,
                         java.lang.String systemId)
                  throws SAXException

  Description copied from class: `EventFilter`
  SAX2: passes this callback to the next consumer, if any
  Overrides:
    `startDTD` in class `EventFilter`
  Following copied from interface: `org.xml.sax.ext.LexicalHandler`
  Parameters:
    `name` - The document type name.
    `publicId` - The declared public identifier for the external DTD subset, or null if none was declared.
    `systemId` - The declared system identifier for the external DTD subset, or null if none was declared. (Note that this is not resolved against the document base URI.)
  Throws:
    `SAXException` - The application may raise an exception.
  See Also:
    `LexicalHandler.endDTD()`, `LexicalHandler.startEntity(java.lang.String)`

### notationDecl

    public void notationDecl(java.lang.String name,
                             java.lang.String publicId,
                             java.lang.String systemId)
                      throws SAXException

  Description copied from class: `EventFilter`
  SAX1: passes this callback to the next consumer, if any
  Overrides:
    `notationDecl` in class `EventFilter`
  Following copied from interface: `org.xml.sax.DTDHandler`
  Parameters:
    `name` - The notation name.
    `publicId` - The notation's public identifier, or null if none was given.
    `systemId` - The notation's system identifier, or null if none was given.
  Throws:
    `SAXException` - Any SAX exception, possibly wrapping another exception.
  See Also:
    `DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)`, `Attributes`

### unparsedEntityDecl

    public void unparsedEntityDecl(java.lang.String name,
                                   java.lang.String publicId,
                                   java.lang.String systemId,
                                   java.lang.String notationName)
                            throws SAXException

  Description copied from class: `EventFilter`
  SAX1: passes this callback to the next consumer, if any
  Overrides:
    `unparsedEntityDecl` in class `EventFilter`
  Following copied from interface: `org.xml.sax.DTDHandler`
  Parameters:
    `name` - The unparsed entity's name.
    `publicId` - The entity's public identifier, or null if none was given.
    `systemId` - The entity's system identifier.
    `notationName` - The name of the associated notation.
  Throws:
    `SAXException` - Any SAX exception, possibly wrapping another exception.
  See Also:
    `DTDHandler.notationDecl(java.lang.String, java.lang.String, java.lang.String)`, `Attributes`

### endDTD

    public void endDTD()
                throws SAXException

  Description copied from class: `EventFilter`
  SAX2: passes this callback to the next consumer, if any
  Overrides:
    `endDTD` in class `EventFilter`
  Following copied from interface: `org.xml.sax.ext.LexicalHandler`
  Throws:
    `SAXException` - The application may raise an exception.
  See Also:
    `LexicalHandler.startDTD(java.lang.String, java.lang.String, java.lang.String)`

### characters

    public void characters(char[] ch,
                           int start,
                           int length)
                    throws SAXException

  Description copied from class: `EventFilter`
  SAX2: passes this callback to the next consumer, if any
  Overrides:
    `characters` in class `EventFilter`
  Following copied from interface: `org.xml.sax.ContentHandler`
  Parameters:
    `ch` - The characters from the XML document.
    `start` - The start position in the array.
    `length` - The number of characters to read from the array.
  Throws:
    `SAXException` - Any SAX exception, possibly wrapping another exception.
  See Also:
    `ContentHandler.ignorableWhitespace(char[], int, int)`, `Locator`

### ignorableWhitespace

    public void ignorableWhitespace(char[] ch,
                                    int start,
                                    int length)
                             throws SAXException

  Description copied from class: `EventFilter`
  SAX2: passes this callback to the next consumer, if any
  Overrides:
    `ignorableWhitespace` in class `EventFilter`
  Following copied from interface: `org.xml.sax.ContentHandler`
  Parameters:
    `ch` - The characters from the XML document.
    `start` - The start position in the array.
    `length` - The number of characters to read from the array.
  Throws:
    `SAXException` - Any SAX exception, possibly wrapping another exception.
  See Also:
    `ContentHandler.characters(char[], int, int)`

### processingInstruction

    public void processingInstruction(java.lang.String target,
                                      java.lang.String data)
                               throws SAXException

  Description copied from class: `EventFilter`
  SAX2: passes this callback to the next consumer, if any
  Overrides:
    `processingInstruction` in class `EventFilter`
  Following copied from interface: `org.xml.sax.ContentHandler`
  Parameters:
    `target` - The processing instruction target.
    `data` - The processing instruction data, or null if none was supplied. The data does not include any whitespace separating it from the target.
  Throws:
    `SAXException` - Any SAX exception, possibly wrapping another exception.

### comment

    public void comment(char[] ch,
                        int start,
                        int length)
                 throws SAXException

  Description copied from class: `EventFilter`
  SAX2: passes this callback to the next consumer, if any
  Overrides:
    `comment` in class `EventFilter`
  Following copied from interface: `org.xml.sax.ext.LexicalHandler`
  Parameters:
    `ch` - An array holding the characters in the comment.
    `start` - The starting position in the array.
    `length` - The number of characters to use from the array.
  Throws:
    `SAXException` - The application may raise an exception.

### startCDATA

    public void startCDATA()
                    throws SAXException

  Description copied from class: `EventFilter`
  SAX2: passes this callback to the next consumer, if any
  Overrides:
    `startCDATA` in class `EventFilter`
  Following copied from interface: `org.xml.sax.ext.LexicalHandler`
  Throws:
    `SAXException` - The application may raise an exception.
  See Also:
    `LexicalHandler.endCDATA()`

### endCDATA

    public void endCDATA()
                  throws SAXException

  Description copied from class: `EventFilter`
  SAX2: passes this callback to the next consumer, if any
  Overrides:
    `endCDATA` in class `EventFilter`
  Following copied from interface: `org.xml.sax.ext.LexicalHandler`
  Throws:
    `SAXException` - The application may raise an exception.
  See Also:
    `LexicalHandler.startCDATA()`

Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Source code is under GPL (with library exception) in the JAXP project at http://www.gnu.org/software/classpathx/jaxp
This documentation was derived from that source code on 2001-11-20.