Groups | Search | Server Info | Login | Register
| Newsgroups | comp.text.xml |
|---|---|
| Date | 2019-06-11 03:51 -0700 |
| References | <fb9a442a-cc34-4880-a1e4-c72bf6f7acfc@c36g2000yqn.googlegroups.com> |
| Message-ID | <3836d83f-35cb-4358-aeed-18968ea497de@googlegroups.com> (permalink) |
| Subject | Re: The 'http://www.w3.org/XML/1998/namespace:lang' attribute is not declared Error |
| From | oussbkik2@gmail.com |
Le vendredi 17 avril 2009 16:00:00 UTC, Candle a écrit :
> I get the following error when I try to validate XML against a
> schema:
> The 'http://www.w3.org/XML/1998/namespace:lang' attribute is not
> declared
>
> My questions are:
> 1. Why I am I getting this error?
> 2. How can I resolve?
>
> I got the schema definition from a third party (ACORD).
>
> I tried to do this using two different methods:
>
> Method 1 – Using a LINQ XDoc (preferred way)
>
> Private Function ValidXsd(ByVal AcordXml As String) As Boolean
>
> Dim schemas As New XmlSchemaSet()
> Dim returnVal As Boolean
>
> schemas.Add(Nothing, XmlReader.Create(Server.MapPath("Includes
> \acord-pcs-v1_15_1-ns-nodoc-codes.xsd")))
>
> Dim xDocAcordXml = XDocument.Load(New StringReader(AcordXml))
>
> xDocAcordXml.Validate(schemas, AddressOf
> ValidationEventHandler, True)
>
> If SchemaValidationResults.Count = 0 Then
> returnVal = True
> Else
> 'Populate AcordXml with values in SchemaValidationResults
> End If
>
> Return returnVal
>
> End Function
>
> Sub ValidationEventHandler(ByVal sender As Object, ByVal e As
> System.Xml.Schema.ValidationEventArgs)
>
> SchemaValidationResults.Add(e.Severity & ": " & e.Message)
>
> End Sub
>
> Method 2 – Using a XmlReader
>
> Private Function ValidXsd2(ByVal AcordXml As String) As Boolean
>
> Dim settings As New XmlReaderSettings()
> Dim returnVal As Boolean
>
> settings.Schemas.Add(Nothing, XmlReader.Create(Server.MapPath
> ("Includes\acord-pcs-v1_15_1-ns-nodoc-codes.xsd")))
>
> settings.ValidationType = ValidationType.Schema
> settings.ValidationFlags =
> XmlSchemaValidationFlags.ReportValidationWarnings
>
> AddHandler settings.ValidationEventHandler, AddressOf
> settings_ValidationEventHandler
>
> settings.IgnoreWhitespace = True
> settings.IgnoreComments = True
>
> Using reader As XmlReader = XmlReader.Create(New StringReader
> (AcordXml), settings)
> While (reader.Read())
> 'Empty loop
> End While
> End Using
>
> If SchemaValidationResults.Count = 0 Then
> returnVal = True
> Else
> 'Populate AcordXml with values in SchemaValidationResults
> End If
>
> Return returnVal
>
>
> End Function
>
> ' Display any warnings or errors.
> Private Sub settings_ValidationEventHandler(ByVal sender As Object,
> ByVal e As System.Xml.Schema.ValidationEventArgs)
>
> SchemaValidationResults.Add(e.Severity & ": " & e.Message)
>
> End Sub
>
> I know the above code samples works since I tried them on a simple
> example (XML, Schema). Plus I stole them from a book.
>
> Any advice would be much appreciated.
>
> Regards,
>
> R
Back to comp.text.xml | Previous | Next — Next in thread | Find similar
Re: The 'http://www.w3.org/XML/1998/namespace:lang' attribute is not declared Error oussbkik2@gmail.com - 2019-06-11 03:51 -0700 Re: The 'http://www.w3.org/XML/1998/namespace:lang' attribute is not declared Error Peter Flynn <peter@silmaril.ie> - 2019-07-21 19:53 +0100
csiph-web