Steve Lawrence created DAFFODIL-2648:
----------------------------------------
Summary: fn:exists fails to unparse when element does not exist
Key: DAFFODIL-2648
URL: https://issues.apache.org/jira/browse/DAFFODIL-2648
Project: Daffodil
Issue Type: Bug
Components: Unparsing
Affects Versions: 3.2.1
Reporter: Steve Lawrence
Schema:
{code:xml}
<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>
{code}
Infoset:
{code:xml}
<ex:root xmlns:ex="http://example.com">
<parent></parent>
<term></term>
</ex:root>
{code}
This infoset fails to unparse with this schema with the error
{quote}
Unparse Error: Expression Evaluation Error: Child element {}int does not exist
{quote}
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.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)