Validate XML with XSD schema

Xbase++ 2.0 Build 554 or later
Message
Author
Piotr D
Posts: 129
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: 155
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: 129
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: 155
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: 94
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: 150
Joined: Mon Feb 01, 2010 8:45 am

Re: Validate XML with XSD schema

#6 Post by Koverhage »

Klaus

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

Re: Validate XML with XSD schema

#7 Post by Diego Euri Almanzar »

Excellent, Klaus, thank you very much.

Although, I would like to validate an XML via an XSD, via Xbase code. It is the only way that my work would look good, since I must do the process in my system.

Alaska Software offers many XML functions, but I haven't found one to validate yet.
Attachments
ALASKAXB.jpg
ALASKAXB.jpg (256.27 KiB) Viewed 2979 times

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Validate XML with XSD schema

#8 Post by skiman »

Hi,

This should be possible with MSXML xml parser. This is an active-x component, which can be used in Xbase++.

Search in Google for
validation xml with xsd schema vbscript
. There are some samples in VBscript, which should be rather easy to convert.
Best regards,

Chris.
www.aboservice.be

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

Re: Validate XML with XSD schema

#9 Post by Diego Euri Almanzar »

good alternative, Chris.

Thanks a lot. Although, I understand that Alaska software, in all those new functions of its library for XML, must have the solution. I did not send an email to them, because in July the subscription expired.

I thank you again.

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Validate XML with XSD schema

#10 Post by skiman »

Hi Diego,

No, the solution won't be in Xbase++.
Best regards,

Chris.
www.aboservice.be

Post Reply