Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-10018 Improve XSD Types support in schema definition
  3. NXP-10053

Extend usage of XSD maxOccurs attribute to handle List definition

    XMLWordPrintable

    Details

    • Type: Sub-task
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.7.1
    • Component/s: Core
    • Impact type:
      API change, Content model Change
    • Upgrade notes:
      Hide

      Background info

      Until 5.6 the maxOccurs attribute of the xs:element was not parsed correctly in all cases.

      Normally, an xs:element with a maxoccurs >1 should be seen as a List.

      Until 5.6 it was only true when the xs:sequence had just one element.

      The problem is visible for complex types declaring several fields :

      <xs:complexType name="complexWithSubList">
          <xs:sequence>
            <xs:element name="fieldA" type="xs:string" />
            <xs:element name="items" type="xs:string" minOccurs="0"
              maxOccurs="unbounded" />
          </xs:sequence>
      </xs:complexType>
      

      Here in 5.6, the field "items" won't be considered as a List.
      In 5.7, the parsing will be ok and items will be List<String>.

      Unfortunately, until 5.6, probably because of bad copy/past a lot of schema were wrongly declared.

      <xs:complexType name="relatedtextresource">
          <xs:sequence>
            <xs:element name="relatedtextid" type="xs:string" minOccurs="0"
              maxOccurs="unbound" />
            <xs:element name="relatedtext" type="xs:string" minOccurs="0"
              maxOccurs="unbound" />
          </xs:sequence>
      </xs:complexType>
      

      In 5.6 this relatedtextresource was seen as a Map<String, String> with 2 keys, relatedtextid and relatedtext.
      In 5.7 this same item would be correctly parsed as Map<String, List<String>> with 2 keys, relatedtextid and relatedtext.

      All Nuxeo "built-in" schema where updated, like the relatedText one : https://github.com/nuxeo/nuxeo-core/commit/efadc46527cd06f0cd0ec8cb4f55595016c2a408

      What should be checked

      Inside your XSD schemas, check that the declaration of complex Type that have more than one field don't use maxOccurs="unbound" whithout any reasons.

      Show
      Background info Until 5.6 the maxOccurs attribute of the xs:element was not parsed correctly in all cases. Normally, an xs:element with a maxoccurs >1 should be seen as a List. Until 5.6 it was only true when the xs:sequence had just one element. The problem is visible for complex types declaring several fields : <xs:complexType name= "complexWithSubList" > <xs:sequence> <xs:element name= "fieldA" type= "xs:string" /> <xs:element name= "items" type= "xs:string" minOccurs= "0" maxOccurs= "unbounded" /> </xs:sequence> </xs:complexType> Here in 5.6, the field "items" won't be considered as a List. In 5.7, the parsing will be ok and items will be List<String>. Unfortunately, until 5.6, probably because of bad copy/past a lot of schema were wrongly declared. <xs:complexType name= "relatedtextresource" > <xs:sequence> <xs:element name= "relatedtextid" type= "xs:string" minOccurs= "0" maxOccurs= "unbound" /> <xs:element name= "relatedtext" type= "xs:string" minOccurs= "0" maxOccurs= "unbound" /> </xs:sequence> </xs:complexType> In 5.6 this relatedtextresource was seen as a Map<String, String> with 2 keys, relatedtextid and relatedtext . In 5.7 this same item would be correctly parsed as Map<String, List<String>> with 2 keys, relatedtextid and relatedtext . All Nuxeo "built-in" schema where updated, like the relatedText one : https://github.com/nuxeo/nuxeo-core/commit/efadc46527cd06f0cd0ec8cb4f55595016c2a408 What should be checked Inside your XSD schemas, check that the declaration of complex Type that have more than one field don't use maxOccurs="unbound" whithout any reasons.

      Description

      Typically, this complex type is considered as a sequence of string.

       <xs:complexType name="stringSequence">
          <xs:sequence>
            <xs:element name="item" type="xs:string" minOccurs="0"
              maxOccurs="unbounded" />
          </xs:sequence>
        </xs:complexType>
      

      But, if the sequence contains more that one element the maxOccurs won't be used :

       <xs:complexType name="complexWithSubList">
          <xs:sequence>
            <xs:element name="fieldA" type="xs:string" />
            <xs:element name="items" type="xs:string" minOccurs="0"
              maxOccurs="unbounded" />
            <xs:element name="fieldB" type="xs:string" />
            <xs:element name="moreitems" type="xs:string" minOccurs="0"
              maxOccurs="unbounded" />
          </xs:sequence>
        </xs:complexType>
      

      and then :

      • items will be seen a string rather than a List of string
      • moreitems will be seen a string rather than a List of string

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: