castor

xs:choice does not work properly if minOccurs=0 is not set

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.1
  • Fix Version/s: 1.1.1
  • Component/s: XML
  • Labels:
    None
  • Environment:
    Windows XP SP2
  • Number of attachments :
    5

Description

Castor XML does not unmarshall the following XML document:

<?xml version="1.0" encoding="UTF-8"?>
<xcap-directory xmlns="urn:oma:xml:xdm:xcap-directory" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<folder auid="resource-lists"/>
</xcap-directory>

With the classes generated from the XML schema for XDM - XCAP Directory (http://www.openmobilealliance.org/tech/profiles/xdm_xcapDirectory-V1_0_1.xsd).

We found a workaround specifying minOccurs="0" in the <xs:choice> element definition of the schema.

Original schema from Open Mobile Alliance is attached to this bug report.

The modified schema to make castor to work is also attached.

  1. patch.c1902.20070312.txt
    12/Mar/07 8:23 AM
    2 kB
    Werner Guttmann
  2. patch.c1902.20070312-002.txt
    12/Mar/07 8:43 AM
    2 kB
    Werner Guttmann
  3. tests.c1902.20070312.txt
    12/Mar/07 8:25 AM
    11 kB
    Werner Guttmann
  4. xdm_xcapDirectory-V1_0_1.xsd
    09/Mar/07 4:49 AM
    5 kB
    Pascal Maugeri
  5. xdm_xcapDirectory-V1_0_1-MODIFIED.xsd
    09/Mar/07 4:49 AM
    5 kB
    Pascal Maugeri

Activity

Hide
Werner Guttmann added a comment -

Does the following fragment of the original schema make sense at all:

<xs:sequence minOccurs="0" maxOccurs="unbounded">

Normally one uses a sequence to define a sequence of elements for a complex type, and specifies the cardinality of the individual elemenst at the element level. Hmm .. just thinking aloud.

Show
Werner Guttmann added a comment - Does the following fragment of the original schema make sense at all: <xs:sequence minOccurs="0" maxOccurs="unbounded"> Normally one uses a sequence to define a sequence of elements for a complex type, and specifies the cardinality of the individual elemenst at the element level. Hmm .. just thinking aloud.
Hide
Pascal Maugeri added a comment -

If I understand correctly you would rewrite the schema in such a way (moving cardinality to elements) ?

<xs:choice>
<xs:sequence>
<xs:element name="entry" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
[...]
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:element name="error-code" type="xs:string"/>
</xs:choice>

I will try that on monday in my dev environment to see if Castor is happy with that

The server returns a folder that can contain 0 to n entries (like files) OR an error code OR nothing (e. <folder auid="resource-lists"/>)

Show
Pascal Maugeri added a comment - If I understand correctly you would rewrite the schema in such a way (moving cardinality to elements) ? <xs:choice> <xs:sequence> <xs:element name="entry" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> [...] </xs:complexType> </xs:element> </xs:sequence> <xs:element name="error-code" type="xs:string"/> </xs:choice> I will try that on monday in my dev environment to see if Castor is happy with that The server returns a folder that can contain 0 to n entries (like files) OR an error code OR nothing (e. <folder auid="resource-lists"/>)
Hide
Pascal Maugeri added a comment -

BTW, I realize that I set this issue to a MAJOR priority while I believe it is minor: I've found a workaround changing the schema.

Could we change this issue to MINOR (it looks I can't do it with my profile) please ?

Show
Pascal Maugeri added a comment - BTW, I realize that I set this issue to a MAJOR priority while I believe it is minor: I've found a workaround changing the schema. Could we change this issue to MINOR (it looks I can't do it with my profile) please ?
Hide
Werner Guttmann added a comment -

Well, it looks like I have been able to identify a problem spot in the source code that is realted to how Castor deals with choices that contain at least one optional element definition.

Show
Werner Guttmann added a comment - Well, it looks like I have been able to identify a problem spot in the source code that is realted to how Castor deals with choices that contain at least one optional element definition.
Hide
Werner Guttmann added a comment -

Initial patch for review.

Show
Werner Guttmann added a comment - Initial patch for review.
Hide
Werner Guttmann added a comment -

New CTF tests related to this issue.

Show
Werner Guttmann added a comment - New CTF tests related to this issue.
Hide
Werner Guttmann added a comment -

Improved patch.

Show
Werner Guttmann added a comment - Improved patch.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: