Versions Compared

Key

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

this proposal is a work in progressThis proposal reflects the feature as implemented in Daffodil 2.4.0. A prior proposal is available here.

...

Code Block
<xs:simpleType name="fruitLocalType"
     dfdlx:inputValueCalc ="{ dfdlx:repTypeValueIntrepTypeValue() – 2 }"
     dfdlx:ouputValueCalc ="{ dfdlx:logicalTypeValueIntlogicalTypeValue() + 2 }" 
     dfdlx:repType=”tns:fruitIntType”
     dfdlx:repValues="12 14"
     dfdlx:repValueRanges="3 10 16 255" >
  <xs:restriction base=”xs:int” />
</xs:simpleType>

...

Code Block
<xs:simpleType name="fruitLocalType" dfdlx:inputTransform="dfdlx:repTypeValueIntrepTypeValue() - 2" dfdlx:outputTransform="dfdlx:logicalTypeValueIntlogicalTypeValue() + 2" 
               dfdlx:repValues="12 14" dfdlx:repValueRanges="3 10 16 255" >
  <xs:union>
    <xs:simpleType>
      <xs:restriction base="xs:int ">
        <xs:enumeration value="10"/>
        <xs:enumeration value="12"/>
      </xs:restriction>
    </xs:simpleType>
    <xs:simpleType>
      <xs:restriction base="xs:int">
        <xs:minInclusive="1"/>
        <xs:maxInclusive="8"/>
      </xs:restriction>
    </xs:simpleType>
    <xs:simpleType>
      <xs:restriction base="xs:int">
        <xs:minInclusive="14"/>
        <xs:maxInclusive="253"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:union>
</xs:simpleType>

...

Code Block
<xs:sequence >
  <xs:element name="raw" type="tns:fruitRepType" dfdlx:outputValueCalc=”dfdlx:outputTypeCalcIntoutputTypeCalc(tns:fruitEnumType, ../fruit)”/>
  <xs:element name=”fruit” type=”tns:fruitEnumType” dfdlx:inputValueCalc=”dfdlx:inputTypeCalcStringinputTypeCalc(tns:fruitRepType, ../raw)”/>
</xs:sequence>

...

The only additional mechanism is the dfdlx: outputTypeCalcNextSiblingInt/String functionsoutputTypeCalcNextSibling function, which takes the value of the following sibling and applies the outputTypeCalc function associated with the element type of the following sibling.

...

Code Block
<xs:sequence>
  <xs:element name="raw" type="tns:fruitIntType" dfdlx:outputValueCalc="dfdlx:outputTypeCalcNextSiblingIntoutputTypeCalcNextSibling()" />
  <xs:choice dfdlx:choiceBranchKeyKind="byType" dfdlx:choiceDispatchKeyKind=”explicit” dfdlx:choiceDispatchKey="../raw" >
    <xs:element name="fruit" type="tns:fruitType" dfdlx:inputValueCalc="dfdlx:inputTypeCalc(tns:fruitType, ../raw)" />
    <xs:element name="localFruit" type="tns:fruitLocalType" dfdlx:inputValueCalc="dfdlx:inputTypeCalc(tns:fruitLocalType, ../raw)" />
    <xs:element name="disused" type="tns:fruitDisuedType" dfdlx:inputValueCalc="dfdlx:inputTypeCalc(tns:fruitDisusedType, ../raw)" />
  <xs:choice>
</xs:sequence>

...

Summary of Functions

  • dfdlx:inputTypeCalcIntinputTypeCalc(f: QName, x:AnyA)
    • f must be a constant QName resolving to a simpleType with a transform defined
    • The repType of said transform must match the type of xThe type f must be a restriction of xs:inttype of x is determined statically at compile time as the primitive type of the repType of f.
    • The return type is given by the primitive type of the logical type of f.
    • If the types given by f do not match what is required, the relevent expression may be cast according to standard DFDL expression casting rules.
    • Returns the result of applying the inputTypeCalc function assotiated associated with f to x
  • dfdlx:inputTypeCalcStringoutputTypeCalc(f: QName, x:Any)
    • Behaves like dfdlx:inputTypeCalcInt(f: QName, x:Any) except that f must be a string type, and a string will be returned
    dfdlx:outputTypeCalcInt(f: QName, x:Any)
    • f must be a constant QName constant QName resolving to a simpleType with a transform defined
    • The repType of said transform must be a restriction of xs:int
    • The type f must match the type of x
    • type of x is determined statically at compile time as the primitive type of the logical type of f.
    • The return type is given by the primitive type of the repType of f.
    • If the types given by f do not match what is required, the relevent expression may be cast according to standard DFDL expression casting rules.
    • Returns the Returns the result of applying the outputTypeCalc function assotiated associated with f to x
  • dfdlx:outputTypeCalcStringoutputTypeCalcNextSiblingInt(f: QName, x:Any)
    • Behaves like dfdlx:inputTypeCalcInt(f: QName, x:Any) except that the repType associated with f must be a restriction of xs:string, and a string will be returned
    dfdlx:outputTypeCalcNextSiblingInt(f: QName, x:Any)
    • The following sibling must be a simpleType whose The following sibling must be a simpleType whose repType is a restriction of xs:int
    • Returns the result of applying the outputTypeCalc function associated with the type of the following element to the value of the following element
  • dfdlx:outputTypeCalcNextSiblingStringoutputTypeCalcNextSibling()
    • Behaves like dfdlx:outputTypeCalcNextSiblingInt, except the repType must be a restriction of xs:string, and a string will be returned
  • dfdlx:repTypeValueInt()
    • Can only be called from inside dfdlx:inputTransform
    • Returns the value of the underlying repType, wehn the underlying repType has an int value
  • dfdlx:repTypeValueString()
    • Can only be called from inside dfdlx:inputTransform
    • Returns the value of the underlying repType, wehn the underlying repType has an string value
    • Returns the result of applying the outputTypeCalc defined by the immidietly following sibling of the current node, to the value contained by the immidietly following sibling of the current node.
    • Can only be used on unparse.
    • Requires that all potential following siblings have the same repType and define an outputTypeCalc.
    • The return type is the primitive type of the repType of the following sibling.
    • If the return type does not match what is expected by the containing expression, it will be cast according to standard DFDL expression casting rules.
  • dfdlx:repTypeValuedfdlx:logicalTypeValueInt()
    • Can only be called from inside dfdlx:outputTransforminputTransform
    • Returns the logical value of this element when the logical type is an int typethe underlying repType.
  • dfdlx:logicalTypeValueStringlogicalTypeValue()
    • Can only be called from inside dfdlx:outputTransform
    • Returns the logical value of this element when the logical type is a String type.