Validating parsers

Apart from the built-in DTD support in parsers, lxml currently supports three schema languages: DTD, Relax NG and XML Schema.All three provide identical APIs in lxml, represented by validator classes with the obvious names.

XML schema is supported in a similar way, but requires an explicit schema to be provided: As described above, the parser support for DTDs depends on internal or external subsets of the XML file.

This means that the XML file itself must either contain a DTD or must reference a DTD to make this work.

The following JScript® code loads and parses the xml document at the specified url.

stands for, or indeed whether that entity reference is even properly defined.

An HTML page can therefore include, among other things, specific data about the subject of the page.

For example, if the page displayed an advertisement for an author's most recent novel, the page can also contain XML data concerning that book, such as its ISBN number, publisher, or suggested retail price.

Simply click on the "Validate" button (the green checkmark in the preceding illustration), specify which validator you want to use, and Stylus Studio® displays the results in the Status window.

Stylus Studio®'s Open XML Parsing & XML Validation Architecture and production environment is a critical component in a world-class XML editor, one that can make the difference between a project's success and its failure. As you can see from the following illustration, it's quite simple to add others using Stylus Studio®'s Custom Validation Engines feature. Engineers from over 100,000 leading companies use Stylus Studio, and now you can ask someone from your own organization about their experiences using Stylus Studio.

Historically, various programs have attempted to deal with this problem by using nonstandard tricks, such as hiding data inside HTML comments.

However, these comments are awkward and, unlike XML, are not exposed to the object model.

lxml also provides support for ISO-Schematron, based on the pure-XSLT skeleton implementation of Schematron: There is also basic support for The parser in lxml can do on-the-fly validation of a document against a DTD or an XML schema.

Comments are closed.