Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added section on parse-time forward reference.

...

The XPath fn:error(...) function is suitable.

Parse-time Forward Reference

Several standards in the MIL-STD and NATO STANAG space express formats using a forward reference idiom that requires those forward references to be used at parse time.

These standards are not publicly available. They are US For-official-use-only or NATO Unclassified (which is controlled, not public), but below illustrates roughly the idiom.

This is pseudo-DFDL - because the expressions are forward referencing:

Code Block
<choice dfdl:choiceDispatchKey="{ ../key }">
  <sequence dfdl:choiceBranchKey="A">
    <element name="e1" type="xs:int"/>
    <element name="e2" type="xs:int"/>
  </sequence>
  <sequence dfdl:choiceBranchKey="B">
    <element name="e2" type="xs:long"/>
  </sequence>
</choice>
....
<element name="key" type="xs:string" dfdl:length="1"/>
....

In the above you see that the key comes after the choice. When parsing this means the parse must suspend, move past the uncertain region (the size of which has to be determined without parsing it, meaning all branches of the choice must be the same fixed predictable length), continue parsing after the uncertain region until the elements have been parsed which allow the choiceDispatchKey expression to be evaluated. At that point the parsing of the choice can be resumed, (whatever format properties were in effect at the start of the choice must be restored while it is parsed) and the result of the parse added to the infoset. Any streaming of the parse-output infoset is of course suspended until the choice can be resolved.