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

hmepas hmepas at gmail.com
Sun Jan 18 21:15:50 GMT 2015


Well to avoid back-compability issues it could be an optional, with default
state to be back compatible.

On Sun, Jan 18, 2015 at 11:26 PM, Mark Overmeer <mark at overmeer.net> wrote:

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


-- 
Pavel S. Khmelinsky <hmepas at gmail.com>
Jabber: hmepas at gmail.com
Skype: hmepas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/xml-compile/attachments/20150119/4b9aed68/attachment.htm>


More information about the Xml-compile mailing list