Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagexml
<annotation><appinfo source="http://www.ogf.org/dfdl/">
    <dfdl:defineFormat name="compressed">
      <dfdl:format ref="ex:general" layerTransform="gzip" layerLengthKind="explicit" layerLengthUnits="bytes" />
    </dfdl:defineFormat>
    <dfdl:format ref="ex:general" />
</appinfo></annnotation>

<sequence>
         ...
  <element         <xs:sequence>
          <xs:element name="compressedPayloadLength" type="xs:int" dfdl:representation="binary"
            dfdl:outputValueCalc='{ dfdl:contentLength(../compressedPayload, "bytes") }' />

  <element         <xs:element name="compressedPayload" >
    <complexType>
       <sequence dfdl:ref="tns:compressed">
<xs:complexType>
              <group<xs:sequence dfdl:ref="tns:compressedGroupContentscompressed" dfdl:layerLength="{ ../compressedPayloadLength }">
                <xs:group ref="tns:compressedGroupContents" />
              </sequence>
xs:sequence>
            </xs:complexType>
          </xs:element>

          <xs:sequence>
            <xs:annotation>
              <xs:appinfo source="http://www.ogf.org/dfdl/">
                <dfdl:assert>{ compressedPayloadLength eq dfdl:contentLength(compressedPayload, "bytes") }</dfdl:assert>
              </xs:appinfo>
            </xs:annotation>
          </complexType>xs:sequence>
    </element>

  <sequence>
    <xs:annotation><xs:appinfo sourceelement name="after" type="http://www.ogf.org/dfdl/">
  xs:string" dfdl:lengthKind="delimited" />
     <dfdl:assert>{ compressedPayloadLength eq dfdl:contentLength(compressedPayload, "bytes") }</dfdlxs:assert>sequence>
    <appinfo></annotation>
  </sequence>
  ....
</sequence>

The above illustrates how one obtains length information for layered sequences.  The compressed sequence is the complex type model group of the compressedPayload element. The compressedPayloadLength element uses dfdl:outputValueCalc to determine the content length of the compressedPayload element, so that it can be stored when unparsing, and the assertion after the compressedPayload element verifies (when parsing) that the length matches what was stored.

The APIs for defining the gzip, base64, or other transformers enable one to do these transformations in a streaming manner, on demand as data is pulled from the resulting data stream of bytes. Of course it is possible to just convert the entire data object, but we want to enable streaming behavior in case stream-encoded objects are large and an implementation wants to optimize this case.

...

Code Block
languagexml
<dfdl:defineFormat name="foldedLines">
  <dfdl:format layerTransform="foldedLineslineFolded_IMF" dfdl:layerLengthKind="boundaryMark"/>
</dfdl:defineFormat>

<dfdl:defineFormat name="base64">
  <dfdl:format layerTransform="base64_MIME" layerEncoding="us-ascii" layerLengthKind="boundaryMark" layerBoundaryMark='{ ./marker }'/>
  <!-- note expression above is ./marker, not ../marker -->
</dfdl:defineFormat>

 <xs:sequence dfdl:ref="tns:foldedLines">
   <xs:sequence>
     ...
     ... presumably everything here is textual, and utf-8. FoldedLines only applies sensibly to text.
     ...
     <xs:element name="marker" type="xs:string" .../>
     <xs:sequence dfdl:ref="tns:base64">
        <xs:sequence>
          ...
          ... everything here is parsed against the bytes obtained from base64 decoding
          ... which is itself decoding the output of the foldedLines transform
          ... above. Base64 requires only us-ascii, which is a subset of utf-8.
          ...
        </xs:sequence><!-- end base64 data -->
      </xs:sequence><!-- end base64 sequence e.g., framing, aligning -->
   </xs:sequence><!-- end of foldedLines data-->
 </xs:sequence><!-- end foldedLines sequence e.g., framing, aligning -->

...