I created a JIRA ticket for this experimental feature to lift the
dfdl:nilValues='%ES;' only restriction on complex type elements.

https://issues.apache.org/jira/browse/DAFFODIL-2597

On Thu, Dec 2, 2021 at 10:58 AM Mike Beckerle <mbecke...@apache.org> wrote:

> It is not possible for DFDL v1.0 to lift this restriction as an erratum.
>
> We can explore removing it for DFDL v2.0 in the future, and create a
> Daffodil experimental feature to implement this.
>
> The process works that way, implement/prototype the change, then with
> experience from an implementation, propose it for the standard.
>
> In general, in DFDL, you do not get to design "the XML you want", and then
> use DFDL to populate it. It simply doesn't work that way. Often tiers of
> elements are required where one is not desired strictly speaking in the
> model.
>
> The way I have seen this sort of thing modeled is like so:
>
> <myElement>
>     <nil/>
> <myElement>
>
> <myElement>
>      <subElement1>....</subElement1>
>      <subElement2>....</subElement2>
>      ....
> <myElement>
>
> So that you always have myElement at the top to identify the thing. Then
> you either have child element content, or a reserved element to indicate
> the nil/nulled status.
>
> Arguably, <myElement xsi:nil="true"/>, should be possible vs.
> <myElement><nil/></myElement>.
>
> Another alternative is to use the lack of an element to indicate that the
> element is nil.
>
> <choice>
>     <sequence dfdl:initiator="-"/>
>     <element name="myElement" ....>
>        ... complex type here...
>     </element>
> </choice>
>
> Then, if the "-" is found, there will be no element at all in the infoset.
> When unparsing, this choice will default to the first branch and output the
> "-".
>
>
>
>
>
>
>
> On Thu, Dec 2, 2021 at 8:00 AM Roger L Costello <coste...@mitre.org>
> wrote:
>
>> Hi Mike,
>>
>>
>>
>> 1. Would you get the DFDL committee to remove this restriction, please?
>>
>>
>>
>> 2. I have 350 data formats, each having dozens of fields with nillable
>> complexTypes. So there is a strong use case for removing the restriction.
>>
>>
>>
>> 3. The choice idea that you presented, although clever and interesting,
>> is not suitable. In the example I presented, the output XML should be one
>> of these:
>>
>>
>>
>> <MyField>-</MyField>
>>
>>
>>
>> <MyField>
>>
>>     <DateTimeIso>…</DateTimeIso>
>>
>> </MyField>
>>
>>
>>
>> <MyField>
>>
>>     <MonthName>…</MonthName>
>>
>> </MyField>
>>
>>
>>
>> With the technique you showed, the output would be one of these:
>>
>>
>>
>> <noValue>-</noValue>
>>
>>
>>
>> <MyField>
>>
>>     <DateTimeIso>…</DateTimeIso>
>>
>> </MyField>
>>
>>
>>
>> <MyField>
>>
>>     <MonthName>…</MonthName>
>>
>> </MyField>
>>
>>
>>
>> That first one -- <noValue> -- is not unacceptable to my community.
>>
>>
>>
>> /Roger
>>
>>
>>
>> *From:* Mike Beckerle <mbecke...@apache.org>
>> *Sent:* Wednesday, December 1, 2021 4:06 PM
>> *To:* users@daffodil.apache.org
>> *Subject:* [EXT] Re: Huh? Nillable complex type elements can only have
>> '%ES;' as their dfdl:nilValue property
>>
>>
>>
>> This is definitely a DFDL language restriction, not a Daffodil-specific
>> thing.
>>
>>
>>
>> I have made inquiries as to what the rationale is for this restriction,
>> and I'll report back.
>>
>>
>>
>> In the mean time, maybe this sort of technique.
>>
>>
>>
>> <choice>
>>
>>     <element name="noValue" type="xs:string" dfdl:lengthKind="explicit"
>> dfdl:length="0" dfdl:initiator="-"/>
>>
>>     <element name="myComplexType">
>>
>>        .... non nillable complex type definition ....
>>
>>     </element>
>>
>> </choice>
>>
>>
>>
>> I have to admit that this workaround sort of suggests that there isn't a
>> coherent rationale for the restriction, as this is pretty obviously
>> equivalent to the complex type being nillable with nilValue="-".
>>
>>
>>
>>
>>
>> On Wed, Dec 1, 2021 at 12:43 PM Roger L Costello <coste...@mitre.org>
>> wrote:
>>
>> Hi Folks,
>>
>> I am creating a DFDL schema for a data format that has a field whose
>> value is a hyphen when no data is available and when data is available,
>> then the field contains either an ISO datetime or a 3-letter month name.
>> Here's how I specified the field:
>>
>> <xs:element name="MyField" nillable="true" dfdl:nilValue="-">
>>     <xs:complexType>
>>         <xs:choice dfdl:choiceLengthKind="implicit">
>>             <xs:element name="DateTimeIso">
>>                 <xs:complexType>
>>                     <xs:sequence>
>>                         ...
>>                     </xs:sequence>
>>                 </xs:complexType>
>>             </xs:element>
>>             <xs:element name="MonthName" type="xs:string"
>>                 dfdl:length="3" dfdl:lengthKind="explicit" />
>>         </xs:choice>
>>     </xs:complexType>
>> </xs:element>
>>
>> When I run it, Daffodil gives this error message:
>>
>> [error] Schema Definition Error: Nillable complex type elements can only
>> have '%ES;' as their dfdl:nilValue property.
>>
>> Is that an error in Daffodil? Or, is it an actual DFDL restriction? If
>> the latter, why is there such a restriction? How do I work around this
>> error?
>>
>> /Roger
>>
>>

Reply via email to