apache > xerces > xerces-p
XML::Xerces
 

XML::Xerces Sample: Validator

Sample: Validator

Validator

Validator is a simple application that parses an XML input file 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 Validator

The Validator sample parses an XML file and prints any errors to STDERR. To run Validator, enter the following

perl validator.pl <XML File>

The following parameters may be set from the command line

Usage:
    perl validator.pl [options]

This program invokes the SAX Parser, and then prints any errors to
STDERR using SAX API.

  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 Validator

cd samples
perl validator.pl --file=personal-invalid.xml
validator.pl:[/home/jasons/work/xml-xerces/samples/personal-invalid.xml]:19:8:E:Unknown element 'fool'
validator.pl:[/home/jasons/work/xml-xerces/samples/personal-invalid.xml]:19:12:E:Attribute 'id' is not declared for element 'fool'
validator.pl:[/home/jasons/work/xml-xerces/samples/personal-invalid.xml]:43:13:E:Element 'fool' is not valid for content model: '(person)+'
validator.pl:[/home/jasons/work/xml-xerces/samples/personal-invalid.xml]:43:13:E:ID attribute 'two.worker' was referenced but never declared