Page 1 of 1

Validate XML with XSD schema

Posted: Thu Nov 12, 2020 3:52 am
by Piotr D
Hi,
Do you know any way to validate XML file with XSD schema directly in Xbase ++ program? Maybe there is some library or ActiveX?

Regards
Piotr

Re: Validate XML with XSD schema

Posted: Thu Aug 04, 2022 8:30 pm
by Diego Euri Almanzar
Hello Piotr

The topic is very interesting. Unfortunately I can't help you. I am also looking for such a solution. An XML validator with XSD. I only find examples in other languages ​​like C#, in .Net, in Visual Basic, but not Xbase++

Although it is not a solution, but I will attach an example in C# so that anyone who wants to help us can better understand what we are looking for.

Cordial greetings.

Code: Select all

 using System;
using System.Xml;
using System.Xml.Schema;

class XmlSchemaSetExample
{
    static void Main()
    {
        XmlReaderSettings booksSettings = new XmlReaderSettings();
        booksSettings.Schemas.Add("http://www.contoso.com/books", "books.xsd");
        booksSettings.ValidationType = ValidationType.Schema;
        booksSettings.ValidationEventHandler += new ValidationEventHandler(booksSettingsValidationEventHandler);

        XmlReader books = XmlReader.Create("books.xml", booksSettings);

        while (books.Read()) { }
    }

    static void booksSettingsValidationEventHandler(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);
        }
    }
}  [code/]

Re: Validate XML with XSD schema

Posted: Thu Aug 04, 2022 11:40 pm
by Piotr D
Dear Diego,
unable to find a library for Xbase to handle thisk task, I asked a friend to write a C# program. There are ready-made functions in C# to handle this task. The ready program is called by passing the XML file and the address of the XSD file as parameters. I get the validation effect back.

Piotr

Re: Validate XML with XSD schema

Posted: Fri Aug 05, 2022 2:14 am
by Diego Euri Almanzar
Dear Piotr,

I'm glad you found a solution. I use Xbase++ 2.0 and I notice that it has an XML handling library. But, I do not find anything specific to validate an XML visus XSD, this being so important today.

Maybe it does, and it has another name...

Best regards.

Re: Validate XML with XSD schema

Posted: Tue Aug 09, 2022 12:25 am
by k-insis
Sorry to be late to party, but in case there is no quick solution to get c# program there is almost always open source solution for that via command line:

Part of project libxml2 is also lint (syntax checker) for

Project:

https://gitlab.gnome.org/GNOME/libxml2/-/wikis/home

xmllint manpage:

https://gnome.pages.gitlab.gnome.org/li ... llint.html

call sample:

xmllint --schema yourxsd.xsd yourxml.xml

catch stdout and analyse it

You can get project and compile on own, or get precompiled binaries at one of mainteiners webpage

https://www.zlatkovic.com/pub/libxml/


Diego Euri Almanzar wrote: Fri Aug 05, 2022 2:14 am Dear Piotr,

I'm glad you found a solution. I use Xbase++ 2.0 and I notice that it has an XML handling library. But, I do not find anything specific to validate an XML visus XSD, this being so important today.

Maybe it does, and it has another name...

Best regards.

Re: Validate XML with XSD schema

Posted: Tue Aug 09, 2022 5:41 am
by Koverhage