diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/ElementBase.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/ElementBase.scala index d057b696c3..3992415bcd 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/ElementBase.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/ElementBase.scala @@ -1007,13 +1007,19 @@ trait ElementBase "The length facet or minLength/maxLength facets are not allowed on types derived from type %s.\nThey are allowed only on types derived from string and hexBinary.", pt.name ) - val res = (hasLength, hasMinLength, hasMaxLength, lengthKind) match { - case (true, false, false, _) => (r.lengthValue, r.lengthValue) - case (true, _, _, _) => + val res = ( + hasLength, + hasMinLength, + hasMaxLength, + lengthKind, + isRepresented + ) match { + case (true, false, false, _, _) => (r.lengthValue, r.lengthValue) + case (true, _, _, _, _) => Assert.invariantFailed( "Facet length cannot be defined with minLength and maxLength facets" ) - case (false, true, true, LengthKind.Implicit) => { + case (false, true, true, LengthKind.Implicit, true) => { schemaDefinitionUnless( r.minLengthValue.compareTo(r.maxLengthValue) == 0, "The minLength and maxLength must be equal for type %s with lengthKind='implicit'. Values were minLength of %s, maxLength of %s.", @@ -1023,7 +1029,7 @@ trait ElementBase ) (r.minLengthValue, r.maxLengthValue) } - case (false, true, true, _) => { + case (false, true, true, _, _) => { schemaDefinitionWhen( r.minLengthValue.compareTo(r.maxLengthValue) > 0, // always true, so we don't bother to specify the type in the message. @@ -1033,13 +1039,13 @@ trait ElementBase ) (r.minLengthValue, r.maxLengthValue) } - case (false, _, _, LengthKind.Implicit) => + case (false, _, _, LengthKind.Implicit, true) => SDE( "When lengthKind='implicit', both minLength and maxLength facets must be specified." ) - case (false, false, true, _) => (zeroBD, r.maxLengthValue) - case (false, false, false, _) => (zeroBD, unbBD) - case (false, true, false, _) => (r.minLengthValue, unbBD) + case (false, false, true, _, _) => (zeroBD, r.maxLengthValue) + case (false, false, false, _, _) => (zeroBD, unbBD) + case (false, true, false, _, _) => (r.minLengthValue, unbBD) case _ => Assert.impossible() } res diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section17/calc_value_properties/inputValueCalc.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section17/calc_value_properties/inputValueCalc.tdml index 16522b2ed9..b5c7433f79 100644 --- a/daffodil-test/src/test/resources/org/apache/daffodil/section17/calc_value_properties/inputValueCalc.tdml +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section17/calc_value_properties/inputValueCalc.tdml @@ -1407,4 +1407,28 @@ + + + + + + + + + + + + + + + + + + + Hello World + + + diff --git a/daffodil-test/src/test/scala/org/apache/daffodil/section17/calc_value_properties/TestInputValueCalc.scala b/daffodil-test/src/test/scala/org/apache/daffodil/section17/calc_value_properties/TestInputValueCalc.scala index 307bf00a46..0e630b0b87 100644 --- a/daffodil-test/src/test/scala/org/apache/daffodil/section17/calc_value_properties/TestInputValueCalc.scala +++ b/daffodil-test/src/test/scala/org/apache/daffodil/section17/calc_value_properties/TestInputValueCalc.scala @@ -244,4 +244,9 @@ class TestInputValueCalc { runner.runOneTest("InputValueCalc_array_elem") } // @Test def test_InputValueCalc_global_elem() { runner.runOneTest("InputValueCalc_global_elem") } + + // DFDL-2806 + @Test def test_IVC_ignored_length_checks(): Unit = { + runner.runOneTest("IVC_ignored_length_checks") + } }