Nope, if the child elements do not consume the full length of the parent complex type, any left over bytes are just skipped on parsing--the values of those bytes are ignored. On unparsing, those bytes will be filled with the dfdl:fillByte property.

On 5/18/22 9:29 AM, Roger L Costello wrote:
Thanks Steve. So if I specify these properties

dfdl:lengthKind="explicit"
dfdl:length="9"
dfdl:lengthUnits="characters"

on an element with complexType, does that implicitly mean "If the element's 
value has a length of less than 9, then the value must be left-justified and must be 
padded on the right with spaces? That seems to be how Daffodil is behaving.

/Roger

-----Original Message-----
From: Steve Lawrence <slawre...@apache.org>
Sent: Wednesday, May 18, 2022 9:16 AM
To: users@daffodil.apache.org
Subject: [EXT] Re: Why does Daffodil ignore my specification of 
textStringJustification and textStringPadCharacter?

Padding/justification only applies to simple xs:string types. They do
not apply to complex types. An alternative would be to model the extra
spaces as a terminator of your MilitaryDayTime element, e.g.

    <xs:element name="MilitaryDayTime"
      dfdl:lengthKind="implicit"
      dfdl:terminator="%SP;%SP;">

On 5/18/22 8:49 AM, Roger L Costello wrote:
Hi Folks,

My input contains slash-separated fields of fixed length. Here's an example 
input:

/05180801Z/

That represents:
Month = 05
Day = 18
Hour = 08
Minute = 01
Time zone = Z

The field may contain a choice of either a MonthDayTime element or a 
MilitaryDayTime element. The above example shows a MonthDayTime value. Here is 
a MilitaryDayTime value:

/211300Z /

That represents:
Day = 21
Hour = 13
Minute = 00
Time zone = Z

Notice the space following the time zone. The space is important because the 
field is exactly 9 characters long. The value doesn't take up the 9 characters, 
so it is padded with a space.

In my DFDL schema I specified these DFDL properties:

dfdl:lengthKind="explicit"
dfdl:length="9"
dfdl:lengthUnits="characters"
dfdl:textStringJustification="left"
dfdl:textStringPadCharacter="%SP;"

When I run the DFDL schema Daffodil generates two warning messages:

[warn] Schema Definition Warning: DFDL property was ignored: 
textStringPadCharacter="%SP;"
[warn] Schema Definition Warning: DFDL property was ignored: 
textStringJustification="left"

Below is the relevant portion of my DFDL schema. Why am I getting these 
warnings?

<xs:element name="TimeOfReturnToOperations" minOccurs="0"
              dfdl:lengthKind="explicit"
              dfdl:length="9"
              dfdl:lengthUnits="characters"
              dfdl:textStringJustification="left"
              dfdl:textStringPadCharacter="%SP;">
      <xs:complexType>
          <xs:choice dfdl:choiceLengthKind="implicit">
              <xs:element name="MonthDayTime">
                  <xs:complexType>
                      <xs:sequence dfdl:separator="">
                          <xs:element name="Month" type="non-zero-length-string" 
dfdl:lengthPattern="01|02|03|04|05|06|07|08|09|10|11|12"/>
                          <xs:element name="Day" type="non-zero-length-string" 
dfdl:lengthPattern="[0-9]{2}"/>
                          <xs:element name="Hour" type="non-zero-length-string" 
dfdl:lengthPattern="[0-9]{2}"/>
                          <xs:element name="Minute" type="non-zero-length-string" 
dfdl:lengthPattern="[0-9]{2}"/>
                          <xs:element name="TimeZone" type="non-zero-length-string" 
dfdl:lengthPattern="Z"/>
                      </xs:sequence>
                  </xs:complexType>
              </xs:element>
              <xs:element name="MilitaryDayTime">
                  <xs:complexType>
                      <xs:sequence dfdl:separator="">
                          <xs:element name="Day" type="non-zero-length-string" 
dfdl:lengthPattern="[0-9]{2}"/>
                          <xs:element name="Hour" type="non-zero-length-string" 
dfdl:lengthPattern="[0-9]{2}"/>
                          <xs:element name="Minute" type="non-zero-length-string" 
dfdl:lengthPattern="[0-9]{2}"/>
                          <xs:element name="TimeZone" type="non-zero-length-string" 
dfdl:lengthPattern="Z"/>
                      </xs:sequence>
                  </xs:complexType>
              </xs:element>
          </xs:choice>
      </xs:complexType>
</xs:element>

Reply via email to