|. you may not have (a working) internet connection on that moment|
|. remote changes in the spec may break your application unexpectedly|
Besides, the content of the schemaLocation attribute to import, include and schema elements are usually broken, missing and/or flawed. You can better do it by hand.
Collect the schemas you need in a directory. The name of the schema file does not need to means anything useful. Then, add the location where the schemas are found:
Add the mapping from namespaces to filenames (you may provide an ARRAY of names or use the same namespace multiple times). It is useful to have a constant defined for your namespace.
use constant MY_NS => http://very-long;
$schema->knownNamespace(&MY_NS => schemafile.xsd);
There is also a less clean solution:
When you have many xsds to include, you may do this:
Many schemas are broken. XML::Compile is not a good tool to figure-out what is wrong with the schema. Have you tried xmllint? Sometimes, you get sufficient help adding to the top of your script:
use Log::Report mode => DEBUG;
When you know what is wrong, you can overrule parts of the schema by redefining elements; simply: the last definition for an element wins. For instance:
Of course, you can also use an external file for this.
This is a piece of code actually used. It shows various complications when an external schema is loaded dynamically into another schema.
# In the top of your script
my $schema_dir = /usr/share/schemas;
my $xyz_ns = http://www.xyzeorder.com/workflow;
my $xyz_xsd = xyzSchema.xsd;
# In the main part of your script
my $schema = XML::Compile::Cache->new(....);
$schema->importDefinitions($xyz_xsd, target_namespace => $xyz_ns);
$schema->addPrefixes(xyz => $xyz_ns);
The schema forgets to mention its targetNamespace, so it is overruled. The ::Cache extension handles prefixes much nicer than the ::Schema base object. So, with reading/writing the hash keys which relate to the elements in this schema will have xyz_ as prefix for clarity.
my data is not recognized
You do specify the data in your structure, but it seems not to be recognized. See wrong error message
wrong error message
You may get an error message about a missing data item on a higher structural level than where the problem actually is. This especially happens with unions and substitutionGroups. The problem is cause by the fact that on a certain structural level, multiple alternatives may appear which only differ many levels deep in structure. X::C needs to scan all the alternatives, and when all fail it does not know which of the alternatives was the best alternative.
Try turning on debugging with:
use Log::Report mode => "DEBUG";
This module is part of XML-Compile distribution version 1.52, built on January 15, 2016. Website: http://perl.overmeer.net/xml-compile/
Other distributions in this suite: XML::Compile, XML::Compile::SOAP, XML::Compile::WSDL11, XML::Compile::SOAP12, XML::Compile::SOAP::Daemon, XML::Compile::SOAP::WSA, XML::Compile::C14N, XML::Compile::WSS, XML::Compile::WSS::Signature, XML::Compile::Tester, XML::Compile::Cache, XML::Compile::Dumper, XML::Compile::RPC, XML::Rewrite and XML::LibXML::Simple.
Please post questions or ideas to the mailinglist at http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/xml-compile . For live contact with other developers, visit the #xml-compile channel on irc.perl.org.
Copyrights 2006-2016 by [Mark Overmeer]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html
|perl v5.20.3||XML::COMPILE::FAQ (3)||2016-01-15|