The issues identified in Analysis: Schema Compiler Backpointers/Copying require some design and test planning.
IsHidden
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.
ParseOrUnparseState has member.
var isInsideHiddenContext : Boolean = false
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.
- In the parse1 and unparse1 methods of Parser and Unparser, If
- the TRD of the current processor is of type SequenceRuntimeData, and
- trd.maybeHiddenGroupRef.isDefined, and
- the state.isInsideHiddenContext is currently false
- 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.
- 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.
- 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)
Test Plan/Design-for-Test
Existing tests that expect to determine isHidden from ERDs of elements should be removed/rewritten, as the information is no longer available there.
Tests should insure that elements are properly hidden if they are multiple group references away from a true dfdl:hiddenGroupRef.