• The 'http://www.w3.org/XML/1998/namespace:lang' attribute is not de

    From oussbkik2@gmail.com@21:1/5 to All on Tue Jun 11 03:51:50 2019
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Peter Flynn@21:1/5 to oussbkik2@gmail.com on Sun Jul 21 19:53:34 2019
    On 11/06/2019 11:51, oussbkik2@gmail.com wrote:
    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?

    The Schema would seem to be defective: it does not contain a declaration
    for the "lang" attribute (on some unidentified element).

    But that error message looks odd. I don't know why it's mentioning that
    URI instead of the one related to the element type where the error
    occurred.

    2. How can I resolve?

    Whatever validator you are using (you don't say) does not identify
    *which* element type is in error.

    Open the file in an XML editor and click on the Validate button. That
    should either jump the cursor to the location of the error, or at least
    give you a line number or path to the location.


    I got the schema definition from a third party (ACORD).

    They would be the people to ask.

    I tried to do this using two different methods:

    This looks like a steamroller to crack a nut. Can you just run a
    standalone validator that reports properly on the error?

    I know the above code samples works since I tried them on a simple
    example (XML, Schema). Plus I stole them from a book.

    They may work, but they don't seem to provide any useful information.

    Peter

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)