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

Mark Overmeer mark at overmeer.net
Thu Oct 18 23:11:23 GMT 2012


* Richard Head Jr. (hsomob1999 at yahoo.com) [121018 22:35]:
> --- On Thu, 10/18/12, Mark Overmeer <mark at overmeer.net> wrote:
> 
>> This should tell it all...  No structural relaxation, because in general
>> that could make parsing impossible...
> Thats what I was afraid of.

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.

> > 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

No, you do not need that: if $self->{locale} is undef, it is equivalent
to missing.

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

If 'type' is a required attribute and may be missing, yes.
To be honest: I hardly ever need these constructs.

> 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.

Everything is just a HASH.
Validation is a side-action of parsing the fields correctly.

> 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.

> 2. Structural error messages have no context: error: cannot find element or attribute `title'

The errors do attempt to produce help there, but that is not easy.

> 3. For typemaps + objects, errors with context refer to xpath locations

What do you expect differently?  Example?
-- 
Regards,

               MarkOv

------------------------------------------------------------------------
       Mark Overmeer MSc                                MARKOV Solutions
       Mark at Overmeer.net                          solutions at overmeer.net
http://Mark.Overmeer.net                   http://solutions.overmeer.net




More information about the Xml-compile mailing list