Uploaded image for project: 'Xerces2-J'
  1. Xerces2-J
  2. XERCESJ-1710

XSD 1.1 all XS11AllCM#whatCanGoHere doesn't take care of maxOccurs="unbounded"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.12.0
    • None
    • None

    Description

      Hi all,

      I consume XSCMValidator API to manage completion in XML editor based on XML Schema by taking care of existing XML elements and filter available elements according XML Schema constraints.

      It works great except whis xs:all in XSD 1.1 and maxOccurs="unbound"

      For instance if I have this xs:all:

      ------------------------------------------------------------

      <xs:all>
      <xs:element name="testEle" minOccurs="1" maxOccurs="unbounded" type="xs:string"/>
      <xs:element name="testEleTwo" type="xs:string"/>
      </xs:all>

      ------------------------------------------------------------

      and I have this XML file:

      ------------------------------------------------------------

           <t:testEle>A</t:testEle>
           <t:testEle>B</t:testEle>

           <t:testEleTwo>C</t:testEleTwo>

      ------------------------------------------------------------

      If I open completion on | (after the 2 t:testEle, I would like to have 

       

       * t:testEle

       * t:testEleTwo

       

      but I have only:

       * t:testEleTwo

       

      After debugging Xerces, it appears that you don't take care of "unbound" in the XS11AllCM#whatCanGoHere.

       

      You do this test:

      ------------------------------------------------------------

      if (state[i] == STATE_START || state[i] < fMaxOccurs[i]) {

      ------------------------------------------------------------

      although I think test should be:

      ------------------------------------------------------------

      if (state[i] == STATE_START || state[i] < fMaxOccurs[i] || fMaxOccurs[i] == SchemaSymbols.OCCURRENCE_UNBOUNDED) {

      ------------------------------------------------------------

       

      This errors occurs in the following code:

       * https://github.com/apache/xerces2-j/blob/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/models/XS11AllCM.java#L328

       * https://github.com/apache/xerces2-j/blob/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/models/XS11AllCM.java#L336

       

      It seems this bug doesn't affect validation since in this case XS11AllCM#whatCanGoHere is never called.

       

      Many thank's for your help.

       

      Regard's Angelo

      Attachments

        Activity

          People

            Unassigned Unassigned
            ZERR Angelo
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: