NEW ISSUE: minOccurs=0 and xsi:nil (resent with subject line)

Previous Topic Next Topic
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

NEW ISSUE: minOccurs=0 and xsi:nil (resent with subject line)

Erik Johnson-2
[Resent with Subject Line -- Sorry]

* Title:          xsi:nil and minOccurs=0
* Description:    see below
* Target:         "Basic"?
* Proposal:       see below

Many type serializers do not use xsi:nil and minOccurs=0 as schema designers intend.  Given this schema type:

<xs:complexType name="UpdateMsg">
            <xs:element name="Name" />
            <xs:element name="Fax" minOccurs="0" nillable="true" />

Callers can send message instances that either (a) include the "Fax" element with content*, (b) exclude the "Fax" element altogether, or (c) include the "Fax" element without content but with an xsi:nil="true" attribute.  Type serializers, however, do not usually support scenario "b" because programming languages can't distinguish whether a type member is intentionally NULL or just unassigned.

Message receivers usually interpret the lack of an element as "left unsaid" and the presence of an element with empty content and an xsi:nil="true" attribute as "set to NULL".  Type serializers summarily convert type members with NULL values to xsi:nil declarations, which can cause unintended data changes on the server.

Data binding tools need to have a way to distinguish unassigned type members (which should be ommitted from the serialization) from members assigned to NULL (which should be serialized with xsi:nil="true").

It seems like this problem is similar to database programming.  Columns excluded from an UPDATE statement are not summarily set to NULL – they are left unchanged.  Maybe solutions to database binding could be reviewed for schema?

I know the whole xsi:nil / minOccurs=0 issue has been well-trodden, but I wanted to submit this facet of the problem because there is some real pain.  Thanks!


Erik Johnson
Epicor Software Corp.

 * Assume there is a simpleType restriction in place like minLength="1"

Reply | Threaded
Open this post in threaded view

NEW ISSUE: Using patterns to constrain numerical types

Pete Cordell

Here's a potential new issue...

* Title:          Using patterns to constrain numerical types
* Description:    see below
* Target:         "Basic"?
* Proposal:       see below

Description: Occasionally people define schema that use patterns to
constrain the format of numerical types.  For example, specifying a pattern
of /\d{3}/ so that integers are of the form 000, 001, 002 etc.  Or
specifying a pattern of /\d+(\.\d+)?e-?\d+/ to ensure that a float number
has the exponent.  It is generally difficult for binding tools to generate
numbers that conform to arbitrary patterns such as these, even though it is
valid XSD.

Proposal:  Recommend against this practice!  Use only the min/max/digits
facets to constrain numerical types.

Is that appropriate?


Pete Cordell
Tech-Know-Ware Ltd
                         for XML to C++ data binding visit