Hello DFDL community,

My input file contains three fields, separated by slash.

The first and last fields contain strings.

The middle field contains either an ISO date/time or a 3-letter month (Jan, 
Feb, etc.)

So, the middle field is a choice.

This input

Birthday/20190617T182530Z/John's birthday

Produces this XML

<input>
  <title>Birthday</title>
  <date>
    <DateTimeIso>
      <Year>2019</Year>
      <MonthNumeric>06</MonthNumeric>
      <Day>17</Day>
      <TimeSeparator>T</TimeSeparator>
      <HourTime>18</HourTime>
      <MinuteTime>25</MinuteTime>
      <SecondTime>30</SecondTime>
      <TimeZoneZulu>Z</TimeZoneZulu>
    </DateTimeIso>
  </date>
  <note>John's birthday</note>
</input>

But this input

New tasking/Oct/Start Fiscal Year

Results in this error message

[error] Parse Error: Separator '/' not found.

First Question: Why is that? Why can't Daffodil recognize that "Oct" doesn't 
match my schema's first choice branch and then use the second choice branch? I 
noticed that if I reverse the choice branches in my DFDL schema, then this 
input parses fine, but then the first input fails.

Below is my DFDL schema.

Second Question: Is there a better way to express the file format than how my 
DFDL schema does it?  /Roger

<xs:element name="input">
    <xs:complexType>
        <xs:sequence dfdl:separator="/" dfdl:separatorPosition="infix">
            <xs:element name="title" type="xs:string" />
            <xs:element name="date">
                <xs:complexType>
                    <xs:choice>
                        <xs:element name="DateTimeIso">
                            <xs:complexType>
                                <xs:sequence dfdl:separator="">
                                    <xs:element name="Year" type="xs:string"
                                        dfdl:length="4" 
dfdl:lengthKind="explicit"
                                        dfdl:textNumberCheckPolicy="strict"
                                        dfdl:textNumberPattern="####" />
                                    <xs:element name="MonthNumeric" 
type="xs:string"
                                        dfdl:length="2" 
dfdl:lengthKind="explicit"
                                        dfdl:textNumberCheckPolicy="strict"
                                        dfdl:textNumberPattern="##"  />
                                    <xs:element name="Day" type="xs:string"
                                        dfdl:length="2" 
dfdl:lengthKind="explicit"
                                        dfdl:textNumberCheckPolicy="strict"
                                        dfdl:textNumberPattern="##" />
                                    <xs:element name="TimeSeparator" 
type="xs:string"
                                        dfdl:length="1" 
dfdl:lengthKind="explicit" />
                                    <xs:element name="HourTime" type="xs:string"
                                        dfdl:length="2" 
dfdl:lengthKind="explicit"
                                        dfdl:textNumberCheckPolicy="strict"
                                        dfdl:textNumberPattern="##" />
                                    <xs:element name="MinuteTime" 
type="xs:string"
                                        dfdl:length="2" 
dfdl:lengthKind="explicit"
                                        dfdl:textNumberCheckPolicy="strict"
                                        dfdl:textNumberPattern="##" />
                                    <xs:element name="SecondTime" 
type="xs:string"
                                        dfdl:length="2" 
dfdl:lengthKind="explicit"
                                        dfdl:textNumberCheckPolicy="strict"
                                        dfdl:textNumberPattern="##" />
                                    <xs:element name="TimeZoneZulu" 
type="xs:string"
                                        dfdl:length="1" 
dfdl:lengthKind="explicit" />
                                </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>
            <xs:element name="note" type="xs:string" />
        </xs:sequence>
    </xs:complexType>
</xs:element>



Reply via email to