Page 1 of 2

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

Re: Validate XML with XSD schema

Posted: Thu Aug 18, 2022 12:47 am
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.

Re: Validate XML with XSD schema

Posted: Thu Aug 18, 2022 2:02 am
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.

Re: Validate XML with XSD schema

Posted: Sat Aug 20, 2022 12:37 am
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.

Re: Validate XML with XSD schema

Posted: Mon Aug 22, 2022 12:10 am
by skiman
Hi Diego,

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