Exemple #1
0
 public virtual void Warning(SAXParseException e)
 {
     if (_errorHandler != null)
     {
         _errorHandler.Warning(e);
     }
 }
Exemple #2
0
 public Problem(SAXParseException e, string resource)
 {
     concatenateErrorMessages(e);
     this.resource = resource;
     this.line     = e.LineNumber;
     this.column   = e.ColumnNumber;
 }
Exemple #3
0
 /// <summary>
 /// Filter an error event.
 /// </summary>
 /// <param name="e">The error as an exception.</param>
 /// <exception cref="SAXException">The client may throw
 /// an exception during processing.</exception>
 public virtual void Error(SAXParseException e)
 {
     if (errorHandler != null)
     {
         errorHandler.Error(e);
     }
 }
Exemple #4
0
 public virtual void FatalError(SAXParseException e)
 {
     if (_errorHandler != null)
     {
         _errorHandler.FatalError(e);
     }
 }
        public override void warning(SAXParseException e)

        {
            if (log.isLoggable(Level.FINE))
            {
                log.log(Level.FINE, getClass().getSimpleName() + ".warning0: " + e);
            }
        }
Exemple #6
0
        ////////////////////////////////////////////////////////////////////
        // Implementation of org.xml.sax.ErrorHandler.
        ////////////////////////////////////////////////////////////////////


        /**
         * Filter a warning event.
         *
         * @param e The warning as an exception.
         * @exception org.xml.sax.SAXException The client may throw
         *            an exception during processing.
         */
        public void warning(SAXParseException e)
        //throws SAXException
        {
            if (errorHandler != null)
            {
                errorHandler.warning(e);
            }
        }
Exemple #7
0
 /**
  * Filter a fatal error event.
  *
  * @param e The error as an exception.
  * @exception org.xml.sax.SAXException The client may throw
  *            an exception during processing.
  */
 public void fatalError(SAXParseException e)
 //throws SAXException
 {
     if (errorHandler != null)
     {
         errorHandler.fatalError(e);
     }
 }
        public override void fatalError(SAXParseException e)

        {
            if (log.isLoggable(Level.FINE))
            {
                log.log(Level.FINE, getClass().getSimpleName() + ".fatalError0: " + e);
            }
        }
Exemple #9
0
        // AElfred only has fatal errors
        public virtual void Error(string message, string url, int line, int column)
        {
            var fatal = new SAXParseException(message, null, url, line, column);

            _errorHandler.FatalError(fatal);

            // Even if the application can continue ... we can't!
            throw fatal;
        }
Exemple #10
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public XmlDocument Parse(XmlReader reader)
        {
            XmlDocument doc = new XmlDocument();

            ArrayList[] schemas = dbf.GetAttributes();
            if (schemas != null && schemas[0] != null)
            {
                for (int i = 0; i < schemas[0].Count; i++)
                {
                    String schema_uri = (String)schemas[1][i];
                    if (schema_uri.IndexOf(".xsd") == -1)
                        schema_uri += ".xsd";

                    XmlTextReader schema_reader = new XmlTextReader(schema_uri);
                    try
                    {
                        XmlSchema schema = XmlSchema.Read(schema_reader, null);
                        doc.Schemas.Add(schema);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Failed to add schema definition (XSD):" + e);
                    }
                }
            }

            doc.Load(reader);

            if (dbf.GetValidating())
            {
                //  Need to validate XML...
                //  
                ValidationEventHandler eventHandler = new ValidationEventHandler(ValidationEventHandler);
                try
                {
                    doc.Validate(eventHandler);
                }
                catch (XmlSchemaException e)
                {
                    if (ihandler != null)
                    {
                        SAXParseException saxe = new SAXParseException("SAXParseException parsing " + reader.BaseURI + " - " + e.Message, e);
                        saxe.LineNumber = e.LineNumber;
                        saxe.ColumnNumber = e.LinePosition;
                    }
                }
            }

            return doc;
        }
