MYOML #9: Validation and Conclusion

The custom markup language has been designed to have a certain structure. That is, there is supposed to be one <article> tag, followed by a <section> container, followed by a <text> container. The CSS stylesheet has been designed with this in mind. However, nothing actually enforces this structure. There is nothing stopping you from writing an article with arbitrary tag structure (or even using undefined tags). There are two problems with this:

  1. Both the XSLT and CSS stylesheets were designed with a certain nesting order in mind, and allowing a different structure risks having a document that doesn't look quite right when displayed.
  2. Not having a consistent structure makes it hard or even impossible to write an XML query tool for indexing articles, etc., since there is no fixed structure to parse.

For these reasons, it is desirable to have a tool automatically check the XML document for correct structure while processing. This eliminates the chance of having a badly formatted document slip through unnoticed.

The correct way to do it is to create a Document Type Definition (DTD) that an XML-checking tool can use to validate the document structure.

In the final installment of Make Your Own Markup Language, a DTD is added to automatically check for errors in the articles. The PHP script is tweaked a little to make it more generic.

Issue #9: Validation and Conclusion

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.