Class NormalizingSaxFilter

  • All Implemented Interfaces:
    org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.ext.LexicalHandler, org.xml.sax.XMLFilter, org.xml.sax.XMLReader

    public class NormalizingSaxFilter
    extends org.xml.sax.helpers.XMLFilterImpl
    implements org.xml.sax.ext.LexicalHandler
    SAX filter which
    1. orders attributes alphabetically
    2. strips ignorable whitespace (works even without schema/DTD: all characters in FileVault can be stripped because all elements are supposed to be empty)
    3. removes leading comments (prior to root element) due to bug in SAX2StAXStreamWriter in Java
    • Constructor Summary

      Constructors 
      Constructor Description
      NormalizingSaxFilter​(org.xml.sax.XMLReader parent)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void characters​(char[] ch, int start, int length)
      Filter out ignorable whitespace (for FileVault all elements are empty, i.e.
      void comment​(char[] ch, int start, int length)  
      void endCDATA()  
      void endDTD()
      Start Lexical Handler
      void endEntity​(java.lang.String name)  
      void parse​(org.xml.sax.InputSource input)  
      void setProperty​(java.lang.String name, java.lang.Object value)  
      void startCDATA()  
      void startDTD​(java.lang.String name, java.lang.String publicId, java.lang.String systemId)  
      void startElement​(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)  
      void startEntity​(java.lang.String name)  
      • Methods inherited from class org.xml.sax.helpers.XMLFilterImpl

        endDocument, endElement, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, ignorableWhitespace, notationDecl, parse, processingInstruction, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NormalizingSaxFilter

        public NormalizingSaxFilter​(org.xml.sax.XMLReader parent)
    • Method Detail

      • setProperty

        public void setProperty​(java.lang.String name,
                                java.lang.Object value)
                         throws org.xml.sax.SAXNotRecognizedException,
                                org.xml.sax.SAXNotSupportedException
        Specified by:
        setProperty in interface org.xml.sax.XMLReader
        Overrides:
        setProperty in class org.xml.sax.helpers.XMLFilterImpl
        Throws:
        org.xml.sax.SAXNotRecognizedException
        org.xml.sax.SAXNotSupportedException
      • parse

        public void parse​(org.xml.sax.InputSource input)
                   throws org.xml.sax.SAXException,
                          java.io.IOException
        Specified by:
        parse in interface org.xml.sax.XMLReader
        Overrides:
        parse in class org.xml.sax.helpers.XMLFilterImpl
        Throws:
        org.xml.sax.SAXException
        java.io.IOException
      • 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 org.xml.sax.helpers.XMLFilterImpl
        Throws:
        org.xml.sax.SAXException
      • characters

        public void characters​(char[] ch,
                               int start,
                               int length)
                        throws org.xml.sax.SAXException
        Filter out ignorable whitespace (for FileVault all elements are empty, i.e. every character is ignorable)
        Specified by:
        characters in interface org.xml.sax.ContentHandler
        Overrides:
        characters in class org.xml.sax.helpers.XMLFilterImpl
        Throws:
        org.xml.sax.SAXException
      • startDTD

        public void startDTD​(java.lang.String name,
                             java.lang.String publicId,
                             java.lang.String systemId)
                      throws org.xml.sax.SAXException
        Specified by:
        startDTD in interface org.xml.sax.ext.LexicalHandler
        Throws:
        org.xml.sax.SAXException
      • endDTD

        public void endDTD()
                    throws org.xml.sax.SAXException
        Start Lexical Handler
        Specified by:
        endDTD in interface org.xml.sax.ext.LexicalHandler
        Throws:
        org.xml.sax.SAXException
      • startEntity

        public void startEntity​(java.lang.String name)
                         throws org.xml.sax.SAXException
        Specified by:
        startEntity in interface org.xml.sax.ext.LexicalHandler
        Throws:
        org.xml.sax.SAXException
      • endEntity

        public void endEntity​(java.lang.String name)
                       throws org.xml.sax.SAXException
        Specified by:
        endEntity in interface org.xml.sax.ext.LexicalHandler
        Throws:
        org.xml.sax.SAXException
      • startCDATA

        public void startCDATA()
                        throws org.xml.sax.SAXException
        Specified by:
        startCDATA in interface org.xml.sax.ext.LexicalHandler
        Throws:
        org.xml.sax.SAXException
      • endCDATA

        public void endCDATA()
                      throws org.xml.sax.SAXException
        Specified by:
        endCDATA in interface org.xml.sax.ext.LexicalHandler
        Throws:
        org.xml.sax.SAXException
      • comment

        public void comment​(char[] ch,
                            int start,
                            int length)
                     throws org.xml.sax.SAXException
        Specified by:
        comment in interface org.xml.sax.ext.LexicalHandler
        Throws:
        org.xml.sax.SAXException