Exemple #11
0
        /// <summary>
        /// Returns a string of the location.
        /// </summary>
        private string getLocationString(SAXParseException ex)
        {
            StringBuilder str = new StringBuilder();

            string systemId = ex.SystemId;

            if (systemId != null)
            {
                int index = systemId.LastIndexOf('/');
                if (index != -1)
                {
                    systemId = systemId.Substring(index + 1);
                }
                str.Append(systemId);
            }
            str.Append(':');
            str.Append(ex.LineNumber);
            str.Append(':');
            str.Append(ex.ColumnNumber);

            return(str.ToString());
        }   // getLocationString(SAXParseException):String
        /// <summary></summary>
        public string[] GetErrorMessages()
        {
            if (errors == null)
            {
                return(new string[0]);
            }
            string[]      result = new string[errors.Count];
            StringBuilder buffer = new StringBuilder();

            for (int i = 0; i < result.Length; i++)
            {
                buffer.Length = 0;
                SAXParseException e
                    = (SAXParseException)errors[i];
                if (e.LineNumber != -1)
                {
                    buffer.Append("line " + e.LineNumber + ": ");
                }
                buffer.Append(e.Message);
                result[i] = buffer.ToString();
            }
            return(result);
        }
Exemple #13
0
 public virtual void FatalError(SAXParseException e) {
   throw e;
 }
Exemple #14
0
 public void Warning(SAXParseException exception)
 {
 }
Exemple #15
0
 /// <summary>
 /// Report a fatal XML parsing error.
 /// <para/>
 /// The default implementation throws a <see cref="SAXParseException"/>.
 /// Application writers may override this method in a subclass if
 /// they need to take specific actions for each fatal error (such as
 /// collecting all of the errors into a single report): in any case,
 /// the application must stop all regular processing when this
 /// method is invoked, since the document is no longer reliable, and
 /// the parser may no longer report parsing events.
 /// </summary>
 /// <param name="e">The error information encoded as an exception.</param>
 /// <exception cref="SAXException">Any SAX exception, possibly
 /// wrapping another exception.</exception>
 /// <seealso cref="IErrorHandler.FatalError(SAXParseException)"/>
 /// <seealso cref="SAXParseException"/>
 public virtual void FatalError(SAXParseException e)
 {
     throw e;
 }
 protected override void errNoNamedCharacterMatch()
 {
     if (errorHandler == null) {
         return;
     }
     SAXParseException spe = new SAXParseException(
             "\u201C&\u201D did not start a character reference. (\u201C&\u201D probably should have been escaped as \u201C&amp;\u201D.)",
             ampersandLocation);
     errorHandler.error(spe);
 }
Exemple #17
0
 /*
  * Receive notification of a recoverable parser error.
  *
  * <p>The default implementation does nothing.  Application writers
  * may override this method in a subclass to take specific actions
  * for each error, such as inserting the message in a log file or
  * printing it to the console.</p>
  *
  * @param e The warning information encoded as an exception.
  * @exception org.xml.sax.SAXException Any SAX exception, possibly
  *            wrapping another exception.
  * @see org.xml.sax.ErrorHandler#warning
  * @see org.xml.sax.SAXParseException
  */
 public void error(SAXParseException e)
 //throws SAXException
 {
     // no op
 }
 /// <summary>
 /// Report a fatal XML parsing error.
 /// </summary>
 public void fatalError(SAXParseException e)
 {
 }
Exemple #19
0
 public virtual void Error(SAXParseException e) {
   // no op
 }
 public abstract void Error(SAXParseException exception);
 /**
  * Emit an error. The locator is used.
  *
  * @param message the error message
  * @throws SAXException if something goes wrong
  */
 public void err(String message)
 {
     if (errorHandler != null) {
         SAXParseException spe = new SAXParseException(message, locator);
         errorHandler.error(spe);
     }
 }
