You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@daffodil.apache.org by Roger L Costello <co...@mitre.org> on 2021/12/01 17:42:58 UTC

Huh? Nillable complex type elements can only have '%ES;' as their dfdl:nilValue property

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

Re: Huh? Nillable complex type elements can only have '%ES;' as their dfdl:nilValue property

Posted by Mike Beckerle <mb...@apache.org>.
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 <co...@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
>