[Xml-compile] Clarification XML::Schema::Compile validation option for writers

Richard Head Jr. hsomob1999 at yahoo.com
Thu Dec 6 01:13:32 GMT 2012


> On Thu, 10/18/12, Mark Overmeer <mark at overmeer.net>
>
> XML requires validation.  The only reason to turn it
> off in XML::Compile is to increase performance if you trust content 
> of the documents, nothing more.

With validation off types are still checked, use="required" directives and enumerations are still enforced. Can you be more specific about what this option does? For example, does it only affect fundamental facets?

> > As an aside, while some of the errors raised by validation => 1
> > are useful, I think that that without a larger "validation framework"
> > they're more of a  constraint in certain cases (particularly when used
> > with typemaps) as:
> > 
> > 1. They're not done in a batch
>
> I have no idea where you are talking about.

Error handling is not ideal and, without a larger "framework" in place, messages can be cryptic and or limited. For example, a particular object may have 10 validation errors but the exception includes only one. It is possible that one will have to to bounce their objects off the WRITER 10 times to resolve all of the errors.  

> > 3. For typemaps + objects, errors with context refer to xpath locations
>
> What do you expect differently?  Example?

Let's say that package has a version attribute that's mapped to an emumeration:

my $pkg = Package->new(version => 'bad!');
# ...
$writer->($doc, $pkg);

When the value given for version is not part of the enum this error is raised:

error: invalid enumerate `bad!' at {http://example.com}package#facet

It would be nice if there was a hook on the object that allows one to map errors to object attributes, making it possible to create a message that at least included the name of the invalid attribute (i.e., something less cryptic).

But don't get me wrong, XML::Compile contains a great set of modules and I love it!





More information about the Xml-compile mailing list