Exemple #22
0
        public void parse(string url)
        {
            int buflen = 500;

            char[]            buffer       = new char[buflen];
            Stack             nsstack      = new Stack();
            Locator           locator      = new Locator();
            SAXParseException saxException = new SAXParseException();
            Attributes        atts;
            XmlTextReader     reader = null;

            try {
                reader = new XmlTextReader(url);
                object nsuri = reader.NameTable.Add("http://www.w3.org/2000/xmlns/");
                Handler.startDocument();
                while (reader.Read())
                {
                    int    len;
                    string prefix;
                    locator.LineNumber   = reader.LineNumber;
                    locator.ColumnNumber = reader.LinePosition;
                    Handler.setDocumentLocator(locator);
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        nsstack.Push(null);                                //marker
                        atts = new Attributes();
                        while (reader.MoveToNextAttribute())
                        {
                            if (reader.NamespaceURI.Equals(nsuri))
                            {
                                prefix = "";
                                if (reader.Prefix == "xmlns")
                                {
                                    prefix = reader.LocalName;
                                }
                                nsstack.Push(prefix);
                                Handler.startPrefixMapping(prefix, reader.Value);
                            }
                            else
                            {
                                SaxAttribute newAtt = new SaxAttribute();
                                newAtt.Name         = reader.Name;
                                newAtt.NamespaceURI = reader.NamespaceURI;
                                newAtt.Value        = reader.Value;
                                atts.attArray.Add(newAtt);
                            }
                        }
                        reader.MoveToElement();
                        Handler.startElement(reader.NamespaceURI,
                                             reader.LocalName, reader.Name, atts.TrimArray());
                        if (reader.IsEmptyElement)
                        {
                            Handler.endElement(reader.NamespaceURI,
                                               reader.LocalName, reader.Name);
                        }
                        break;

                    case XmlNodeType.EndElement:
                        Handler.endElement(reader.NamespaceURI,
                                           reader.LocalName, reader.Name);
                        prefix = (string)nsstack.Pop();
                        while (prefix != null)
                        {
                            Handler.endPrefixMapping(prefix);
                            prefix = (string)nsstack.Pop();
                        }
                        break;

                    case XmlNodeType.Text:
                        while ((len = reader.ReadChars(buffer, 0, buflen)) > 0)
                        {
                            Handler.characters(buffer, 0, len);
                        }
                        //After read your are automatically put on the next tag so you
                        //have to call the proper case from here or it won't work correctly.
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            goto case XmlNodeType.Element;
                        }
                        if (reader.NodeType == XmlNodeType.EndElement)
                        {
                            goto case XmlNodeType.EndElement;
                        }
                        break;

                    case XmlNodeType.ProcessingInstruction:
                        Handler.processingInstruction(reader.Name, reader.Value);
                        break;

                    case XmlNodeType.Whitespace:
                        char[] whiteSpace = reader.Value.ToCharArray();
                        Handler.ignorableWhitespace(whiteSpace, 0, 1);
                        break;

                    case XmlNodeType.Entity:
                        Handler.skippedEntity(reader.Name);
                        break;
                    }
                }
                Handler.endDocument();
            }             //try
            catch (Exception exception) {
                saxException.LineNumber = reader.LineNumber.ToString();
                saxException.SystemID   = "";
                saxException.Message    = exception.GetBaseException().ToString();
                errorHandler.error(saxException);
            } finally {
                if (reader.ReadState != ReadState.Closed)
                {
                    reader.Close();
                }
            }
        }
Exemple #23
0
 public virtual void warning(SAXParseException e)
 {
     parse.addWarning(e);
 }
Exemple #24
0
 public virtual void fatalError(SAXParseException e)
 {
     parse.addError(e);
 }
 public override void Error(SAXParseException exception)
 {
     this.LogError(exception.Message);
 }
Exemple #26
0
 public void Error(SAXParseException exception)
 {
 }
Exemple #27
0
 public void fatalError(SAXParseException exception)
 {
     context.Response.Write("<p><b>Fatal Error: " + exception.getMessage() + "</b></p>");
     context.Response.Write("<p>Line Number:" + exception.getLineNumber() + "</p>");
 }
Exemple #28
0
 public void FatalError(SAXParseException exception)
 {
 }
Exemple #29
0
 //throws SAXException
 /**
  * Filter a fatal error event.
  *
  * @param e The error as an exception.
  * @exception org.xml.sax.SAXException The client may throw
  *            an exception during processing.
  */
 public void fatalError(SAXParseException e)
 {
     if (errorHandler != null)
     {
         errorHandler.fatalError(e);
     }
 }
Exemple #30
0
        ////////////////////////////////////////////////////////////////////
        // Default implementation of the ErrorHandler interface.
        ////////////////////////////////////////////////////////////////////


        /*
         * Receive notification of a parser warning.
         *
         * <p>The default implementation does nothing.  Application writers
         * may override this method in a subclass to take specific actions
         * for each warning, such as inserting the message in a log file or
         * printing it to the console.</p>
         *
         * @param e The warning information encoded as an exception.
         * @exception org.xml.sax.SAXException Any SAX exception, possibly
         *            wrapping another exception.
         * @see org.xml.sax.ErrorHandler#warning
         * @see org.xml.sax.SAXParseException
         */
        public void warning(SAXParseException e)
        //throws SAXException
        {
            // no op
        }
Exemple #31
0
        ////////////////////////////////////////////////////////////////////
        // Default implementation of the ErrorHandler interface.
        ////////////////////////////////////////////////////////////////////


        /// <summary>
        /// Receive notification of a parser warning.
        /// <para/>
        /// The default implementation does nothing.  Application writers
        /// may override this method in a subclass to take specific actions
        /// for each warning, such as inserting the message in a log file or
        /// printing it to the console.
        /// </summary>
        /// <param name="e">The warning information encoded as an exception.</param>
        /// <exception cref="SAXException">Any SAX exception, possibly
        /// wrapping another exception.</exception>
        /// <seealso cref="IErrorHandler.Warning(SAXParseException)"/>
        /// <seealso cref="SAXParseException"/>
        public virtual void Warning(SAXParseException e)
        {
            // no op
        }
Exemple #32
0
 /*
  * Report a fatal XML parsing error.
  *
  * <p>The default implementation throws a SAXParseException.
  * Application writers may override this method in a subclass if
  * they need to take specific actions for each fatal error (such as
  * collecting all of the errors into a single report): in any case,
  * the application must stop all regular processing when this
  * method is invoked, since the document is no longer reliable, and
  * the parser may no longer report parsing events.</p>
  *
  * @param e The error information encoded as an exception.
  * @exception org.xml.sax.SAXException Any SAX exception, possibly
  *            wrapping another exception.
  * @see org.xml.sax.ErrorHandler#fatalError
  * @see org.xml.sax.SAXParseException
  */
 public void fatalError(SAXParseException e)
 //throws SAXException
 {
     throw e;
 }
 /// <summary>
 /// Receive notification of a recoverable parser error.
 /// </summary>
 public void error(SAXParseException e)
 {
 }
Exemple #34
0
 //throws SAXException
 ////////////////////////////////////////////////////////////////////
 // Implementation of org.xml.sax.ErrorHandler.
 ////////////////////////////////////////////////////////////////////
 /**
  * Filter a warning event.
  *
  * @param e The warning as an exception.
  * @exception org.xml.sax.SAXException The client may throw
  *            an exception during processing.
  */
 public void warning(SAXParseException e)
 {
     if (errorHandler != null)
     {
         errorHandler.warning(e);
     }
 }
Exemple #35
0
 //throws SAXException
 /**
  * Receive notification of a recoverable parser error.
  *
  * <p>The default implementation does nothing.  Application writers
  * may override this method in a subclass to take specific actions
  * for each error, such as inserting the message in a log file or
  * printing it to the console.</p>
  *
  * @param e The warning information encoded as an exception.
  * @exception org.xml.sax.SAXException Any SAX exception, possibly
  *            wrapping another exception.
  * @see org.xml.sax.ErrorHandler#warning
  * @see org.xml.sax.SAXParseException
  */
 public void error(SAXParseException e)
 {
     // no op
 }
