You are viewing a plain text version of this content. The canonical link for it is here.
Posted to p-dev@xerces.apache.org by Frank Ehrenfried <fr...@overture.com> on 2001/10/08 22:58:42 UTC

Validating an XML document using XSchema

Can anybody inform me how to use Xerces to validate an XML document versus
an XSchema document. For example, in the "samples" sub-directory there
exists an XML document called "personal-schema.xml".  When I invoke
DOMCount.pl with the option "v=always", I get the following error message:

MESSAGE: Unknown element 'personnel'.

Thanks in advance,
Frank B. Ehrenfried

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org


Re: Validating an XML document using XSchema

Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"Frank Ehrenfried" <fr...@overture.com> writes:

> Can anybody inform me how to use Xerces to validate an XML document versus
> an XSchema document. For example, in the "samples" sub-directory there
> exists an XML document called "personal-schema.xml".  When I invoke
> DOMCount.pl with the option "v=always", I get the following error message:
> 
> MESSAGE: Unknown element 'personnel'.

Sorry, the usage output was being blocked. Typing the command without
any arguments should have printed the following information:

$ perl ./samples/DOMCount.pl
USAGE: ./samples/DOMCount.pl [-v=xxx][-n] file
Options:
    -v=xxx      Validation scheme [always | never | auto*]
    -n          Enable namespace processing. Defaults to off.
    -s          Enable schema processing. Defaults to off.

  * = Default if not provided explicitly

Schema usage with Xerces is rather odd (I think):
1) You cannot use -v as this applies to the DOCTYPE, and with schemas
   you are not likely to use a DOCTYPE
2) You must enable namespace parsing, otherwise none of the
   schema-specific attributes will be recognized

So...

$ perl samples/DOMCount.pl -n -s samples/personal-schema.xml 
samples/personal-schema.xml: (37 elems)
samples/personal-schema.xml: duration:  1 wallclock secs ( 0.07 usr +  0.00 sys =  0.07 CPU)

I will point out that if you are only looking for tools that will help
validate you XML files, you have no need for Xerces.pm, you can just
use the samples that come with Xerces-C. If, on the other hand, you're
going to develop your own Perl applications, I think Xerces.pm will
come in handy.

HTH,
jas.

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org