THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block |
---|
<xs:choice dfdl:choiceDispatchKey="{ dfdldaf:lookAhead(16,8) }"> <xs:element name="a" type="xs:int" dfdl:length="16" dfdl:choiceBranchKey="1"/> <xs:element name="b" type="xs:int" dfdl:length="16" dfdl:choiceBranchKey="2"/> </xs:choice> <xs:element name="tag" type="xs:int" dfdl:length="8" /> |
...
This proposal is to add the dfdl daf:lookAhead function to DPath.
...
daf:lookAhead
- dfdldaf:lookAhead(distance, bitSize)
- read bitSize bits, where the first bit is located at an offset of distance from the current location
- Restrictions
- distance >=0
- bitSize >= 0
- distance + bitSize <= Implementation defined limit no less than 512 bits
- Cannot be called during unparse
- Error if looks past EOF
- Undefined behavior if looks past document boundery when in streaming mode.
Examples
The following two elements are equivalent:
- <xs:element name="a" type="xs:unsignedInt" dfdl:length="3" dfdl:lengthUnits="bits" />
- <xs:element name="a" type="xs:unsignedInt" dfdl:length="3" dfdl:lengthUnits="bits" dfdl:inputValueCalc="{ dfdldaf:lookAhead(0,3) }" />
The following example demonstrates using lookAhead to branch based on a field in the future:
Code Block |
---|
<xs:choice dfdl:choiceDispatchKey="{ dfdldaf:lookAhead(16,8) }"> <xs:element name="a" type="xs:int" dfdl:length="16" dfdl:choiceBranchKey="1"/> <xs:element name="b" type="xs:int" dfdl:length="16" dfdl:choiceBranchKey="2"/> </xs:choice> <xs:element name="tag" type="xs:int" dfdl:length="8" /> |
...