Can an array count itself? Like this:
<xs:element name="name"
type="xs:string"
maxOccurs="unbounded">
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:discriminator test="{
fn:count(.) le 5 }" />
</xs:appinfo>
</xs:annotation>
</xs:element>
The above can be reformulated by calling instead of fn:count, dfdl:occursIndex(), and that's definitely well defined in this case. But what does fn:count return in this case? Daffodil will return the same value
as the occursIndex, because it will have speculatively attached the array element to the infoset at the time the fn:count function is being evaluated. But I don't know if that is the right answer or if we should simply say that fn:count is not defined in this case.
Similarly, does an array element exist when it is being parsed?
<xs:element name="name"
type="xs:string"
maxOccurs="unbounded">
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:discriminator test="{
fn:exists(.) }" />
</xs:appinfo>
</xs:annotation>
</xs:element>