private static void ValidationEventHandler(object sender, System.Xml.Schema.ValidationEventArgs e) { //error in xml document isDocumentValid = false; //display the error message Console.WriteLine(e.Message); }
private void ValidationHandler(object sender, ValidationEventArgs args) { sbValidationErrors.AppendLine(args.Message); XmlSchemaValidationException vx = args.Exception as XmlSchemaValidationException; // 02/07/2010 Defensive programming, also check for valid SourceObject. if ( vx != null && vx.SourceObject != null ) { if ( vx.SourceObject is XmlElement ) { XmlElement xSourceObject = vx.SourceObject as XmlElement; sbValidationErrors.AppendLine("Source object for the exception is " + xSourceObject.Name + ". "); sbValidationErrors.AppendLine(xSourceObject.OuterXml); } else if ( vx.SourceObject is XmlAttribute ) { XmlAttribute xSourceObject = vx.SourceObject as XmlAttribute; sbValidationErrors.AppendLine("Source object for the exception is " + xSourceObject.Name + ". "); sbValidationErrors.AppendLine(xSourceObject.OuterXml); if ( xSourceObject.ParentNode != null ) sbValidationErrors.AppendLine(xSourceObject.ParentNode.OuterXml); } } #if DEBUG Debug.WriteLine(sbValidationErrors); #endif }
void ValidationCallback(object sender, ValidationEventArgs args) { if (args.Severity == XmlSeverityType.Error) { throw args.Exception; } }
/// <summary> /// delegate method that gets called when a validation error occurs /// </summary> /// <param name="sender">Sender.</param> /// <param name="args">Arguments.</param> public static void MyValidationEventHandler(object sender, ValidationEventArgs args) { throw new XmlSchemaException("Error validating bulletml document: " + args.Message, args.Exception, args.Exception.LineNumber, args.Exception.LinePosition); }
private void SchemaValidation(object obj, System.Xml.Schema.ValidationEventArgs erg) { if (erg.Exception != null) { throw new Exception("Schema Voilation: " + erg.Exception.Message); } }
//hook up validaton callback public void ValidationCallback(object sender, ValidationEventArgs args) { if (args.Severity == XmlSeverityType.Warning) { _output.WriteLine("WARNING: "); bWarningCallback = true; warningCount++; } else if (args.Severity == XmlSeverityType.Error) { _output.WriteLine("ERROR: "); bErrorCallback = true; errorCount++; } XmlSchemaException se = args.Exception as XmlSchemaException; _output.WriteLine("Exception Message:" + se.Message + "\n"); if (se.InnerException != null) { _output.WriteLine("InnerException Message:" + se.InnerException.Message + "\n"); } else _output.WriteLine("Inner Exception is NULL\n"); }
void myValidationEventHandler(object sender, ValidationEventArgs e) { if (e.Severity == XmlSeverityType.Error) throw e.Exception; else Trace.WriteLine(e.Exception.ToString()); }
static void OnValidationError(object sender, ValidationEventArgs e) { if (e.Severity == XmlSeverityType.Warning) Console.WriteLine("\tWarning: Matching schema not found. No validation occurred. " + e.Message); else Console.WriteLine("\tValidation error: " + e.Message); }
private static void SchemaValidationHandler(object sender, ValidationEventArgs args) { if (args.Severity == XmlSeverityType.Error) { throw new InvalidOperationException(System.Web.Services.Res.GetString("WsdlInstanceValidationDetails", new object[] { args.Message, args.Exception.LineNumber.ToString(CultureInfo.InvariantCulture), args.Exception.LinePosition.ToString(CultureInfo.InvariantCulture) })); } }
// Display any validation errors. private void XmlReader_ValidationCallBack(object sender, System.Xml.Schema.ValidationEventArgs e) { if (e.Exception != null) { ProcessException(e.Exception); } }
static void ValidationEventHandler(object sender, System.Xml.Schema.ValidationEventArgs e) { if (e.Severity == XmlSeverityType.Error) { throw new InvalidOperationException(e.Message); } }
//hook up validaton callback public void ValidationCallback(object sender, ValidationEventArgs args) { switch (args.Severity) { case XmlSeverityType.Warning: _output.WriteLine("WARNING: "); bWarningCallback = true; warningCount++; break; case XmlSeverityType.Error: _output.WriteLine("ERROR: "); bErrorCallback = true; errorCount++; break; } _output.WriteLine("Exception Message:" + args.Exception.Message + "\n"); if (args.Exception.InnerException != null) { _output.WriteLine("InnerException Message:" + args.Exception.InnerException.Message + "\n"); } else { _output.WriteLine("Inner Exception is NULL\n"); } }
static void ValidationEventHandler2(object sender, System.Xml.Schema.ValidationEventArgs e) { if (e.Severity == System.Xml.Schema.XmlSeverityType.Error) { hatalar.Append(e.Message + "<br><br>"); } }
public void ValidationCallBack(Object sender, ValidationEventArgs args) { //'Display the validation error. This is only called on error m_Success = false; //'Validation failed //writertbox("Validation error: " + args.Message); App.addDebugLine("Validation Error: " + args.Message); }
internal void ValidationCallBack(object sender, ValidationEventArgs args) { TTE.Log(sender, args); if (args.Severity == XmlSeverityType.Error | args.Severity == XmlSeverityType.Warning) { _isValid = false; } }
private void ValidationCallBack(object sender, ValidationEventArgs args) { if (args.Severity == XmlSeverityType.Warning) ValidationErrors.Add("Warning: Matching schema not found. No validation occurred." + args.Message); else ValidationErrors.Add("Validation error: " + args.Message); }
private static void SchemaValidationEventHandler(object sender, ValidationEventArgs arg) { Console.WriteLine($"{arg.Severity.ToString()}: {arg.Message}"); if (arg.Severity == XmlSeverityType.Error) { throw arg.Exception; } }
private static void ReaderSettings_ValidationEventHandler(Object Sender, System.Xml.Schema.ValidationEventArgs args) { // 11- Implement your logic for each validation iteration string strTemp = "Linea: " + Reader.LineNumber + " - Posición: " + Reader.LinePosition + " - " + args.Message; Resultado.Add(strTemp); _IsValid = false; }
/// <summary> EventHandler is called when there is an error during validation </summary> /// <param name="sender"></param> /// <param name="args"></param> private void MyValidationEventHandler(object sender, ValidationEventArgs args) { // Set the flag isValid = false; // Add this error to the building list of errors errors.AppendLine(args.Message); }
protected void OnValidate(object _, ValidationEventArgs vae) { var offset = textArea.Document.PositionToOffset(new TextLocation(vae.Exception.LinePosition-1,vae.Exception.LineNumber-1)); var mk = new TextMarker(offset, GetWordLen(offset), TextMarkerType.WaveLine, vae.Severity == XmlSeverityType.Error ? Color.DarkBlue : Color.Green); mk.ToolTip = vae.Message; textArea.Document.MarkerStrategy.AddMarker(mk); }
static private void xmlValidationEventHandler(object sender, ValidationEventArgs e) { // TODO(Ligh): Do more with the error here. Debug.WriteLine($"ERROR: {e.Message}"); throw new System.Exception($"Xml validation error: {e.Message}"); }
private void ValidationCallBack(object sender, ValidationEventArgs args) { isValid = false; if (sb.Length > 0) sb.Append("<br/>"); if (args.Severity == XmlSeverityType.Warning) sb.Append("Warning: Matching schema not found. No validation occurred." + args.Message); else sb.AppendLine("Validation error: " + args.Message); }
private static void ValidationHandler(object sender, ValidationEventArgs e) { AddXmlValidationMessage(OtaUtils.GetCurrentEditorFileName(), e.Message, e.Severity, e.Exception.LineNumber, e.Exception.LinePosition); }
// Display any validation errors. private void XmlSchema_ValidationCallBack(object sender, System.Xml.Schema.ValidationEventArgs e) { if (e.Exception != null) { ProcessException(e.Exception); } //Console.WriteLine(" Validation Error: {0}" & vbCrLf, e.Message) }
// Display any warnings or errors. private static void ValidationCallBack(object sender, ValidationEventArgs args) { if (args.Severity == XmlSeverityType.Warning) Console.WriteLine("\tWarning: Matching schema not found. No validation occurred." + args.Message); else Console.WriteLine("\tValidation error: " + args.Message); }
private void Xml_ValidationEventHandler(object sender, ValidationEventArgs e) { switch (e.Severity) { case XmlSeverityType.Error: TheSchemaErrors.Add(e.Message); break; case XmlSeverityType.Warning: TheSchemaWarnings.Add(e.Message); break; } }
private void SchemaValidationEventHandler(object sender, ValidationEventArgs e) { if(e.Severity == XmlSeverityType.Error || e.Severity == XmlSeverityType.Warning ) { _logProxy.LogThis(MessageImportance.High, e.Severity + " " + e.Message); isCorrectXml = false; } }
private static ArrayList list = new ArrayList(); // strings #endregion Fields #region Methods public static void MyValidationEventHandler(object sender, ValidationEventArgs args) { if (args.Severity == XmlSeverityType.Error) { isValid = false; } list.Add(args.Severity + ": " + args.Message); }
private static void xmlSettingsValidationEventHandler(object sender, ValidationEventArgs e) { if (e.Severity == XmlSeverityType.Warning) ErroValidadorXML += "Cuidado: \n" + e.Message + "\n"; else if (e.Severity == XmlSeverityType.Error) ErroValidadorXML += "ERRO: \n" + e.Message + "\n"; else ErroValidadorXML += "ERRO: \n" + e.Message + "\n"; }
static void schemaValidationEventHandler(object sender, ValidationEventArgs e) { if(e.Severity == XmlSeverityType.Warning) { Console.Write("WARNING: "); Console.WriteLine(e.Message); } else if(e.Severity == XmlSeverityType.Error) { Console.Write("ERROR: "); Console.WriteLine(e.Message); } }
private void ValidationCallBack( object sender, ValidationEventArgs e ) { if( e.Severity == XmlSeverityType.Error ) m_ErrCount++; else m_WarnCount++; MESSAGE( String.Format( "{0}: {1}", e.Severity, e.Message ) ); }
private static void Handler(object sender, ValidationEventArgs e) { isValid = false; if (e.Severity == XmlSeverityType.Error || e.Severity == XmlSeverityType.Warning) System.Diagnostics.Trace.WriteLine( String.Format("Line: {0}, Position: {1} \"{2}\"", e.Exception.LineNumber, e.Exception.LinePosition, e.Exception.Message)); }
/// <summary> /// Se der um erro na validação do schema, esse evento é disparado /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Reader_ValidationEventHandler(object sender, ValidationEventArgs e) { // Como sera exibida a mensagem de ERROS de validacao validarResultado = validarResultado + String.Format("\rLinha:{1}" + Environment.NewLine + "\rColuna:{0}" + Environment.NewLine + "\rErro:{2}" + Environment.NewLine, e.Exception.LinePosition, e.Exception.LineNumber, e.Exception.Message); }
public void ValidationHandler(object sender, ValidationEventArgs args) { if (args.Severity == XmlSeverityType.Error) this._ValidationErrorCount++; else this._ValidationWarningCount++; this.lbSchemaErrors.Items.Add(string.Format("{0}: {1} ({2}, {3})", args.Severity, args.Message, args.Exception.LineNumber, args.Exception.LinePosition)); }
public void HandleValidationError(object sender, System.Xml.Schema.ValidationEventArgs ve) { if (ve.Severity == XmlSeverityType.Error || ve.Severity == XmlSeverityType.Warning) { validationErrorList.Add(new ValidationError() { errorMessage = ve.Exception.Message }); } }
public void ValidationEventHandler (object sender, ValidationEventArgs e) { switch (e.Severity) { case XmlSeverityType.Error: HasError = true; break; case XmlSeverityType.Warning: HasWarning = true; break; } }
private static void ValidationCallBack(object sender, System.Xml.Schema.ValidationEventArgs args) { if (args.Severity == XmlSeverityType.Warning) { _xmlSchemaValidationErrors.Add($"Warning: Matching schema not found. No validations occurred. {args.Message}"); } else { _xmlSchemaValidationErrors.Add(args.Message); } }
/// <summary> /// Event handler that is raised when XML doesn't validate against the schema. /// </summary> /// <param name="sender">sender of the event</param> /// <param name="e">event arguments</param> void settings_ValidationEventHandler(object sender, System.Xml.Schema.ValidationEventArgs e) { if (e.Severity == XmlSeverityType.Warning) { Debug.LogWarning("The following validation warning occurred: " + e.Message); } else if (e.Severity == XmlSeverityType.Error) { Debug.LogError("The following critical validation errors occurred: " + e.Message); } }
private void Handler(object sender, ValidationEventArgs e) { if (e.Severity == XmlSeverityType.Error || e.Severity == XmlSeverityType.Warning) { System.Console.WriteLine(String.Format("Line: {0}, Position: {1} '{2}'", e.Exception.LineNumber, e.Exception.LinePosition, e.Exception.Message)); is_success_ = false; } }
public void SchemaValidationEventHandler(object sender, ValidationEventArgs e) { if (e.Severity == XmlSeverityType.Error) { this.validationErrors.Add(e.Message); } else { this.validationWarnings.Add(e.Message); } }
//************************************************************************************ // // Event handler that is raised when XML doesn't validate against the schema. // //************************************************************************************ private void settings_ValidationEventHandler(object sender, System.Xml.Schema.ValidationEventArgs e) { if (e.Severity == XmlSeverityType.Warning) { System.Windows.Forms.MessageBox.Show("The following validation warning occurred: " + e.Message); } else if (e.Severity == XmlSeverityType.Error) { System.Windows.Forms.MessageBox.Show("The following critical validation errors occurred: " + e.Message); Type objectType = sender.GetType(); } }
protected void Settings_ValidationEventHandler(object sender, System.Xml.Schema.ValidationEventArgs e) { if (e.Severity == XmlSeverityType.Warning) { _messages.Add(String.Concat(XmlSeverityType.Warning.ToString(), ":", e.Message)); } else if (e.Severity == XmlSeverityType.Error) { _messages.Add(String.Concat(XmlSeverityType.Error.ToString(), ":", e.Message)); _isvalid = false; } }
static void booksSettingsValidationEventHandler(object sender, System.Xml.Schema.ValidationEventArgs e) { if (e.Severity == System.Xml.Schema.XmlSeverityType.Warning) { Console.Write("WARNING: "); Console.WriteLine(e.Message); } else if (e.Severity == System.Xml.Schema.XmlSeverityType.Error) { Console.Write("ERROR: "); Console.WriteLine(e.Message); } }
static void ValidationEventHandler(object sender, System.Xml.Schema.ValidationEventArgs args) { if (args.Severity == XmlSeverityType.Warning) { Console.Write("\nWARNING: "); } else if (args.Severity == XmlSeverityType.Error) { Console.Write("\nERROR: "); } Console.WriteLine(args.Message); }
/// <summary> /// Event Handler for XSD Validation. /// </summary> /// <param name="sender">sender object.</param> /// <param name="e">Validation event Arguments.</param> private static void xmlRSettings_ValidationEventHandler(object sender, System.Xml.Schema.ValidationEventArgs e) { switch (e.Severity) { case System.Xml.Schema.XmlSeverityType.Error: { if (e.Exception is XmlSchemaValidationException) { throw e.Exception; } break; } } }
//************************************************************************************ // // Event handler that is raised when XML doesn't validate against the schema. // //************************************************************************************ void settings_ValidationEventHandler(object sender, System.Xml.Schema.ValidationEventArgs e) { if (e.Severity == XmlSeverityType.Warning) { Console.WriteLine ("The following validation warning occurred: " + e.Message); } else if (e.Severity == XmlSeverityType.Error) { Console.WriteLine ("The following critical validation errors occurred: " + e.Message); Type objectType = sender.GetType(); } }
/// <summary> /// Called by the validating reader when the schema is xsd invalid /// </summary> /// <param name="sender">the validating reader</param> /// <param name="e">information about the validation error</param> internal void OnSchemaValidationEvent(object sender, System.Xml.Schema.ValidationEventArgs e) { Debug.Assert(e != null); XmlReader reader = sender as XmlReader; if (reader != null && !IsValidateableXmlNamespace(reader.NamespaceURI, reader.NodeType == XmlNodeType.Attribute)) { //For V1 Schemas, we never returned errors for elements in custom namespaces. //But the behavior is not totally correct since the error might have occured inside a known namespace //even though the element that the reader pointing to is in a custom namespace. But if we fix that, it would //cause lot of breaking changes for V1 customers since we can not change the xsd for them. //For attributes, we can ignore the errors always since attributes are unordered and custom attributes should always be allowed. if ((this.SchemaVersion == XmlConstants.EdmVersionForV1) || (this.SchemaVersion == XmlConstants.EdmVersionForV1_1)) { return; } // For V2 Schemas that have custom namespaces, the only thing we would not catch are warnings. //We also need to ignore any errors reported on custom namespace since they would become annotations. Debug.Assert(this.SchemaVersion >= XmlConstants.EdmVersionForV2 || SchemaVersion == XmlConstants.UndefinedVersion, "Have you added a new Edm Version?"); if ((reader.NodeType == XmlNodeType.Attribute) || (e.Severity == System.Xml.Schema.XmlSeverityType.Warning)) { return; } } //Ignore the warnings for attributes in V2 since we would see warnings for undeclared attributes in empty namespace //that are on elements in custom namespace. For undeclared attributes in known namespace, we would see errors. if ((this.SchemaVersion >= XmlConstants.EdmVersionForV2) && (reader.NodeType == XmlNodeType.Attribute) && (e.Severity == System.Xml.Schema.XmlSeverityType.Warning)) { return; } EdmSchemaErrorSeverity severity = EdmSchemaErrorSeverity.Error; if (e.Severity == System.Xml.Schema.XmlSeverityType.Warning) { severity = EdmSchemaErrorSeverity.Warning; } AddError(ErrorCode.XmlError, severity, e.Exception.LineNumber, e.Exception.LinePosition, e.Message); }
// the handler for xml validation events static void ValidationEventHandler(object sender, System.Xml.Schema.ValidationEventArgs e) { string errorMsg = string.Empty; if (e.Exception.GetType() == typeof(XmlSchemaValidationException)) { XmlSchemaValidationException inex = (XmlSchemaValidationException)e.Exception; XmlElement el = (XmlElement)inex.SourceObject; if (e.Message.Contains("duplicate key sequence") && ((XmlDocument2)el.OwnerDocument).UniqueNodeValues == false) { return; } // Check if we have any existing validation errors ArrayList existingErrors = ((XmlDocument2)el.OwnerDocument).ValidationErrors; switch (e.Severity) { case System.Xml.Schema.XmlSeverityType.Error: case System.Xml.Schema.XmlSeverityType.Warning: { if (existingErrors.Count > 0) { PostResult existingResult = (PostResult)existingErrors[0]; existingResult.AdditionalInfo = String.Format("{0}\r\n{1}", existingResult.AdditionalInfo, e.Message); ((XmlDocument2)el.OwnerDocument).ValidationErrors.RemoveAt(0); ((XmlDocument2)el.OwnerDocument).ValidationErrors.Add(existingResult); } else { errorMsg = String.Format("XML Schema validation error(s):\r\n{0}", e.Message); ((XmlDocument2)el.OwnerDocument).ValidationErrors.Add(new PostResult(null, null, false, true, errorMsg, STATUS_CODES.XML_INVALID_AGAINST_SCHEMA, null)); } break; } } } else { return; } }
/// <summary> /// Handler method for validation errors. Throws an exception when an error is encountered /// </summary> /// <param name="sender">Sender of the validation event</param> /// <param name="args">Validation error arguments</param> private static void ValidationHandler(object sender, System.Xml.Schema.ValidationEventArgs args) { switch (args.Severity) { case System.Xml.Schema.XmlSeverityType.Error: XmlSchemaException xmlSchemaException = args.Exception as XmlSchemaException; if (xmlSchemaException != null) { throw new InvalidOperationException("'" + xmlSchemaException.Message + "' at line " + xmlSchemaException.LineNumber + " position " + xmlSchemaException.LinePosition); } else { throw new InvalidOperationException("'" + args.Message + "'"); } case System.Xml.Schema.XmlSeverityType.Warning: if (args.Message == "No DTD found.") // Unfortunately there does not seem to be a typed exception for not having a DTD, so need to test the message :-( { throw new InvalidOperationException("'" + args.Message + "'"); } // Else: Do nothing break; } }
private static void settings_ValidationEventHandler(object sender, System.Xml.Schema.ValidationEventArgs e) { //throw new NotImplementedException(); }
/// <summary> /// Logs information on XML schema errors /// </summary> static void settings_ValidationEventHandler(object sender, System.Xml.Schema.ValidationEventArgs e) { Debug.WriteLine(e.Message); errorCount++; }
private void ValidationCallBack(object sender, System.Xml.Schema.ValidationEventArgs e) { ValidationErrors.Add(new XmlValidationError(e.Message, e.Exception.LineNumber, e.Exception.LinePosition, e.Severity, 201)); }
void r_ValidationEventHandler(object sender, System.Xml.Schema.ValidationEventArgs e) { MessageBox.Show(e.Message); }
void settings_ValidationEventHandler(object sender, System.Xml.Schema.ValidationEventArgs e) { throw new InvalidArgumentException(e.Message); }
void ValidationEventHandler(object sender, sch.ValidationEventArgs args) { }
void OnValidationEvent(object sender, System.Xml.Schema.ValidationEventArgs e) { // todo: log errors in error list window. }
void validationEventHandler(object sender, System.Xml.Schema.ValidationEventArgs e) { XmlSchemaValidationException ex = (XmlSchemaValidationException)e.Exception; m_Errors.Add(ex); }
private void ValidationEventHandler(object sender, Schema.ValidationEventArgs args) { }
/// <summary> /// There is a problem with the xsd /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void rdrSettings_ValidationEventHandlerSchema(object sender, System.Xml.Schema.ValidationEventArgs e) { fValidationResult.AppendLine(e.Message); }
private void ValidatingReader_ValidationEventHandler(object sender, System.Xml.Schema.ValidationEventArgs e) { throw new Exception(e.Message); }