You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Implementation

This flag member is set on infoset elements at the time they are created (parsing) or spliced into the infoset (unparsing - streaming unparser).

This works by dynamically maintaining boolean state member isInsideHiddenContext.

  1. ParseOrUnparseState has member.

    var isInsideHiddenContext : Boolean = false
  2. SequenceRuntimeData has constructor argument/member:

    val maybeHiddenGroupRefArg : Maybe[ModelGroupRuntimeData] 
    lazy val maybeHiddenGroupRef = maybeHiddenGroupRefArg // and also serialized

    with value Nope for anything except a SequenceGroupRef that has the dfdl:hiddenGroupRef property. This is a Maybe type to provide for access to the referenced group's model-group runtime data. However, for purposes of isHidden computation this is just used as a boolean flag.

  3. In the parse1 and unparse1 methods of Parser and Unparser, If
    1. the TRD of the current processor is of type SequenceRuntimeData, and
    2. trd.maybeHiddenGroupRef.isDefined, and
    3. the state.isInsideHiddenContext is currently false
    4. then invoke the parse/unparse method within a code branch that first sets the isInsideHiddenContext to true, and sets it back to false upon unwinding. Note that a try-finally type of unwind-protect could be used, but should not be necessary, as parsers are supposed to unwind the stack without throws, and all throws are fatal when unparsing.
    5. else invoke the parse/unparse method normally, which does not affect the state of isInsideHiddenContext, so if already true, it stays true, if currently false, stays false.
  4. When infoset elements are created by element combinators, (parsing), or when they are accepted and spliced into the infoset by element combinators (unparsing) they are setIsHidden(state.isInsideHiddenContext)
  5. Runtime checking for elements inside hidden groups being either defaultable, or dfdl:outputValueCalc.
    1. When an element is setIsHidden(true), then if it is of simple type it should be checked to insure it is either defaultable or dfdl:outputValueCalc, and it is a runtime SDE if not.
  6. ChoiceCombinator.unparser method computes a choiceBranchEventMap, and also determines statically which branch should be taken if the choice is hidden. Both these are parameters to the ChoiceUnparserCombinator which decides at runtime if it is unparsing an isHidden choice, and selects to use the statically determined branch if so, otherwise uses the choiceBranchEventMap.
  7. The ChoiceBranchEventMap is computed without regard for isHidden.

Test Plan/Design-for-Test

Tests should insure that elements are properly hidden if they are multiple group references away from a true dfdl:hiddenGroupRef.

Transition Plan

Releases 2.5.0 and prior did not use this technique.

Existing tests that expect to determine isHidden from ERDs of elements should be removed/rewritten, as the information is no longer available there.

Existing code that expects to find isHidden on ERDs should get it from the Infoset Element (DIElement class) directly instead.

Since we cannot know if an element will be hidden or not until runtime, many checks currently done at schema compile time must instead be done at runtime. For example, in childrenInHiddenGroupNotDefaultableOrOVC, a check is done for whether an element inside a hidden group is neither defaultable nor has dfdl:outputValueCalc. This test must be done at runtime instead as described above.

Static isHidden parameters - all these must be removed. Anything that statically depends on knowledge of isHidden must be revised to not depend on it.

Static analysis changes: many currently static attributes such as possibleFirstChildElementsInInfoset, currently depend on isHidden being statically determined. There is a specific static childrenInHiddenGroupNotDefaultableOrOVC attribute which must be removed.


  • No labels