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 Lev Lvovsky <li...@sonous.com> on 2007/03/06 01:46:27 UTC
validating against a Schema
Hello, I'm looking to validate an xml document against a vendor
provided Schema definition, and am running into some inexplicable
problems. I've a really simple implementation for testing as follows:
------
#!/usr/bin/perl -w
use strict;
use XML::Xerces qw(error);
XML::Xerces::XMLPlatformUtils::Initialize();
my $parser = new XML::Xerces::XercesDOMParser;
my $error_handler = new XML::Xerces::PerlErrorHandler;
$parser->setErrorHandler($error_handler);
$parser->setDoNamespaces(1);
$parser->setDoSchema(1);
$parser->setExternalNoNamespaceSchemaLocation('test.xsd');
#$parser->setExternalSchemaLocation('test.xsd');
$parser->parse('some.xml');
------
running the code using no namespaces, I simply get the following
warning at the last tag of the XML file.
"MESSAGE: Attribute 'xmlns' has already been declared for element
'schema'"
running the code using namespaces (which seem to be provided in the
xml file), I get the following error:
"MESSAGE: The schemaLocation attribute does not contain pairs of
values."
This *seems* erroneous, as the schemaLocation attribute does contain
a pair of values...
In the end, even when specifying no namespaces, modification of the
xsd file which should break the validation has no effect. Changing
the target XML file has no effect either. If anyone can suggest any
pointers or docs to read, it would be greatly appreciated!
thanks!
-lev
---------------------------------------------------------------------
To unsubscribe, e-mail: p-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: p-dev-help@xerces.apache.org
RE: validating against a Schema
Posted by "Garrett, Philip (MAN-Corporate)" <Ph...@manheim.com>.
Sorry, I don't know what's causing your problem. I have attached a perl
script I wrote to do validation like this -- maybe it will help. I run
it on Xerces 2.6.0_2.
Lev Lvovsky wrote:
> Hello, I'm looking to validate an xml document against a vendor
> provided Schema definition, and am running into some inexplicable
> problems. I've a really simple implementation for testing as follows:
>
> ------
> #!/usr/bin/perl -w
>
> use strict;
> use XML::Xerces qw(error);
>
> XML::Xerces::XMLPlatformUtils::Initialize();
>
> my $parser = new XML::Xerces::XercesDOMParser;
> my $error_handler = new XML::Xerces::PerlErrorHandler;
> $parser->setErrorHandler($error_handler);
>
> $parser->setDoNamespaces(1);
> $parser->setDoSchema(1);
>
> $parser->setExternalNoNamespaceSchemaLocation('test.xsd');
> #$parser->setExternalSchemaLocation('test.xsd');
> $parser->parse('some.xml');
> ------
>
> running the code using no namespaces, I simply get the following
> warning at the last tag of the XML file.
>
> "MESSAGE: Attribute 'xmlns' has already been declared for element
> 'schema'"
>
> running the code using namespaces (which seem to be provided in the
> xml file), I get the following error:
>
> "MESSAGE: The schemaLocation attribute does not contain pairs of
> values."
>
> This *seems* erroneous, as the schemaLocation attribute does contain
> a pair of values...
>
> In the end, even when specifying no namespaces, modification of the
> xsd file which should break the validation has no effect. Changing
> the target XML file has no effect either. If anyone can suggest any
> pointers or docs to read, it would be greatly appreciated!
>
> thanks!
> -lev
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: p-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: p-dev-help@xerces.apache.org