Uploaded image for project: 'Daffodil'
  1. Daffodil
  2. DAFFODIL-2648

fn:exists fails to unparse when element does not exist

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.2.1
    • 3.3.0
    • Unparsing
    • None

    Description

      Schema:

        <annotation>
          <appinfo source="http://www.ogf.org/dfdl/">
            <dfdl:format
              ref="ex:GeneralFormat" />
          </appinfo>
        </annotation>
      
        <element name="root">
          <complexType>
            <sequence>
              <element name="parent">
                <complexType>
                  <sequence>
                    <element name="int" type="xs:int" minOccurs="0" dfdl:lengthKind="explicit" dfdl:length="1" />
                  </sequence>
                </complexType>
              </element>
              <element name="term" type="xs:string"
                dfdl:lengthKind="explicit" dfdl:length="0"
                dfdl:terminator="{ if (fn:exists(../parent/int)) then 'x' else 'y' }" />
            </sequence>
          </complexType>
        </element>
      

      Infoset:

      <ex:root xmlns:ex="http://example.com">
        <parent></parent>
        <term></term>
      </ex:root>
      

      This infoset fails to unparse with this schema with the error

      Unparse Error: Expression Evaluation Error: Child element {}int does not exist

      The expected output is the letter y

      By the time the terminator expression for term is evaluated, parent should have been finalized and so we should know for sure that the int element exists or not and fn:exists should return the correct value.

      Note that if term were inside parent and after the int element, even that should still work even though parent isn't finalized yet, because this is a backwards referencing expression and so should always get an answer--we never need to wait for the int element to maybe show up or not in the infoset.

      Attachments

        Activity

          People

            slawrence Steve Lawrence
            slawrence Steve Lawrence
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: