private static void AddXmlValidationMessage(string aFileName, string aMessage, XmlSeverityType aXmlSeverityType, int aLineNumber, int aLinePosition) { IOTAMessageService _MessageService = OtaUtils.GetMessageService(); OTAMessageKind _OTAMessageKind = OTAMessageKind.otamkWarn; IntPtr _Out; if (aXmlSeverityType == XmlSeverityType.Error) { _OTAMessageKind = OTAMessageKind.otamkError; } _MessageService.ShowMessageView(null); _MessageService.AddCompilerMessage(aFileName, aMessage, "Xml / Xsd Validation", _OTAMessageKind, aLineNumber, aLinePosition, new IntPtr(0), out _Out); }
internal DataSetCheckerEventArgs(XmlSeverityType severity, string message, XmlNode node, Exception exception) { this.message = message ?? throw new ArgumentNullException(nameof(message)); this.severity = severity; this.node = node; this.exception = exception; }
/// <summary> /// Constructor de la clase. /// </summary> /// <param name="excepcion">la excepción que generó el error.</param> /// <param name="mensaje">el mensaje reportado por el error.</param> /// <param name="severidad">la severidad del error reportado.</param> public ErrorCargaTaxonomia(string codigo, Exception excepcion, string mensaje, XmlSeverityType severidad) { CodigoError = codigo; Excepcion = excepcion; Mensaje = mensaje; Severidad = severidad; }
private static bool IsValidXmlBySchema(XDocument doc) { bool isValid = true; var schema = new XmlSchemaSet(); schema.Add("http://tempuri.org/Computer.xsd", path + "\\Computer.xsd"); doc.Validate(schema, ValidationEventHandler); return(isValid); void ValidationEventHandler(object sender, ValidationEventArgs e) { XmlSeverityType type = XmlSeverityType.Warning; if (Enum.TryParse("Error", out type)) { if (type == XmlSeverityType.Error) { isValid = false; //throw new Exception(e.Message); } } } }
internal void Add(XmlSeverityType severity, string message) { Add(message); HasErrors = severity == XmlSeverityType.Error; HasWarnings = severity == XmlSeverityType.Warning; }
public void CallbackB(object sender, ValidationEventArgs args) { lastObjectSent = sender; IsCalledB = true; lastSeverity = args.Severity; lastException = args.Exception as XmlSchemaValidationException; }
public ValidationErrors(XmlSeverityType Severity, string Message, int Line, int Position) { this.Severity = Severity; this.Message = Message; this.Line = Line; this.Position = Position; }
public XmlValidationError(string message, XmlSeverityType severityType, int lineNumber, int linePosition) { this.message = message; this.severityType = severityType; this.lineNumber = lineNumber; this.linePosition = linePosition; }
public XmlValidationError(XmlException ex) { LineNumber = ex.LineNumber; LinePosition = ex.LinePosition; Message = ex.Message; Severity = XmlSeverityType.Error; }
public XmlValidationError(string message, XmlSeverityType severity, int lineNumber, int linePosition) { this.Message = message; this.Severity = severity; this.LineNumber = lineNumber; this.LinePosition = linePosition; }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (!(value is XmlSeverityType)) { return(value); } if (_imageSourceConverter == null) { _imageSourceConverter = new ImageSourceConverter(); } XmlSeverityType severity = (XmlSeverityType)value; switch (severity) { case XmlSeverityType.Error: return(_imageSourceConverter.ConvertFromString(@"pack://*****:*****@"pack://application:,,/Resources/Warning16.png")); } return(value); }
public ValidationProblem(string message, int line, int column, XmlSeverityType type) { this.message = message; this.line = line; this.column = column; this.type = type; }
public ErrorMessage(XmlSeverityType severity, string message, XmlSchemaException exception, int lineNumber) { Severity = severity; Message = message; Exception = exception; LineNumber = lineNumber.ToString("N0"); }
/// <summary> /// Creates an instance of ValidationProblem. /// </summary> /// <param name="message">the problem's message</param> /// <param name="line">line the problem was detected in</param> /// <param name="column">column the problem was detected at</param> /// <param name="type">the type of problem</param> public ValidationProblem(string message, int line, int column, XmlSeverityType type) { this.message = message; this.line = line; this.column = column; this.type = type; }
protected void SendValidationEventNoThrow(XmlSchemaException e, XmlSeverityType severity) { if (severity == XmlSeverityType.Error) { _errorCount++; } _eventHandler?.Invoke(null, new ValidationEventArgs(e, severity)); }
void IValidationEventHandling.SendEvent(Exception /*XmlSchemaException*/ exception, XmlSeverityType severity) { if (eventHandler != null) { eventHandler(reader, new ValidationEventArgs((XmlSchemaException)exception, severity)); } else if (reader.ValidationType != ValidationType.None && severity == XmlSeverityType.Error) { throw exception; } }
/// <summary> /// Handles a XmlValidation exception/error /// </summary> /// <param name="sender"></param> /// <param name="arguments"></param> private static void ValidationError(object sender, ValidationEventArgs arguments) { m_SchemaException = arguments.Exception; m_sValidationErrorMessage = arguments.Message; m_SeverityType = arguments.Severity; m_bXmlFileValid = false; }
private void SendValidationEvent(XmlSchemaException e, XmlSeverityType severity) { if (this.eventHandler == null) { throw e; } this.eventHandler(this, new ValidationEventArgs(e, severity)); }
/// <summary> /// Handles a Schema read exception/error /// </summary> /// <param name="sender"></param> /// <param name="arguments"></param> private static void SchemaReadError(object sender, ValidationEventArgs arguments) { m_SchemaException = arguments.Exception; m_sValidationErrorMessage = arguments.Message; m_SeverityType = arguments.Severity; throw new Exception("SchemaReadError: " + arguments.Message); }
/// <summary> /// Build the message from information in a validation event. /// </summary> public ValidationMessage(Object source, XmlSeverityType severityType, string message) { ParameterCheck.ParameterRequired(message, "message"); ValidationMessageType = severityType == XmlSeverityType.Error ? ValidationMessageType.Error : ValidationMessageType.Warning; Message = message; XPath = LocalXPathOrRoot(source); }
internal ValuednessValidationCallbackArgs(XPathNavigator navigator, XmlSeverityType severity) { if (navigator == null) { throw new ArgumentNullException("navigator"); } Navigator = navigator; Severity = severity; }
private void AddError(string description, XmlSeverityType category) { Error error = new Error(); error.Description = description; error.Category = category; this.AddError(error); }
/// <summary> /// Validates an xmldocument according to the xmlschema /// </summary> /// <param name="xmlRaw"></param> /// <param name="xmlSchema"></param> /// <returns></returns> public static bool Validate(XmlDocument xmlRaw, XmlSchema xmlSchema) { m_bXmlFileValid = true; // set to true, since the error handler will set it to 'false' m_SchemaException = null; m_sValidationErrorMessage = string.Empty; m_SeverityType = XmlSeverityType.Warning; XmlValidatingReader xmlValidator = null; string sTempXmlFile = FileUtilities.GetUniqueTempFileName(); try { if (File.Exists(sTempXmlFile) == true) { File.Delete(sTempXmlFile); } xmlRaw.Save(sTempXmlFile); //Get Validator XmlTextReader xmlReader = new XmlTextReader(sTempXmlFile); xmlValidator = new XmlValidatingReader(xmlReader); //Assign Schema xmlValidator.Schemas.Add(xmlSchema); xmlValidator.ValidationType = ValidationType.Schema; xmlValidator.ValidationEventHandler += new ValidationEventHandler(ValidationError); //Validate the entire Document Node By Node while (xmlValidator.Read()) { ; } } catch (Exception ex) { throw new Exception("Validation exception: ", ex); } finally { if (xmlValidator != null) { xmlValidator.Close(); } xmlValidator = null; if (File.Exists(sTempXmlFile) == true) { File.Delete(sTempXmlFile); } } return(m_bXmlFileValid); }
/// <summary> /// Build the message from information in a validation event. /// </summary> public ValidationMessage(Object source, XmlSeverityType severityType, string message) { ParameterCheck.ParameterRequired(message, "message"); ValidationMessageType = severityType == XmlSeverityType.Error ? ValidationMessageType.Error : ValidationMessageType.Warning; Message = message; XPath = LocalXPathOrRoot(source); }
void IValidationEventHandling.SendEvent(Exception exception, XmlSeverityType severity) { if (this.eventHandler != null) { this.eventHandler(this.reader, new ValidationEventArgs((XmlSchemaException)exception, severity)); } else if ((this.reader.ValidationType != ValidationType.None) && (severity == XmlSeverityType.Error)) { throw exception; } }
protected void SendValidationEvent(XmlSchemaException e, XmlSeverityType severity) { if (eventHandler != null) { eventHandler(reader, new ValidationEventArgs(e, severity)); } else if (severity == XmlSeverityType.Error) { throw e; } }
protected void SendValidationEventNoThrow(XmlSchemaException e, XmlSeverityType severity) { if (severity == XmlSeverityType.Error) { this.errorCount++; } if (this.eventHandler != null) { this.eventHandler(null, new ValidationEventArgs(e, severity)); } }
protected void SendValidationEvent(XmlSchemaException e, XmlSeverityType severity) { if (_eventHandling != null) { _eventHandling.SendEvent(e, severity); } else if (severity == XmlSeverityType.Error) { throw e; } }
/// <summary> /// This event will fire on every XML validation error / warning. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> static public void ValidationEventHandler(object sender, ValidationEventArgs args) { XmlSeverityType type = XmlSeverityType.Warning; if (Enum.TryParse <XmlSeverityType>("Warning", out type)) { if (type == XmlSeverityType.Error) { Console.WriteLine(string.Format("{0}, {1}, {2}", args.Exception, args.Exception.LineNumber, args.Exception.LinePosition)); } } }
static void ValidationEventHandler(object sender, ValidationEventArgs e) { XmlSeverityType xmlSeverityType = XmlSeverityType.Warning; if (!Enum.TryParse <XmlSeverityType>("Error", out xmlSeverityType)) { if (xmlSeverityType == XmlSeverityType.Error) { throw new Exception(e.Message); } } }
/// <summary> /// Constructor de la clase. /// </summary> /// <param name="excepcion">la excepción que generó el error.</param> /// <param name="mensaje">el mensaje reportado por el error.</param> /// <param name="severidad">la severidad del error reportado.</param> public ErrorCargaTaxonomia(string codigo, Exception excepcion, string mensaje, XmlSeverityType severidad, string archivo, IDictionary <string, object> infoExtra, int linea = 0, int columna = 0) { CodigoError = codigo; Excepcion = excepcion; Mensaje = mensaje; Severidad = severidad; UriArchivo = archivo; InformacionExtra = infoExtra; Linea = linea; Columna = columna; }
private void ValidationEventHandler(dynamic sender, ValidationEventArgs e) { XmlSeverityType type = XmlSeverityType.Warning; if (Enum.TryParse <XmlSeverityType>("Error", out type)) { if (type == XmlSeverityType.Error) { ValidationErrors.AppendLine(e.Message + Environment.NewLine + sender.Parent); } } }
static void ValidationEventHandler(object sender, ValidationEventArgs e) { XmlSeverityType type = XmlSeverityType.Warning; if (Enum.TryParse <XmlSeverityType>("Error", out type)) { if (type == XmlSeverityType.Error) { Console.WriteLine(e.Message); throw new Exception(e.Message); } } }
private static DtdMessageType GetMessageTye(XmlSeverityType eventArgSeverity) { switch (eventArgSeverity) { case XmlSeverityType.Error: return(DtdMessageType.Error); case XmlSeverityType.Warning: return(DtdMessageType.Warning); } return(DtdMessageType.Error); }
public static void RaiseValidationEvent(ValidationEventHandler handle, Exception innerException, string message, XmlSchemaObject xsobj, object sender, string sourceUri, XmlSeverityType severity) { XmlSchemaException ex = new XmlSchemaException ( message, sender, sourceUri, xsobj, innerException); ValidationEventArgs e = new ValidationEventArgs(ex,message,severity); if(handle == null) { if (e.Severity == XmlSeverityType.Error) throw e.Exception; } else { handle(sender,e); } }
private void SendValidationEvent(XmlSchemaException e, XmlSeverityType severity) { this.schema.ErrorCount++; e.SetSchemaObject(this.schema); if (validationEventHandler != null) { validationEventHandler(null, new ValidationEventArgs(e, severity)); } else if (severity == XmlSeverityType.Error) { throw e; } }
private void SendValidationEvent(string code, string[] args, XmlSeverityType severity) { SendValidationEvent(new XmlSchemaException(code, args, this.reader.BaseURI, this.positionInfo.LineNumber, this.positionInfo.LinePosition), severity); }
/// <summary> /// Handles a Schema read exception/error /// </summary> /// <param name="sender"></param> /// <param name="arguments"></param> private static void SchemaReadError(object sender, ValidationEventArgs arguments) { m_SchemaException = arguments.Exception; m_sValidationErrorMessage = arguments.Message; m_SeverityType = arguments.Severity; throw new Exception("SchemaReadError: " + arguments.Message); }
private void SendValidationEvent(XmlSchemaException e, XmlSeverityType severity) { _SchemaInfo.ErrorCount++; if (_validationEventHandler != null) { _validationEventHandler(this, new ValidationEventArgs(e, severity)); } else if (severity == XmlSeverityType.Error) { throw e; } }
internal void DtdParserProxy_SendValidationEvent( XmlSeverityType severity, XmlSchemaException exception ) { if ( DtdValidation ) { this.SendValidationEvent( severity, exception ); } }
private void SendValidationEvent(XmlSeverityType severity, XmlSchemaException e) { Debug.Assert(_validate); IValidationEventHandling eventHandling = _readerAdapterWithValidation.ValidationEventHandling; if (eventHandling != null) { eventHandling.SendEvent(e, severity); } }
private void SendValidationEvent(XmlSchemaValidationException e, XmlSeverityType severity) { bool errorSeverity = false; if (severity == XmlSeverityType.Error) { errorSeverity = true; context.Validity = XmlSchemaValidity.Invalid; } if (errorSeverity) { if (eventHandler != null) { eventHandler(validationEventSender, new ValidationEventArgs(e, severity)); } else { throw e; } } else if (ReportValidationWarnings && eventHandler != null) { eventHandler(validationEventSender, new ValidationEventArgs(e, severity)); } }
private void SendValidationEvent(XmlSchemaException e, XmlSeverityType severity) { if (validationEventHandler != null) { validationEventHandler(null, new ValidationEventArgs(e, severity)); } else if (severity == XmlSeverityType.Error) { throw e; } }
protected void SendValidationEvent(XmlSchemaException e, XmlSeverityType severity) { if (eventHandling != null) { eventHandling.SendEvent(e, severity); } else if (severity == XmlSeverityType.Error) { throw e; } }
private void SendValidationEvent(XmlSchemaValidationException e, XmlSeverityType severity) { bool flag = false; if (severity == XmlSeverityType.Error) { flag = true; this.context.Validity = XmlSchemaValidity.Invalid; } if (flag) { if (this.eventHandler == null) { throw e; } this.eventHandler(this.validationEventSender, new ValidationEventArgs(e, severity)); } else if (this.ReportValidationWarnings && (this.eventHandler != null)) { this.eventHandler(this.validationEventSender, new ValidationEventArgs(e, severity)); } }
protected void SendValidationEvent(string code, string msg, XmlSeverityType severity) { SendValidationEvent(new XmlSchemaException(code, msg, reader.BaseURI, positionInfo.LineNumber, positionInfo.LinePosition), severity); }
/// <summary> /// Validates an xmldocument according to the xmlschema /// </summary> /// <param name="xmlRaw"></param> /// <param name="xmlSchema"></param> /// <returns></returns> public static bool Validate(XmlDocument xmlRaw, XmlSchema xmlSchema) { m_bXmlFileValid = true; // set to true, since the error handler will set it to 'false' m_SchemaException = null; m_sValidationErrorMessage = string.Empty; m_SeverityType = XmlSeverityType.Warning; XmlValidatingReader xmlValidator = null; string sTempXmlFile = FileUtilities.GetUniqueTempFileName(); try { if (File.Exists(sTempXmlFile) == true) File.Delete(sTempXmlFile); xmlRaw.Save(sTempXmlFile); //Get Validator XmlTextReader xmlReader = new XmlTextReader(sTempXmlFile); xmlValidator = new XmlValidatingReader(xmlReader); //Assign Schema xmlValidator.Schemas.Add(xmlSchema); xmlValidator.ValidationType = ValidationType.Schema; xmlValidator.ValidationEventHandler += new ValidationEventHandler(ValidationError); //Validate the entire Document Node By Node while (xmlValidator.Read()); } catch (Exception ex) { throw new Exception("Validation exception: ", ex); } finally { if(xmlValidator != null) xmlValidator.Close(); xmlValidator = null; if (File.Exists(sTempXmlFile) == true) File.Delete(sTempXmlFile); } return m_bXmlFileValid; }
private void HandleError (string message, XmlSeverityType severity) { if (validatingReader != null && validatingReader.ValidationType == ValidationType.None) return; IXmlLineInfo info = this as IXmlLineInfo; bool hasLine = info.HasLineInfo (); XmlSchemaException ex = new XmlSchemaException ( message, hasLine ? info.LineNumber : 0, hasLine ? info.LinePosition : 0, null, BaseURI, null); HandleError (ex, severity); }
internal ValidationEventArgs( XmlSchemaException ex ) : base() { this.ex = ex; severity = XmlSeverityType.Error; }
private void SendValidationEvent(string code, string msg, XmlSeverityType severity) { if (severity != XmlSeverityType.Warning || ReportValidationWarnings) { SendValidationEvent(new XmlSchemaValidationException(code, msg, sourceUriString, positionInfo.LineNumber, positionInfo.LinePosition), severity); } }
internal ValidationEventArgs( XmlSchemaException ex , XmlSeverityType severity ) : base() { this.ex = ex; this.severity = severity; }
private void SendValidationEvent(XmlSeverityType severity, string code, string arg, int lineNo, int linePos) { SendValidationEvent(severity, new XmlSchemaException(code, arg, _ps.baseUriStr, lineNo, linePos)); }
private void SendValidationEvent(XmlSeverityType severity, string code, string arg) { Debug.Assert(_validate); SendValidationEvent(severity, new XmlSchemaException(code, arg, BaseUriStr, (int)LineNo, (int)LinePos)); }
private void SendValidationEvent(XmlSeverityType severity, XmlSchemaException exception) { if (_validationEventHandling != null) { _validationEventHandling.SendEvent(exception, severity); } }
private void SendValidationEvent(string code, string[] args, Exception innerException, XmlSeverityType severity) { if ((severity != XmlSeverityType.Warning) || this.ReportValidationWarnings) { this.SendValidationEvent(new XmlSchemaValidationException(code, args, innerException, this.sourceUriString, this.positionInfo.LineNumber, this.positionInfo.LinePosition), severity); } }
/// <summary> /// Handles a XmlValidation exception/error /// </summary> /// <param name="sender"></param> /// <param name="arguments"></param> private static void ValidationError(object sender, ValidationEventArgs arguments) { m_SchemaException = arguments.Exception; m_sValidationErrorMessage = arguments.Message; m_SeverityType = arguments.Severity; m_bXmlFileValid = false; }
internal static void SendValidationEvent(System.Xml.Schema.ValidationEventHandler eventHandler, object sender, XmlSchemaValidationException e, XmlSeverityType severity) { if (eventHandler != null) { eventHandler(sender, new ValidationEventArgs(e, severity)); } else if (severity == XmlSeverityType.Error) { throw e; } }
void SendValidationEvent( XmlSeverityType severity, XmlSchemaException exception ) { if ( validationEventHandler != null ) { validationEventHandler( this, new ValidationEventArgs( exception, severity ) ); } }
private void HandleError (XmlSchemaException ex, XmlSeverityType severity) { if (validatingReader != null && validatingReader.ValidationType == ValidationType.None) return; if (validatingReader != null) this.validatingReader.OnValidationEvent (this, new ValidationEventArgs (ex, ex.Message, severity)); else if (severity == XmlSeverityType.Error) throw ex; }
private void SendValidationEvent( XmlSeverityType severity, XmlSchemaException e ) { Debug.Assert( validate ); readerAdapter.SendValidationEvent( severity, e ); }