Exemple #36
0
 /// <summary>
 /// Receive notification of a recoverable parser error.
 /// <para/>The default implementation does nothing.  Application writers
 /// may override this method in a subclass to take specific actions
 /// for each error, such as inserting the message in a log file or
 /// printing it to the console.
 /// </summary>
 /// <param name="e">The warning information encoded as an exception.</param>
 /// <exception cref="SAXException">Any SAX exception, possibly
 /// wrapping another exception.</exception>
 /// <seealso cref="IErrorHandler.Warning(SAXParseException)"/>
 /// <seealso cref="SAXParseException"/>
 public virtual void Error(SAXParseException e)
 {
     // no op
 }
Exemple #37
0
 //throws SAXException
 /**
  * Report a fatal XML parsing error.
  *
  * <p>The default implementation throws a SAXParseException.
  * Application writers may override this method in a subclass if
  * they need to take specific actions for each fatal error (such as
  * collecting all of the errors into a single report): in any case,
  * the application must stop all regular processing when this
  * method is invoked, since the document is no longer reliable, and
  * the parser may no longer report parsing events.</p>
  *
  * @param e The error information encoded as an exception.
  * @exception org.xml.sax.SAXException Any SAX exception, possibly
  *            wrapping another exception.
  * @see org.xml.sax.ErrorHandler#fatalError
  * @see org.xml.sax.SAXParseException
  */
 public void fatalError(SAXParseException e)
 {
     throw e;
 }
 protected override void errUnescapedAmpersandInterpretedAsCharacterReference()
 {
     if (errorHandler == null) {
         return;
     }
     SAXParseException spe = new SAXParseException(
             "The string following \u201C&\u201D was interpreted as a character reference. (\u201C&\u201D probably should have been escaped as \u201C&amp;\u201D.)",
             ampersandLocation);
     errorHandler.error(spe);
 }
Exemple #39
0
 //throws SAXException
 ////////////////////////////////////////////////////////////////////
 // Default implementation of the ErrorHandler interface.
 ////////////////////////////////////////////////////////////////////
 /**
  * Receive notification of a parser warning.
  *
  * <p>The default implementation does nothing.  Application writers
  * may override this method in a subclass to take specific actions
  * for each warning, such as inserting the message in a log file or
  * printing it to the console.</p>
  *
  * @param e The warning information encoded as an exception.
  * @exception org.xml.sax.SAXException Any SAX exception, possibly
  *            wrapping another exception.
  * @see org.xml.sax.ErrorHandler#warning
  * @see org.xml.sax.SAXParseException
  */
 public void warning(SAXParseException e)
 {
     // no op
 }
Exemple #40
0
 public void warning(SAXParseException exception)
 {
     context.Response.Write("<p><b>Warning: " + exception.getMessage() + "</b></p>");
     context.Response.Write("<p>Line Number:" + exception.getLineNumber() + "</p>");
 }
Exemple #41
0
 public virtual void Warning(SAXParseException e) {
   // no op
 }
Exemple #42
0
 /**
  * @param string
  * @throws SAXException
  */
 private void warn(String message)
 {
     if (errorHandler != null) {
       SAXParseException spe = new SAXParseException(message, this);
       errorHandler.warning(spe);
     }
 }
 /**
  * @param string
  * @throws SAXException
  */
 private void err(String message)
 {
     // TODO remove wrapping when changing read() to take a CharBuffer
     try {
         if (errorHandler != null) {
             SAXParseException spe = new SAXParseException(message, this);
             errorHandler.error(spe);
         }
     } catch (SAXException e) {
         throw (IOException) new IOException(e.Message).initCause(e);
     }
 }