Good Afternoon Steve,
I appreciate the quick response. If I were dealing with powers of 10, the solution you suggest would be perfect, but unfortunately, I’m not that lucky. Instead, we have scores of fixed-point types with deltas such as 360 degrees encoded in 8 bits (i.e. 360/(2^8). To define such a type, we use the technique below: <schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dfdl=" http://www.ogf.org/dfdl/dfdl-1.0/"> <simpleType name="SomeElementType"> <restriction base="xs:float"> <minInclusive value="0.0"/> <maxInclusive value="358.59375"/> </restriction> </simpleType> <complexType name="SomeComplexType"> <sequence> <group dfdl:hiddenGroupRef="HiddenSomeComplexTypeSomeElementGroup"/> <element name="SomeElement" type="SomeElementType"> <annotation> <appinfo source="http:www.ogf.org/dfdl/"> <dfdl:element inputValueCalc="{xs:float(../RawValue * 1.40625)}"/> </appinfo> </annotation> </element> </sequence> </complexType> <group name="HiddenSomeComplexTypeSomeElementGroup"> <sequence> <element name="RawValue" type="xs:unsignedInt"> <annotation> <appinfo source="http:www.ogf.org/dfdl/"> <dfdl:element length="8" lengthKind="explicit" lengthUnits="bits" outputValueCalc="{xs:unsignedInt(../SomeElement div 1.40625)}"/> </appinfo> </annotation> </element> </sequence> </group> </schema> It would be ideal to reduce this to something similar to: <schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dfdl=" http://www.ogf.org/dfdl/dfdl-1.0/"> <simpleType name="SomeElementType"> <restriction base="xs:float"> <minInclusive value="0.0"/> <maxInclusive value="358.59375"/> </restriction> </simpleType> <complexType name="SomeComplexType"> <sequence> <sequence dfdlx:layer="FixedPointLayer" dfdl:newVariableInstance ref="fixed_point_layer:delta" defaultValue="1.40625"> <element name="SomeElement" type="SomeElementType"/> </sequence> </sequence> </complexType> </schema> Thanks, Sean From: *Steve Lawrence* <*[email protected] <[email protected]>*> Date: Thu, Oct 16, 2025 at 1:45 PM Subject: RE: Fixed-Point Layer To: <*[email protected] <[email protected]>*> CC: Sean Callahan <*[email protected] <[email protected]>*> Are you able to use dfdl:binaryDecimalVirtualPoint? For example: <element name="cost" type="xs:decimal" dfdl:representation="binary" dfdl:binaryNumberRep="binary" dfdl:byteOrder="bigEndian" dfdl:lengthKind="explicit" dfdl:length="4" dfdl:lengthUnits="bytes" dfdl:binaryDecimalVirtualPoint="2" /> This parses a 4-byte binary integer that represents a cost in cents. The binaryDecimalVirtualPoint="2" then shifts the decimal to the left by 2 so the value in the infoset becomes dollars and cents. For example, 12345 becomes 123.45 If you're looking for something different, can you give an example? (I've CC'd you directly since you're not subscribed to the list. You may want to join to see any follow-up discussion.) On 2025/10/16 11:24:13 Sean Callahan wrote: > Good Morning Folks, > > If it hasn’t already been suggested, a fixed-point (vs floating-point) > layer would be an excellent addition to the distribution. Currently, the > only alternative is hidden groups, which isn’t intuitive and quickly > clutters a schema. > > Thanks, > > Sean Callahan >
