This is an automated email from the ASF dual-hosted git repository.
slawrence pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-daffodil.git
The following commit(s) were added to refs/heads/master by this push:
new 565712f Expand the diagnostic message for dfdl:checkConstraints(.)
565712f is described below
commit 565712f05ff94bc232695b7310389f9de8f03a8e
Author: Steinberger <[email protected]>
AuthorDate: Fri Sep 4 10:02:56 2020 -0400
Expand the diagnostic message for dfdl:checkConstraints(.)
The diagnostic message only displays "." as the error.
This commit adds the full expression text to the diagnostic message
for the case of test_checkConstraintsComplexTypeFails.
This case does not invlolve inputValueCalc.
The case of test_assertFailShowsValue2 indicated in the ticket
invloves inputValueCalc and is addressed in Daffodil-1035 Lone "."
in a dfdl:inputValueCalc expression should be an error
Daffodil-1043
---
.../org/apache/daffodil/dpath/Conversions.scala | 68 +---------------------
.../org/apache/daffodil/dpath/Expression.scala | 19 +++---
.../TestPolymorphicUpwardRelativeExpressions.scala | 4 +-
.../daffodil/section07/assertions/assert.tdml | 8 +--
.../section07/assertions/TestAssertions.scala | 4 +-
5 files changed, 19 insertions(+), 84 deletions(-)
diff --git
a/daffodil-core/src/main/scala/org/apache/daffodil/dpath/Conversions.scala
b/daffodil-core/src/main/scala/org/apache/daffodil/dpath/Conversions.scala
index 952908a..8daf8f3 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/dpath/Conversions.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/dpath/Conversions.scala
@@ -17,8 +17,6 @@
package org.apache.daffodil.dpath
-import org.apache.daffodil.exceptions.Assert
-
/*
* Casting chart taken from http://www.w3.org/TR/xpath-functions/#casting, with
* types DFDL does not allow removed.
@@ -269,74 +267,14 @@ object Conversion {
case (_, Exists) => Nil
case (_, other) => {
- val (relevantExpr: Expression, detailMsg: String) =
- polymorphicExpressionDiagnostics(st, tt, context)
context.SDE(
- "In expression %s, the type %s cannot be converted to %s.%s",
- relevantExpr.text,
+ "In expression %s, the type %s cannot be converted to %s.",
+ context.wholeExpressionText,
st.globalQName.toQNameString,
- tt.globalQName.toQNameString,
- detailMsg)
+ tt.globalQName.toQNameString)
}
}
ops
}
- /**
- * Determines a better expression for use in diagnostic messages, and
computes
- * a detailed diagnostic message with one line per use of the polymorphic
expression
- * up to 4 lines of detail. (Beyond that are suppressed/ignored.)
- */
- def polymorphicExpressionDiagnostics(
- st: NodeInfo.Kind,
- tt: NodeInfo.Kind,
- context: Expression): (Expression, String) = {
- val (relevantExpr: Expression, detailMsg: String) =
- context match {
- case stepE: StepExpression => {
- val typeNodeGroups = stepE.stepElements.groupBy { _.typeNode }
- Assert.invariant(typeNodeGroups.size > 0)
- val rpp = stepE.relPathParent
- val wholePath =
- if (rpp.isAbsolutePath)
- rpp.parent.asInstanceOf[RootPathExpression]
- else
- rpp
- if (typeNodeGroups.size > 1) {
- //
- // types are not consistent for all step elements
- //
-
- val detailStrings: Seq[String] = {
- typeNodeGroups.flatMap {
- case (tn, cis) =>
- val tname = tn.globalQName.toQNameString
- val perUsePointStrings = cis.map { ci =>
- val sfl = ci.schemaFileLocation.locationDescription
- val qn = ci.namedQName.toQNameString
- val msg = "element %s in expression %s with %s type at
%s".format(
- qn, wholePath.text, tname, sfl)
- msg
- }
- perUsePointStrings
- }
- }.toSeq
- val detailPart: Seq[String] =
- if (detailStrings.length > 4)
- detailStrings.take(4) :+ "..."
- else
- detailStrings
- val detailMessage: String =
- "\nThe type is %s due to:\n%s".format(
- st.name, detailPart.mkString("\n"))
- (wholePath, detailMessage)
- } else {
- (wholePath, "")
- }
- }
- case _ => (context, "")
- }
- (relevantExpr, detailMsg)
- }
-
}
diff --git
a/daffodil-core/src/main/scala/org/apache/daffodil/dpath/Expression.scala
b/daffodil-core/src/main/scala/org/apache/daffodil/dpath/Expression.scala
index 873a333..c2f8d03 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/dpath/Expression.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/dpath/Expression.scala
@@ -623,24 +623,20 @@ case class WholeExpression(
}
if (!allowCoercion) {
- val (relevantExpr: Expression, detailMsg: String) =
- Conversion.polymorphicExpressionDiagnostics(inherentType, targetType,
subExpr)
if (tunable.allowExpressionResultCoercion) {
SDW(
WarnID.DeprecatedExpressionResultCoercion,
"In expression %s, result type (%s) should be manually cast to the
expected type (%s) with the appropriate constructor." +
- "Performing deprecated automatic conversion.%s",
- relevantExpr.text,
+ "Performing deprecated automatic conversion.",
+ wholeExpressionText,
inherentType,
- targetType,
- detailMsg)
+ targetType)
} else {
SDE(
- "In expression %s, result type (%s) must be manually cast to the
expected type (%s) with the approrpriate constructor.%s",
- relevantExpr.text,
+ "In expression %s, result type (%s) must be manually cast to the
expected type (%s) with the approrpriate constructor.",
+ wholeExpressionText,
inherentType,
- targetType,
- detailMsg)
+ targetType)
}
}
@@ -1033,7 +1029,7 @@ sealed abstract class DownStepExpression(s: String,
predArg: Option[PredicateExp
val sfl = ci.schemaFileLocation.locationDescription
val qn = ci.namedQName.toQNameString
val msg = "element %s in expression %s with %s type at
%s".format(
- qn, wholePath.text, tname, sfl)
+ qn, wholePath.wholeExpressionText, tname, sfl)
msg
}
perUsePointStrings
@@ -1058,6 +1054,7 @@ sealed abstract class DownStepExpression(s: String,
predArg: Option[PredicateExp
}
}
+
// TODO: Is ".[i]" ever a valid expression in DFDL?
// Perhaps. Doesn't work currently though. See DAFFODIL-2182
diff --git
a/daffodil-core/src/test/scala/org/apache/daffodil/dsom/TestPolymorphicUpwardRelativeExpressions.scala
b/daffodil-core/src/test/scala/org/apache/daffodil/dsom/TestPolymorphicUpwardRelativeExpressions.scala
index 9b0a9b7..3d65cc6 100644
---
a/daffodil-core/src/test/scala/org/apache/daffodil/dsom/TestPolymorphicUpwardRelativeExpressions.scala
+++
b/daffodil-core/src/test/scala/org/apache/daffodil/dsom/TestPolymorphicUpwardRelativeExpressions.scala
@@ -144,8 +144,8 @@ class TestPolymorphicUpwardRelativeExpressions extends
Logging {
}
val msg = e.getMessage()
val hasSDE = msg.contains("Schema Definition Error")
- val hasPolyInt = msg.contains("../../poly with xs:int")
- val hasPolyDate = msg.contains("../../poly with xs:date")
+ val hasPolyInt = msg.contains("../../poly eq 5 with xs:int")
+ val hasPolyDate = msg.contains("../../poly eq 5 with xs:date")
val hasDifferentPhrase = msg.contains("different types at different
points")
assertTrue(hasSDE)
assertTrue(hasPolyInt)
diff --git
a/daffodil-test/src/test/resources/org/apache/daffodil/section07/assertions/assert.tdml
b/daffodil-test/src/test/resources/org/apache/daffodil/section07/assertions/assert.tdml
index 8fd2ba4..0e0bce5 100644
---
a/daffodil-test/src/test/resources/org/apache/daffodil/section07/assertions/assert.tdml
+++
b/daffodil-test/src/test/resources/org/apache/daffodil/section07/assertions/assert.tdml
@@ -429,10 +429,10 @@
model="s1" description="Section 7 - negative test for assert expression -
DFDL-7-043R">
<tdml:document><![CDATA[1:2;3,4.]]></tdml:document>
<tdml:errors>
- <tdml:error>Parse Error</tdml:error>
- <tdml:error>Assertion failed</tdml:error>
- <tdml:error>Parsed value was:</tdml:error>
-
<tdml:error><![CDATA[<seq_02><e1>1</e1><e2>2</e2><e3>3</e3><e4>4</e4></seq_02>]]></tdml:error>
+ <tdml:error>Schema Definition Error</tdml:error>
+ <tdml:error>xs:int(.) eq 42</tdml:error>
+ <tdml:error>cannot be converted</tdml:error>
+ <tdml:error>xs:int</tdml:error>
</tdml:errors>
</tdml:parserTestCase>
diff --git
a/daffodil-test/src/test/scala/org/apache/daffodil/section07/assertions/TestAssertions.scala
b/daffodil-test/src/test/scala/org/apache/daffodil/section07/assertions/TestAssertions.scala
index 970d1db..b21155a 100644
---
a/daffodil-test/src/test/scala/org/apache/daffodil/section07/assertions/TestAssertions.scala
+++
b/daffodil-test/src/test/scala/org/apache/daffodil/section07/assertions/TestAssertions.scala
@@ -42,8 +42,8 @@ class TestAssertions {
// DAFFODIL-752
//@Test def test_assertFailShowsValue() {
runner.runOneTest("assertFailShowsValue") }
- // DFDL-1043
- // @Test def test_assertFailShowsValue2() {
runner.runOneTest("assertFailShowsValue2") }
+
+ @Test def test_assertFailShowsValue2(): Unit = {
runner.runOneTest("assertFailShowsValue2") }
@Test def test_assertFailShowsDetails(): Unit = {
runner.runOneTest("assertFailShowsDetails") }
@Test def test_assertWithWhitespace(): Unit = {
runner.runOneTest("assertWithWhitespace") }
@Test def test_assertWithWhitespaceAndCdata(): Unit = {
runner.runOneTest("assertWithWhitespaceAndCdata") }