static private RegisterWellknownNamespaceParserType ( string namespaceUri ) : bool | ||
namespaceUri | string | |
return | bool |
/// <summary> /// Validation callback for a validating XML reader. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="args">Any data pertinent to the event.</param> private void HandleValidation(object sender, ValidationEventArgs args) { if (args.Severity == XmlSeverityType.Error) { XmlSchemaException ex = args.Exception; XmlReader xmlReader = (XmlReader)sender; if (!NamespaceParserRegistry.GetSchemas().Contains(xmlReader.NamespaceURI) && ex is XmlSchemaValidationException) { // try wellknown parsers bool registered = NamespaceParserRegistry.RegisterWellknownNamespaceParserType(xmlReader.NamespaceURI); if (registered) { throw new RetryParseException(); } } throw ex; } else { #region Instrumentation if (log.IsWarnEnabled) { log.Warn( "Ignored XML validation warning: " + args.Message, args.Exception); } #endregion } }
/// <summary> /// Validation callback for a validating XML reader. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="args">Any data pertinent to the event.</param> private void HandleValidation(object sender, ValidationEventArgs args) { if (args.Severity == XmlSeverityType.Error) { XmlSchemaException ex = args.Exception; XmlReader xmlReader = (XmlReader)sender; if (!NamespaceParserRegistry.GetSchemas().Contains(xmlReader.NamespaceURI) #if NET_2_0 && ex is XmlSchemaValidationException #endif ) { // try wellknown parsers bool registered = NamespaceParserRegistry.RegisterWellknownNamespaceParserType(xmlReader.NamespaceURI); if (registered) { throw new RetryParseException(); } } #if !NET_2_0 // ignore validation errors for well-known 'xml' namespace. This seems to be a bug in net 1.0 + 1.1 if (ex.Message.IndexOf("http://www.w3.org/XML/1998/namespace:") > -1) { return; } #endif throw ex; } else { #region Instrumentation if (log.IsWarnEnabled) { log.Warn( "Ignored XML validation warning: " + args.Message, args.Exception); } #endregion } }