1 / 7

Calculated Values

Calculated Values. DFDL supports limited layering Properties: inputValueCalc outputValueCalc outputLengthCalc Note: inputLengthCalc is just length=“{ … }”. Calculated Values Example. M. M. D. D. Y. Y. Logically, the data is a date. <element name=“d” type=“date”/>

sheryl
Download Presentation

Calculated Values

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Calculated Values • DFDL supports limited layering • Properties: • inputValueCalc • outputValueCalc • outputLengthCalc • Note: inputLengthCalc is just length=“{ … }” 1

  2. Calculated Values Example M M D D Y Y • Logically, the data is a date. <element name=“d” type=“date”/> • Physically, it is stored as 6 packed-decimal digits, unsigned • Like so: 2

  3. Physical Layer’s Shape M M D D Y Y <sequence> <element name="mm" type="int“ /> <element name="dd" type="int“ /> <element name="yy" type="int“ /> </sequence> 3

  4. Physical Layer Representation M M D D Y Y <sequence dfdl:representation="binary" dfdl:numberRepresentation="packedDecimal" dfdl:decimalSigned="false“ > <element name="mm" type="int" dfdl:numberPattern="##“ /> <element name="dd" type="int" dfdl:numberPattern="##“ /> <element name="yy" type="int" dfdl:numberPattern="##“ /> </sequence> 4

  5. Hide Physical Layer M M D D Y Y Physical layer (hidden) Logical layer <sequence> <annotation><appinfo ...> <dfdl:hidden> <element name="pdate"> <complexType> • <sequence dfdl:representation="binary" • dfdl:numberRepresentation="packedDecimal" • dfdl:decimalSigned="false“ > • <element name="mm" type="int" • dfdl:numberPattern="##“ /> • <element name="dd" type="int" • dfdl:numberPattern="##“ /> • <element name="yy" type="int" • dfdl:numberPattern="##“ /> • </sequence> </complexType> </element> </dfdl:hidden> </appinfo></annotation> <element name="d" type="date"> … </element> 5

  6. Parsing: Calculate Logical from Physical M M D D Y Y dfdl:property annotations to avoid quoting hell <sequence> … hidden pdate here … <element name="d" type="date"> <annotation><appinfo> <dfdl:format> <dfdl:property name="inputValueCalc"> { fn:date(fn:concat(if ( ../pdate/yy > 50 ) then "19" else "20", fn:string(../pdate/yy), "-", fn:string(../pdate/mm), "-", fn:string(../pdate/dd))) } </dfdl:property> </dfdl:format> </appinfo></annotation> </element> 6

  7. Unparsing: Calculate Physical from Logical M M D D Y Y <sequence dfdl:representation="binary" dfdl:numberRepresentation="packedDecimal" dfdl:decimalSigned="false" <element name="mm" type="int" dfdl:numberPattern="##" dfdl:outputValueCalc="{ fn:month-from-date(../d) }" /> <element name="dd" type="int" dfdl:numberPattern="##" dfdl:outputValueCalc="{ fn:day-from-date(../d) }" /> <element name="yy" type="int" dfdl:numberPattern="##" dfdl:outputValueCalc="{ fn:year-from-date(../d) idiv 100 }" /> </sequence> 7

More Related