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

Richard Head Jr. hsomob1999 at yahoo.com
Thu Oct 18 22:35:28 GMT 2012


--- On Thu, 10/18/12, Mark Overmeer <mark at overmeer.net> wrote:
> > Richard Head Jr. (hsomob1999 at yahoo.com)
> > Is validation => 0 meant to only turn off checking XSD restrictions,
> > and not XSD structural validation...

> This should tell it all...  No structural relaxation, because in general
> that could make parsing impossible...

Thats what I was afraid of.

> What do you need?

I end up doing a lot if conditional checks in my object's toXML() methods:

$xml->{locale} = $self->name if defined $self->name

if($self->checksum && $self->algorithm) {
  $xml->{checksum} = { 
    _ => $self->checksum, type => $self->algorithm 
  };
}

#...

It would be a lot easer to just include everything in the $xml hash, generate the XML, and used the XML Schema for full validation -if necessary. 
 
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 
2. Structural error messages have no context: error: cannot find element or attribute `title'
3. For typemaps + objects, errors with context refer to xpath locations






More information about the Xml-compile mailing list