org.inria.ns.reflex.xml.sax
Class SAXSafeDocument

java.lang.Object
  extended by org.xml.sax.helpers.XMLFilterImpl
      extended by org.inria.ns.reflex.xml.sax.SAXFilter
          extended by org.inria.ns.reflex.xml.sax.SAXSafeDocument
All Implemented Interfaces:
Localizable, ContentHandler, DTDHandler, EntityResolver, ErrorHandler, DeclHandler, LexicalHandler, XMLFilter, XMLReader
Direct Known Subclasses:
SAXDocument, SAXSafeParser, XMLBuilder.SAXSplitter, XSLTFilter

public class SAXSafeDocument
extends SAXFilter

A SAX document that takes care of whether DTD stuff have to be forwarded or not.

***

This class is used to fix buggy XSLT processors :

***

Author:
Philippe Poulard

Constructor Summary
SAXSafeDocument(ParserConfiguration parserConfiguration)
          Create a filter that ensure that "document events" are well-balanced.
 
Method Summary
 void characters(char[] ch, int start, int length)
          Forward a character event.
 void endDTD()
          Forward an end DTD, except if it has been blocked.
 void startDTD(String name, String publicId, String systemId)
          Forward a start DTD, except if it has been blocked.
 void startElement(String uri, String localName, String qName, Attributes atts)
          Forward a start element.
 
Methods inherited from class org.inria.ns.reflex.xml.sax.SAXFilter
attributeDecl, comment, elementDecl, endCDATA, endDocument, endEntity, externalEntityDecl, getDeclHandler, getLexicalHandler, getLocation, getProperty, internalEntityDecl, isLocalizable, parse, setDeclHandler, setLexicalHandler, setLocation, setProperty, startCDATA, startDocument, startEntity
 
Methods inherited from class org.xml.sax.helpers.XMLFilterImpl
endElement, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, ignorableWhitespace, notationDecl, parse, processingInstruction, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.ContentHandler
endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startPrefixMapping
 
Methods inherited from interface org.xml.sax.DTDHandler
notationDecl, unparsedEntityDecl
 

Constructor Detail

SAXSafeDocument

public SAXSafeDocument(ParserConfiguration parserConfiguration)
Create a filter that ensure that "document events" are well-balanced.

Parameters:
configuration - The non-null configuration expected for the parser, if one is needed.
Method Detail

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes atts)
                  throws SAXException
Forward a start element.

When this event is encountered, DTD start and end events will be blocked.

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class XMLFilterImpl
Parameters:
uri - The URI.
localName - The local name.
qName - The qualified name.
atts - The attributes.
Throws:
SAXException
See Also:
XMLFilterImpl.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
Forward a character event.

When this event is encountered, DTD start and end events will be blocked if one of the characters is not a whitespace.

Specified by:
characters in interface ContentHandler
Overrides:
characters in class XMLFilterImpl
Parameters:
ch - The arry of characters to forward.
start - Where the characters start.
length - The length.
Throws:
SAXException
See Also:
XMLFilterImpl.characters(char[], int, int)

startDTD

public void startDTD(String name,
                     String publicId,
                     String systemId)
              throws SAXException
Forward a start DTD, except if it has been blocked.

Specified by:
startDTD in interface LexicalHandler
Overrides:
startDTD in class SAXFilter
Parameters:
name - The name of the DTD.
publicId - Its public identifier.
systemId - Its system identifier.
Throws:
SAXException
See Also:
SAXFilter.startDTD(java.lang.String, java.lang.String, java.lang.String)

endDTD

public void endDTD()
            throws SAXException
Forward an end DTD, except if it has been blocked.

Specified by:
endDTD in interface LexicalHandler
Overrides:
endDTD in class SAXFilter
Throws:
SAXException
See Also:
SAXFilter.endDTD()