You haven't specified a length of the LatitudeDegrees (or LatitudeMinutes). So the lengthKind is just delimited and so will end up delimited by the nearest enclosing delimiter, which is the /. So LatatitudeDegrees is parsed as "2006", and things go off the rails.

Instead, you want your LatitudeDegrees/Minutes elements to have lengthKind="explicit" with length="2", e.g.:

<xs:element name="Origin">
    <xs:complexType>
        <xs:sequence>
<xs:element name="LatitudeDegrees" dfdl:lengthKind="explicit" dfdl:length="2">
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:pattern value="[0-9]{2}"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:element>
<xs:element name="LatitudeMinutes" dfdl:lengthKind="explicit" dfdl:length="2">
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:pattern value="[0-9]{2}"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
</xs:element>



On 8/18/22 11:08 AM, Roger L Costello wrote:
Hi Folks,

Daffodil is unable to parse DFDL schemas containing two consecutive element 
declarations, each with a simpleType which has a facet.

With this input:

John Doe/2006/Sally Smith

The part of interest is the middle part - 2006 - which consists of two 
subparts: 20 (LatitudeDegrees) and 06 (LatitudeMinutes). Each subpart is 
constrained via XSD facets.

I get this error message when I parse using Daffodil version 3.2.1 (using the 
-V limited option):

[error] Validation Error: LatitudeMinutes failed facet checks due to: facet 
enumeration(s): 06

Below is my DFDL schema.

I believe this is a bug, yes? Is there a workaround?

<xs:schema xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema";>
     <xs:annotation xmlns:f="function" xmlns:fn="http://www.w3.org/2005/xpath-functions"; 
xmlns:regex="regex-functions">
         <xs:appinfo source="http://www.ogf.org/dfdl/";>
             <dfdl:format alignment="1"
                 alignmentUnits="bytes"
                 emptyValueDelimiterPolicy="none"
                 encoding="ASCII"
                 encodingErrorPolicy="replace"
                 escapeSchemeRef=""
                 fillByte="%SP;"
                 floating="no"
                 ignoreCase="yes"
                 initiatedContent="no"
                 initiator=""
                 leadingSkip="0"
                 lengthKind="delimited"
                 lengthUnits="characters"
                 nilValueDelimiterPolicy="none"
                 occursCountKind="implicit"
                 outputNewLine="%CR;%LF;"
                 representation="text"
                 separator=""
                 separatorSuppressionPolicy="anyEmpty"
                 sequenceKind="ordered"
                 textBidi="no"
                 textPadKind="none"
                 textTrimKind="none"
                 trailingSkip="0"
                 truncateSpecifiedLengthString="no"
                 terminator=""
                 textNumberRep="standard"
                 textStandardBase="10"
                 textStandardZeroRep="0"
                 textNumberRounding="pattern"
                 textStandardExponentRep="E"
                 textNumberCheckPolicy="strict"/>
         </xs:appinfo>
     </xs:annotation>
     <xs:element name="Test">
         <xs:complexType>
             <xs:sequence dfdl:separator="/" dfdl:separatorPosition="infix">
                 <xs:element name="A" type="xs:string" />
                 <xs:element name="Origin">
                     <xs:complexType>
                         <xs:sequence dfdl:separator="">
                             <xs:element name="LatitudeDegrees">
                                 <xs:simpleType>
                                     <xs:restriction base="xs:string">
                                         <xs:pattern value="[0-9]{2}"/>
                                     </xs:restriction>
                                 </xs:simpleType>
                             </xs:element>
                             <xs:element name="LatitudeMinutes">
                                 <xs:simpleType>
                                     <xs:restriction base="xs:string">
                                         <!--<xs:pattern value="[0-9]{2}"/>-->  
<!-- This also fails -->
                                         <xs:enumeration value="06" />
                                     </xs:restriction>
                                 </xs:simpleType>
                             </xs:element>
                         </xs:sequence>
                     </xs:complexType>
                 </xs:element>
                 <xs:element name="B" type="xs:string" />
             </xs:sequence>
         </xs:complexType>
     </xs:element>
</xs:schema>



Reply via email to