Perl XML and DTD Validate Primer Tutorial

Perl XML and DTD Validate Primer Tutorial

Perl XML and DTD Validate Primer Tutorial

The XML Validation subject area is quite complex. The reason for this is that when there is intelligence in your data, as XML often has, it can be organized in a variety of ways. One approach with XML data is to oversee its integrity with the use of DTD schemas, which is like a blueprint for your XML data, outlining how it should be structured to pass validation checks. If you know your XML data passes the validation tests implied by the DTD then you are likely to have a very successful project, if the DTD has been structured methodically and has enough flexibility to express all the complication needed to satisfy business logic requirements.

Perl has functionality to help with validating XML in a variety of different scenarios, as do other languages such as PHP, Python (the three P’s ride again!) and Java, for example. Here for this tutorial there were two huge contributions from:

  • the Eclipse IDE XML examples provided ( the same as used in yesterday of yesterday to yesterday’s tutorial Java Eclipse XML and DTD Validate Primer Tutorial )
  • very good tutorial here where only the input file name arrangement was changed to be hardcoded (being as $ARGV[1] didn’t work for me … boo hoo) in download code presented below

In this primer tutorial you can see some Perl XML and DTD validation program in action on a Mac laptop using a cpan install of Perl modules XML::Checker and XML::Parser. With the tutorial there was trouble passing command line arguments, otherwise the code downloadable below would have mentioned $ARGV[1] as the input file in a scenario like perl xmldtdvalidate.pl Invoice.xml

Link to downloadable Perl programming source code for XML and DTD validation xmldtdvalidate.pl

Link to (all but top line of) sample DTD data Invoice.dtd (curiously did not validate until the <?xml version=”1.0″ encoding=”UTF-8″?> top line was omitted)

Link to sample XML data Invoice.xml

If this was interesting you may be interested in this too.

This entry was posted in eLearning, Tutorials and tagged , , , , , , . Bookmark the permalink.

One Response to Perl XML and DTD Validate Primer Tutorial

  1. I’m really enjoying the theme/design of your site. Do you ever run into any web browser compatibility issues? A number of my blog audience have complained about my website not working correctly in Explorer but looks great in Opera. Do you have any tips to help fix this problem?|

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>