XML::Xerces Sample: DOM Validator
Sample: DOM Validator
DOM Validator
DOM Validator is a simple application that parses an XML input file using a DOM parser and reports validation errors to STDERR in the same format as onsgmls so that it can be used for example in Emacs locating the errors in the source file.
Running DOM Validator
The DOM Validator sample parses an XML file and prints any errors to STDERR. To run DOM Validator, enter the following
perl validator-dom.pl <XML File>
The following parameters may be set from the command line
Usage: perl validator-dom.pl [options] This program invokes the DOM Parser, and then prints any errors to STDERR. required flags: --file=file_name : the XML file to parse optional parameters: --namespace : enable namespace checking --schema : parse a W3C XML Schema file (forces --namespace) --full_schema : do full schema checking (forces --namespace and --schema) --help : print this message
Here is a sample output from DOM Validator
cd samples perl validator-dom.pl --file=personal-invalid.xml validator-dom.pl:[/home/jasons/work/xml-xerces/samples/personal-invalid.xml]:19:8:E:Unknown element 'fool' validator-dom.pl:[/home/jasons/work/xml-xerces/samples/personal-invalid.xml]:19:12:E:Attribute 'id' is not declared for element 'fool' validator-dom.pl:[/home/jasons/work/xml-xerces/samples/personal-invalid.xml]:43:13:E:Element 'fool' is not valid for content model: '(person)+' validator-dom.pl:[/home/jasons/work/xml-xerces/samples/personal-invalid.xml]:43:13:E:ID attribute 'two.worker' was referenced but never declared