[Xml-compile] patch for treating { array => 'scalar' } explicitly as an error in Writer.

Mark Overmeer mark at overmeer.net
Sun Jan 18 20:26:19 GMT 2015


* hmepas (hmepas at gmail.com) [150118 15:11]:
> When I send soap-requests from XML::Compile i could use structres like
> { array_element => 'something' }
> Where array_element defined with maxOccur > 1. And XML::Compile will
> quietly treat it as [ 'something' ] provided. In my practice, if I as a
> programmer providing scalar where array ref expected it's most of the time
> just honest mistake, like @values beside \@values, and for me would be more
> expected behaviour is to just have errors then this happens.

The writer offers a little more flexibility than the reader.  In this
case:    <element name="item" type="string" minOccurs="unbounded"/>
the reader will always produce   item => ['foo']
but the writer with accept both  item => ['foo']  as  item => 'foo'

 . Very very often, the schema permits to include more than one element,
   but it is never used with more than one element.  Those additional
   array [] make the code less readible.

 . I have seen elements change over schema versions from default
   maxOccurs=1 into maxOccurs > 1.  In this case, the offered
   flexibility helps: the old code works with the new schema.

 . It's quite confusing that the 'item' is signular, but you always
   have to give it an array.  It has bitten me a few times until
   I had enough of it.

So: the flexibility is on purpose and does help coders.  It is not
accidental.

I will not change the code for the simple reason of backwards
compatibility.  I'll only break that when the code produces
incorrect results.
-- 
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