Description
Variable Error caused by ignored newVariableInstance in Group Annotation
(Note: repo with changes currently exists in a private repo. See comment for details on accessing the repo)
When a newVariableInstance is declared in a statement annotation in a group containing a choice, it causes an error that the variable has no defaultValue, but if the statement annotation is wrapped in a sequence with the choice, it works as expected.
The 2 below should be equivalent.
<!-- causes variable error --> <xs:annotation> <xs:appinfo source="http://www.ogf.org/dfdl/"> <dfdl:format ref="ms:msCommon" /> <dfdl:defineVariable name="messageID" type="xs:string"/> </xs:appinfo> </xs:annotation> <!-- shorthand --> <group> <annotation> <dfdl:newVariableInstance ref="cmvmf:messageID" defaultValue="{...}"/> </annotation> <choice choiceDispatchKey="{ $cmvmf:messageID}">...</choice> </group>
<!--no error--> <xs:annotation> <xs:appinfo source="http://www.ogf.org/dfdl/"> <dfdl:format ref="ms:msCommon" /> <dfdl:defineVariable name="messageID" type="xs:string"/> </xs:appinfo> </xs:annotation> <!-- shorthand --> <group> <sequence> <annotation> <dfdl:newVariableInstance ref="cmvmf:messageID" defaultValue="{...}"/> </annotation> <choice choiceDispatchKey="{ $cmvmf:messageID}">...</choice> </sequence> </group>
// variable error org.apache.daffodil.tdml.TDMLExceptionImpl: (Implementation: daffodil) RuntimeSchemaDefinitionError: Runtime Schema Definition Error: Variable Error: Variable map (runtime): variable cmvmf:messageID has no value. It was not set, and has no default value. Schema context: cmvmf:messageID Location line 53 column 14 in file:/home/okilo/git/DFDLSchemas/dfdl-noc-vmfa/target/classes/com/owlcyberdefense/mil-std-6017/xsd/vmfChoiceOfMessages.dfdl.xsd Schema context: message Location line 49 column 14 in file:/home/okilo/git/DFDLSchemas/dfdl-noc-vmfa/target/classes/com/owlcyberdefense/noc/xsd/message_content_type.dfdl.xsd Data location was preceding byte 57 limit(bytes) 78 Caused by: Runtime Schema Definition Error: Variable Error: Variable map (runtime): variable cmvmf:messageID has no value. It was not set, and has no default value. Schema context: cmvmf:messageID Location line 53 column 14 in file:/home/okilo/git/DFDLSchemas/dfdl-noc-vmfa/target/classes/com/owlcyberdefense/mil-std-6017/xsd/vmfChoiceOfMessages.dfdl.xsd Schema context: message Location line 49 column 14 in file:/home/okilo/git/DFDLSchemas/dfdl-noc-vmfa/target/classes/com/owlcyberdefense/noc/xsd/message_content_type.dfdl.xsd Data location was preceding byte 57 limit(bytes) 78 at org.apache.daffodil.processors.parsers.DoSDEMixin.doSDE(ParseErrors.scala:102) at org.apache.daffodil.processors.parsers.DoSDEMixin.doSDE$(ParseErrors.scala:95) at org.apache.daffodil.dpath.RuntimeExpressionDPath.doSDE(DPath.scala:73) at org.apache.daffodil.dpath.RuntimeExpressionDPath.handleCompileState(DPath.scala:169) at org.apache.daffodil.dpath.RuntimeExpressionDPath.handleThrow(DPath.scala:333) at org.apache.daffodil.dpath.RuntimeExpressionDPath.evaluateMaybe(DPath.scala:266) at org.apache.daffodil.dpath.RuntimeExpressionDPath.evaluate(DPath.scala:275) at org.apache.daffodil.processors.ExprEvalMixin.eval(Evaluatable.scala:404) at org.apache.daffodil.processors.ExprEvalMixin.eval$(Evaluatable.scala:398) at org.apache.daffodil.processors.EvaluatableConvertedExpression.eval(Evaluatable.scala:485) at org.apache.daffodil.processors.EvaluatableConvertedExpressionMixin.compute(Evaluatable.scala:470) at org.apache.daffodil.processors.EvaluatableConvertedExpressionMixin.compute$(Evaluatable.scala:469) at org.apache.daffodil.processors.EvaluatableConvertedExpression.compute(Evaluatable.scala:485) at org.apache.daffodil.processors.InfosetCachedEvaluatable.getCachedOrComputeAndCache(Evaluatable.scala:90) at org.apache.daffodil.processors.InfosetCachedEvaluatable.getCachedOrComputeAndCache$(Evaluatable.scala:68) at org.apache.daffodil.processors.ChoiceDispatchKeyEv.getCachedOrComputeAndCache(EvElement.scala:284) at org.apache.daffodil.processors.Evaluatable.evaluate(Evaluatable.scala:284) at org.apache.daffodil.processors.parsers.ChoiceDispatchCombinatorParser.computeDispatchKey(ElementKindParsers.scala:235) at org.apache.daffodil.processors.parsers.ChoiceDispatchCombinatorParserBase.parse(ElementKindParsers.scala:159) at org.apache.daffodil.processors.parsers.Parser.parse1(Parser.scala:82) at org.apache.daffodil.processors.parsers.Parser.parse1$(Parser.scala:76) at org.apache.daffodil.processors.parsers.CombinatorParser.parse1(Parser.scala:161) at org.apache.daffodil.processors.parsers.Unseparated.parseOne(UnseparatedSequenceParsers.scala:29) at org.apache.daffodil.processors.parsers.Unseparated.parseOne$(UnseparatedSequenceParsers.scala:27) at org.apache.daffodil.processors.parsers.ScalarOrderedUnseparatedSequenceChildParser.parseOne(UnseparatedSequenceParsers.scala:37) at org.apache.daffodil.processors.parsers.SequenceParserBase.parseOneInstanceWithMaybePoU(SequenceParserBases.scala:437) at org.apache.daffodil.processors.parsers.SequenceParserBase.parseOneInstance(SequenceParserBases.scala:422) at org.apache.daffodil.processors.parsers.SequenceParserBase.parse(SequenceParserBases.scala:265) at org.apache.daffodil.processors.parsers.Parser.parse1(Parser.scala:82) at org.apache.daffodil.processors.parsers.Parser.parse1$(Parser.scala:76) at org.apache.daffodil.processors.parsers.CombinatorParser.parse1(Parser.scala:161) at org.apache.daffodil.processors.parsers.ElementParserBase.parse(ElementCombinator1.scala:135) at org.apache.daffodil.processors.parsers.Parser.parse1(Parser.scala:82) at org.apache.daffodil.processors.parsers.Parser.parse1$(Parser.scala:76) at org.apache.daffodil.processors.parsers.CombinatorParser.parse1(Parser.scala:161) at org.apache.daffodil.processors.parsers.Unseparated.parseOne(UnseparatedSequenceParsers.scala:29) at org.apache.daffodil.processors.parsers.Unseparated.parseOne$(UnseparatedSequenceParsers.scala:27) at org.apache.daffodil.processors.parsers.RepOrderedWithMinMaxUnseparatedSequenceChildParser.parseOne(UnseparatedSequenceParsers.scala:64) at org.apache.daffodil.processors.parsers.SequenceParserBase.parseOneInstanceWithMaybePoU(SequenceParserBases.scala:437) at org.apache.daffodil.processors.parsers.SequenceParserBase.parseOneInstance(SequenceParserBases.scala:417) at org.apache.daffodil.processors.parsers.SequenceParserBase.parse(SequenceParserBases.scala:157) at org.apache.daffodil.processors.parsers.Parser.parse1(Parser.scala:82) at org.apache.daffodil.processors.parsers.Parser.parse1$(Parser.scala:76) at org.apache.daffodil.processors.parsers.CombinatorParser.parse1(Parser.scala:161) at org.apache.daffodil.processors.parsers.SeqCompParser.parse(Parser.scala:177) at org.apache.daffodil.processors.parsers.Parser.parse1(Parser.scala:82) at org.apache.daffodil.processors.parsers.Parser.parse1$(Parser.scala:76) at org.apache.daffodil.processors.parsers.CombinatorParser.parse1(Parser.scala:161) at org.apache.daffodil.processors.parsers.ElementParserBase.parse(ElementCombinator1.scala:135) at org.apache.daffodil.processors.parsers.Parser.parse1(Parser.scala:82) at org.apache.daffodil.processors.parsers.Parser.parse1$(Parser.scala:76) at org.apache.daffodil.processors.parsers.CombinatorParser.parse1(Parser.scala:161) at org.apache.daffodil.processors.parsers.Unseparated.parseOne(UnseparatedSequenceParsers.scala:29) at org.apache.daffodil.processors.parsers.Unseparated.parseOne$(UnseparatedSequenceParsers.scala:27) at org.apache.daffodil.processors.parsers.ScalarOrderedUnseparatedSequenceChildParser.parseOne(UnseparatedSequenceParsers.scala:37) at org.apache.daffodil.processors.parsers.SequenceParserBase.parseOneInstanceWithMaybePoU(SequenceParserBases.scala:437) at org.apache.daffodil.processors.parsers.SequenceParserBase.parseOneInstance(SequenceParserBases.scala:422) at org.apache.daffodil.processors.parsers.SequenceParserBase.parse(SequenceParserBases.scala:265) at org.apache.daffodil.processors.parsers.Parser.parse1(Parser.scala:82) at org.apache.daffodil.processors.parsers.Parser.parse1$(Parser.scala:76) at org.apache.daffodil.processors.parsers.CombinatorParser.parse1(Parser.scala:161) at org.apache.daffodil.processors.parsers.SpecifiedLengthParserBase.parse(SpecifiedLengthParsers.scala:76) at org.apache.daffodil.processors.parsers.Parser.parse1(Parser.scala:82) at org.apache.daffodil.processors.parsers.Parser.parse1$(Parser.scala:76) at org.apache.daffodil.processors.parsers.CombinatorParser.parse1(Parser.scala:161) at org.apache.daffodil.processors.parsers.ElementParserBase.parse(ElementCombinator1.scala:135) at org.apache.daffodil.processors.parsers.Parser.parse1(Parser.scala:82) at org.apache.daffodil.processors.parsers.Parser.parse1$(Parser.scala:76) at org.apache.daffodil.processors.parsers.CombinatorParser.parse1(Parser.scala:161) at org.apache.daffodil.processors.parsers.Unseparated.parseOne(UnseparatedSequenceParsers.scala:29) at org.apache.daffodil.processors.parsers.Unseparated.parseOne$(UnseparatedSequenceParsers.scala:27) at org.apache.daffodil.processors.parsers.ScalarOrderedUnseparatedSequenceChildParser.parseOne(UnseparatedSequenceParsers.scala:37) at org.apache.daffodil.processors.parsers.SequenceParserBase.parseOneInstanceWithMaybePoU(SequenceParserBases.scala:437) at org.apache.daffodil.processors.parsers.SequenceParserBase.parseOneInstance(SequenceParserBases.scala:422) at org.apache.daffodil.processors.parsers.SequenceParserBase.parse(SequenceParserBases.scala:265) at org.apache.daffodil.processors.parsers.Parser.parse1(Parser.scala:82) at org.apache.daffodil.processors.parsers.Parser.parse1$(Parser.scala:76) at org.apache.daffodil.processors.parsers.CombinatorParser.parse1(Parser.scala:161) at org.apache.daffodil.processors.parsers.SeqCompParser.parse(Parser.scala:177) at org.apache.daffodil.processors.parsers.Parser.parse1(Parser.scala:82) at org.apache.daffodil.processors.parsers.Parser.parse1$(Parser.scala:76) at org.apache.daffodil.processors.parsers.CombinatorParser.parse1(Parser.scala:161) at org.apache.daffodil.processors.parsers.ElementParserBase.parse(ElementCombinator1.scala:135) at org.apache.daffodil.processors.parsers.Parser.parse1(Parser.scala:82) at org.apache.daffodil.processors.parsers.Parser.parse1$(Parser.scala:76) at org.apache.daffodil.processors.parsers.CombinatorParser.parse1(Parser.scala:161) at org.apache.daffodil.processors.parsers.Unseparated.parseOne(UnseparatedSequenceParsers.scala:29) at org.apache.daffodil.processors.parsers.Unseparated.parseOne$(UnseparatedSequenceParsers.scala:27) at org.apache.daffodil.processors.parsers.ScalarOrderedUnseparatedSequenceChildParser.parseOne(UnseparatedSequenceParsers.scala:37) at org.apache.daffodil.processors.parsers.SequenceParserBase.parseOneInstanceWithMaybePoU(SequenceParserBases.scala:437) at org.apache.daffodil.processors.parsers.SequenceParserBase.parseOneInstance(SequenceParserBases.scala:422) at org.apache.daffodil.processors.parsers.SequenceParserBase.parse(SequenceParserBases.scala:265) at org.apache.daffodil.processors.parsers.Parser.parse1(Parser.scala:82) at org.apache.daffodil.processors.parsers.Parser.parse1$(Parser.scala:76) at org.apache.daffodil.processors.parsers.CombinatorParser.parse1(Parser.scala:161) at org.apache.daffodil.processors.parsers.ElementParserBase.parse(ElementCombinator1.scala:135) at org.apache.daffodil.processors.parsers.Parser.parse1(Parser.scala:82) at org.apache.daffodil.processors.parsers.Parser.parse1$(Parser.scala:76) at org.apache.daffodil.processors.parsers.CombinatorParser.parse1(Parser.scala:161) at org.apache.daffodil.processors.parsers.Unseparated.parseOne(UnseparatedSequenceParsers.scala:29) at org.apache.daffodil.processors.parsers.Unseparated.parseOne$(UnseparatedSequenceParsers.scala:27) at org.apache.daffodil.processors.parsers.RepOrderedWithMinMaxUnseparatedSequenceChildParser.parseOne(UnseparatedSequenceParsers.scala:64) at org.apache.daffodil.processors.parsers.SequenceParserBase.parseOneInstanceWithMaybePoU(SequenceParserBases.scala:437) at org.apache.daffodil.processors.parsers.SequenceParserBase.parseOneInstance(SequenceParserBases.scala:417) at org.apache.daffodil.processors.parsers.SequenceParserBase.parse(SequenceParserBases.scala:157) at org.apache.daffodil.processors.parsers.Parser.parse1(Parser.scala:82) at org.apache.daffodil.processors.parsers.Parser.parse1$(Parser.scala:76) at org.apache.daffodil.processors.parsers.CombinatorParser.parse1(Parser.scala:161) at org.apache.daffodil.processors.parsers.ElementParserBase.parse(ElementCombinator1.scala:135) at org.apache.daffodil.processors.parsers.Parser.parse1(Parser.scala:82) at org.apache.daffodil.processors.parsers.Parser.parse1$(Parser.scala:76) at org.apache.daffodil.processors.parsers.CombinatorParser.parse1(Parser.scala:161) at org.apache.daffodil.processors.DataProcessor.doParse(DataProcessor.scala:503) at org.apache.daffodil.processors.DataProcessor.parse(DataProcessor.scala:447) at org.apache.daffodil.tdml.processor.DaffodilTDMLDFDLProcessor.doParseWithBothApis(DaffodilTDMLDFDLProcessor.scala:311) at org.apache.daffodil.tdml.processor.DaffodilTDMLDFDLProcessor.parse(DaffodilTDMLDFDLProcessor.scala:248) at org.apache.daffodil.tdml.processor.DaffodilTDMLDFDLProcessor.parse(DaffodilTDMLDFDLProcessor.scala:253) at org.apache.daffodil.tdml.ParserTestCase.doParseExpectSuccess(TDMLRunner.scala:1069) ... 33 more Caused by: Variable Error: Variable map (runtime): variable cmvmf:messageID has no value. It was not set, and has no default value. Schema context: cmvmf:messageID Location line 53 column 14 in file:/home/okilo/git/DFDLSchemas/dfdl-noc-vmfa/target/classes/com/owlcyberdefense/mil-std-6017/xsd/vmfChoiceOfMessages.dfdl.xsd