[
https://issues.apache.org/jira/browse/DAFFODIL-3059?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18046433#comment-18046433
]
Olabusayo Kilo commented on DAFFODIL-3059:
------------------------------------------
See test test_prefix_alignment_0 which was added in
https://github.com/apache/daffodil/pull/1604
> prefixed Element can't be bit aligned
> -------------------------------------
>
> Key: DAFFODIL-3059
> URL: https://issues.apache.org/jira/browse/DAFFODIL-3059
> Project: Daffodil
> Issue Type: Bug
> Components: Back End
> Affects Versions: 4.0.0
> Reporter: Olabusayo Kilo
> Priority: Major
>
> The spec expects the prefixedType of the prefixed element to be 1 (without
> specification of alignment Units). Everything works as expected when
> alignment units is in bytes, with the following schema.
> {code:xml}
> <xs:include
> schemaLocation="/org/apache/daffodil/xsd/DFDLGeneralFormatPortable.dfdl.xsd"/>
> <dfdl:format
> ref="ex:GeneralFormat"
> representation="text"
> lengthKind="delimited"
> separatorPosition="infix"
> lengthUnits="bytes"
> alignmentUnits="bytes"
> encoding="US-ASCII"
> />
> <xs:simpleType name="prefixType" dfdl:lengthKind="explicit"
> dfdl:length="1">
> <xs:restriction base="xs:int"/>
> </xs:simpleType>
> <xs:element name="prefixed_element">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="e1" dfdl:lengthKind="implicit"
> dfdl:fillByte="E">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="c" type="xs:string"
> dfdl:length="2"
> dfdl:lengthKind="explicit"
> dfdl:alignment="2"
> dfdl:fillByte="C"/>
> <xs:element name="a" type="xs:string"
> dfdl:prefixLengthType="ex:prefixType"
> dfdl:prefixIncludesPrefixLength="no"
> dfdl:lengthKind="prefixed"
> dfdl:alignment="2"
> dfdl:fillByte="A"/>
> <xs:element name="b" type="xs:string"
> dfdl:length="2"
> dfdl:lengthKind="explicit"
> dfdl:alignment="2"
> dfdl:fillByte="B"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:defineSchema>
> {code}
> However things break with the following SDE if alignmentunits = bits, since
> the alignment still has to fulfill the requirement of being 1. But it is
> going to be 1 bit instead, which is illegal for US-ASCII encoding
>
> SDE: org.apache.daffodil.tdml.TDMLExceptionImpl: (Implementation: daffodil)
> SchemaDefinitionError: The given alignment (1 bits) must be a multiple of the
> encoding specified alignment (8 bits) for int when representation='text'.
> Encoding: US-ASCII
> {code:xml}
> <tdml:defineSchema name="s2" elementFormDefault="unqualified">
> <xs:include
> schemaLocation="/org/apache/daffodil/xsd/DFDLGeneralFormatPortable.dfdl.xsd"/>
> <dfdl:format
> ref="ex:GeneralFormat"
> representation="text"
> lengthKind="delimited"
> separatorPosition="infix"
> lengthUnits="bits"
> alignmentUnits="bits"
> encoding="US-ASCII"
> />
> <xs:simpleType name="prefixType" dfdl:lengthKind="explicit"
> dfdl:length="8">
> <xs:restriction base="xs:int"/>
> </xs:simpleType>
> <xs:element name="prefixed_element">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="e1" dfdl:lengthKind="implicit"
> dfdl:fillByte="E">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="c" type="xs:string"
> dfdl:length="16"
> dfdl:lengthKind="explicit"
> dfdl:alignment="16"
> dfdl:fillByte="C"/>
> <xs:element name="a" type="xs:string"
> dfdl:prefixLengthType="ex:prefixType"
> dfdl:prefixIncludesPrefixLength="no"
> dfdl:lengthKind="prefixed"
> dfdl:alignment="16"
> dfdl:fillByte="A"/>
> <xs:element name="b" type="xs:string"
> dfdl:length="16"
> dfdl:lengthKind="explicit"
> dfdl:alignment="16"
> dfdl:fillByte="B"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </tdml:defineSchema>
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)