« XDC 2019 | Home | MBS Xojo Plugins, ver… »

New XML Validator class for Xojo

For next Xojo plugin 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. The biggest plugin in space...
17 05 19 - 13:28