/// <summary> /// Initializes a new instance of te <see cref="SchematronValidationException"/> class with the specified /// <see cref="SchematronValidationEventArgs"/>. /// </summary> /// <param name="e"> /// A <see cref="SchematronValidationEventArgs"/> that contains the details of the schematron validation event. /// </param> public SchematronValidationException(SchematronValidationEventArgs e) : base(e.Message) { }
void OnValidationEvent(SchematronValidationEventArgs e) { if (log.IsDebugEnabled) log.Debug(String.Format("Test '{0}' fails at {1}", e.Assertion.Test, XPathHelper.FullName(e.Instance))); if (AssertionFailed != null) AssertionFailed(this, e); else throw new SchematronValidationException(e); }
void handler(object sender, SchematronValidationEventArgs e) { errors.Add(e); }
void Start(object sender, SchematronValidationEventArgs e) { report.WriteStartElement("schematron-output", Schematron.SvrlNamespace); if (e.Schematron.Title.Count > 0) report.WriteAttributeString("title", e.Schematron.Title.ToString()); if (!string.IsNullOrEmpty(e.Schematron.SchemaVersion)) report.WriteAttributeString("schemaVersion", e.Schematron.SchemaVersion); report.WriteAttributeString("phase", ((SchematronValidator)sender).ValidationPhase); if (e.Schematron.HasNamespaces) { foreach (NamespaceDefinition ns in e.Schematron.Namespaces) { report.WriteStartElement("ns-prefix-in-attribute-values", Schematron.SvrlNamespace); report.WriteAttributeString("prefix", ns.Prefix); report.WriteAttributeString("uri", ns.Uri); report.WriteEndElement(); } } }
void RuleFired(object sender, SchematronValidationEventArgs e) { report.WriteStartElement("fired-rule", Schematron.SvrlNamespace); if (!string.IsNullOrEmpty(e.Rule.ID)) report.WriteAttributeString("id", e.Rule.ID); report.WriteAttributeString("context", e.Rule.Context); if (!string.IsNullOrEmpty(e.Rule.Role)) report.WriteAttributeString("role", e.Rule.Role); if (!string.IsNullOrEmpty(e.Rule.Flag)) report.WriteAttributeString("flag", e.Rule.Flag); report.WriteEndElement(); }
void End(object sender, SchematronValidationEventArgs e) { report.WriteEndElement(); report.Flush(); if (closeStream) report.Close(); }
void AssertionFailed(object sender, SchematronValidationEventArgs e) { validationFailure = true; if (e.Assertion is Report) report.WriteStartElement("successful-report", Schematron.SvrlNamespace); else report.WriteStartElement("failed-assert", Schematron.SvrlNamespace); report.WriteAttributeString("location", XPathHelper.FullName(e.Instance)); report.WriteAttributeString("test", e.Assertion.Test); if (!string.IsNullOrEmpty(e.Assertion.Role)) report.WriteAttributeString("role", e.Assertion.Role); if (!string.IsNullOrEmpty(e.Assertion.Flag)) report.WriteAttributeString("flag", e.Assertion.Flag); // Diagnostic references if (!string.IsNullOrEmpty(e.Assertion.Diagnostics)) { string[] ids = e.Assertion.Diagnostics.Split(' '); for (int i = 0; i < ids.Length; ++i) { report.WriteStartElement("diagnostic-reference", Schematron.SvrlNamespace); report.WriteAttributeString("diagnostic", ids[i]); if (i < e.Diagnostics.Length) report.WriteElementString("text", Schematron.SvrlNamespace, e.Diagnostics[i]); report.WriteEndElement(); } } report.WriteElementString("text", Schematron.SvrlNamespace, e.Message); report.WriteEndElement(); }
void ActivePattern(object sender, SchematronValidationEventArgs e) { report.WriteStartElement("active-pattern", Schematron.SvrlNamespace); if (!string.IsNullOrEmpty(e.Pattern.ID)) report.WriteAttributeString("id", e.Pattern.ID); report.WriteAttributeString("name", e.Pattern.Title.ToString()); report.WriteEndElement(); }