Validate XML with XSD schema

Xbase++ 2.0 Build 554 or later
Post Reply
Message
Author
Piotr D
Posts: 110
Joined: Mon Jul 28, 2014 1:26 am
Location: Poznań, Poland

Validate XML with XSD schema

#1 Post 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

Diego Euri Almanzar
Posts: 114
Joined: Thu Nov 05, 2020 10:51 am
Location: DOMINICAN REPUBLIC

Re: Validate XML with XSD schema

#2 Post 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/]

Piotr D
Posts: 110
Joined: Mon Jul 28, 2014 1:26 am
Location: Poznań, Poland

Re: Validate XML with XSD schema

#3 Post 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

Diego Euri Almanzar
Posts: 114
Joined: Thu Nov 05, 2020 10:51 am
Location: DOMINICAN REPUBLIC

Re: Validate XML with XSD schema

#4 Post 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.

k-insis
Posts: 45
Joined: Fri Jan 28, 2011 4:07 am

Re: Validate XML with XSD schema

#5 Post 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.

Koverhage
Posts: 140
Joined: Mon Feb 01, 2010 8:45 am

Re: Validate XML with XSD schema

#6 Post by Koverhage »

Klaus

Post Reply