Class DAXValidator

  • All Implemented Interfaces:
    org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

    public class DAXValidator
    extends org.xml.sax.helpers.DefaultHandler
    This class reads to validate a DAX document. It requires at least Xerces-J 2.10.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int m_errors
      Counts the number of errors.
      protected int m_fatals
      Counts the number of fatal errors.
      private org.xml.sax.Locator m_location
      Keep the location within the document.
      private org.xml.sax.XMLReader m_reader
      Holds the instance of a XMLReader class.
      private java.lang.String m_schemafile
      what is the name of the schema file in the filename hint?
      protected boolean m_verbose
      How verbose should we be?
      protected int m_warnings
      Counts the number of warnings.
      static java.lang.String SCHEMA_NAMESPACE
      URI namespace for DAX schema.
      protected static java.lang.String vendorParserClass
      Default parser is the Xerces parser.
    • Constructor Summary

      Constructors 
      Constructor Description
      DAXValidator​(boolean verbose)
      default c'tor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void characters​(char[] ch, int start, int length)  
      void endDocument()  
      void endElement​(java.lang.String nsURI, java.lang.String localName, java.lang.String qName)  
      void error​(org.xml.sax.SAXParseException ex)  
      void fatalError​(org.xml.sax.SAXParseException ex)  
      private java.lang.String full_where()  
      void ignorableWhitespace​(char[] ch, int start, int length)  
      static void main​(java.lang.String[] args)  
      void parse​(java.lang.String filename)  
      private boolean prop​(java.lang.String uri, java.lang.Object value)
      Sets a SAX property while capturing failed features right here.
      private boolean set​(java.lang.String uri, boolean flag)
      Sets a feature while capturing failed features right here.
      void setDocumentLocator​(org.xml.sax.Locator locator)  
      void startDocument()  
      void startElement​(java.lang.String nsURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attrs)  
      boolean statistics()
      Show how many warnings, errors and fatals were shown.
      void warning​(org.xml.sax.SAXParseException ex)  
      private java.lang.String where()  
      • Methods inherited from class org.xml.sax.helpers.DefaultHandler

        endPrefixMapping, notationDecl, processingInstruction, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDecl
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • vendorParserClass

        protected static final java.lang.String vendorParserClass
        Default parser is the Xerces parser.
        See Also:
        Constant Field Values
      • SCHEMA_NAMESPACE

        public static final java.lang.String SCHEMA_NAMESPACE
        URI namespace for DAX schema.
        See Also:
        Constant Field Values
      • m_schemafile

        private java.lang.String m_schemafile
        what is the name of the schema file in the filename hint?
      • m_reader

        private org.xml.sax.XMLReader m_reader
        Holds the instance of a XMLReader class.
      • m_location

        private org.xml.sax.Locator m_location
        Keep the location within the document.
      • m_verbose

        protected boolean m_verbose
        How verbose should we be?
      • m_warnings

        protected int m_warnings
        Counts the number of warnings.
      • m_errors

        protected int m_errors
        Counts the number of errors.
      • m_fatals

        protected int m_fatals
        Counts the number of fatal errors.
    • Constructor Detail

      • DAXValidator

        public DAXValidator​(boolean verbose)
                     throws java.lang.Exception
        default c'tor
        Throws:
        java.lang.Exception
    • Method Detail

      • set

        private boolean set​(java.lang.String uri,
                            boolean flag)
        Sets a feature while capturing failed features right here.
        Parameters:
        uri - is the feature's URI to modify
        flag - is the new value to set.
        Returns:
        true, if the feature could be set, false for an exception
      • prop

        private boolean prop​(java.lang.String uri,
                             java.lang.Object value)
        Sets a SAX property while capturing failed features right here.
        Parameters:
        uri - is the property's URI to modify
        value - is the new value to set.
        Returns:
        true, if the feature could be set, false for an exception
      • warning

        public void warning​(org.xml.sax.SAXParseException ex)
                     throws org.xml.sax.SAXException
        Specified by:
        warning in interface org.xml.sax.ErrorHandler
        Overrides:
        warning in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • error

        public void error​(org.xml.sax.SAXParseException ex)
                   throws org.xml.sax.SAXException
        Specified by:
        error in interface org.xml.sax.ErrorHandler
        Overrides:
        error in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • fatalError

        public void fatalError​(org.xml.sax.SAXParseException ex)
                        throws org.xml.sax.SAXException
        Specified by:
        fatalError in interface org.xml.sax.ErrorHandler
        Overrides:
        fatalError in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • setDocumentLocator

        public void setDocumentLocator​(org.xml.sax.Locator locator)
        Specified by:
        setDocumentLocator in interface org.xml.sax.ContentHandler
        Overrides:
        setDocumentLocator in class org.xml.sax.helpers.DefaultHandler
      • full_where

        private java.lang.String full_where()
      • where

        private java.lang.String where()
      • startDocument

        public void startDocument()
                           throws org.xml.sax.SAXException
        Specified by:
        startDocument in interface org.xml.sax.ContentHandler
        Overrides:
        startDocument in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • endDocument

        public void endDocument()
        Specified by:
        endDocument in interface org.xml.sax.ContentHandler
        Overrides:
        endDocument in class org.xml.sax.helpers.DefaultHandler
      • startElement

        public void startElement​(java.lang.String nsURI,
                                 java.lang.String localName,
                                 java.lang.String qName,
                                 org.xml.sax.Attributes attrs)
                          throws org.xml.sax.SAXException
        Specified by:
        startElement in interface org.xml.sax.ContentHandler
        Overrides:
        startElement in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • endElement

        public void endElement​(java.lang.String nsURI,
                               java.lang.String localName,
                               java.lang.String qName)
                        throws org.xml.sax.SAXException
        Specified by:
        endElement in interface org.xml.sax.ContentHandler
        Overrides:
        endElement in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • characters

        public void characters​(char[] ch,
                               int start,
                               int length)
                        throws org.xml.sax.SAXException
        Specified by:
        characters in interface org.xml.sax.ContentHandler
        Overrides:
        characters in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • ignorableWhitespace

        public void ignorableWhitespace​(char[] ch,
                                        int start,
                                        int length)
                                 throws org.xml.sax.SAXException
        Specified by:
        ignorableWhitespace in interface org.xml.sax.ContentHandler
        Overrides:
        ignorableWhitespace in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • parse

        public void parse​(java.lang.String filename)
                   throws java.lang.Exception
        Throws:
        java.lang.Exception
      • statistics

        public boolean statistics()
        Show how many warnings, errors and fatals were shown.
        Returns:
        true, if we should transmit an error exit code.
      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception