New XML Validator class for Xojo

  1. 7 months ago

    Christian S

    19 May 2019 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany
    Edited 7 months ago

    For next MBS Xojo Plugins version we added a new class to validate XML text. Our XMLValidatorMBS class can take a XML scheme as text to initialize the validator. Then you can either validate a file or XML text in memory. With files, if you set the working directory to the right folder, we can even find references files int he XML or the schema text.

    For error and warning messages, we provide them directly via Error and Warning events. We also collect them in an Messages array, which can be useful to check for errors later after validation.

    The messages are in XMLValidatorMessageMBS objects, so we can provide the message and metadata like a line number and file name, if possible. Line numbers seem to be correct if you use Unix line endings. For Mac line endings, you get always line 1. So a call to ReplaceLineEndings(XML, endOfLine.Unix) may be useful.

    To implement this class, we relay on libxml2 and the validator functions there. As Xojo has built-in XML classes, we have no need to reimplement all of that, but the validation was missing for a client.

  2. Eduardo G

    19 May 2019 Pre-Release Testers Europe (Madrid, Spain)
    Edited 7 months ago

    This sounds nice. I'm about to enter into a project that deals heavily with producing and consuming XML (the SAF-T regulation of Portugal for reporting to the tax authorities) and it might come in handy.

    I had assumed the built-in XML classes but we continuously keep hitting issues with data received from multiple sources due to faulty XML implementations. Troubleshooting is cumbersome right now. I'll take a look when I have a minute.

or Sign Up to reply!