You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by sl...@apache.org on 2019/01/11 14:03:35 UTC

[incubator-daffodil] branch master updated: Restrict coercion of a whole expression

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 a2f56a3  Restrict coercion of a whole expression
a2f56a3 is described below

commit a2f56a3f44d307a138fb7a4614f873120e186d63
Author: Steve Lawrence <sl...@apache.org>
AuthorDate: Thu Dec 13 12:00:43 2018 -0500

    Restrict coercion of a whole expression
    
    - While we allow coercion within an expression according to XPath, we do
      not want to always allow coercion to the target expression type. For
      example, if the target type of an expression is an xs:string, we do
      not want to coerce { 5 } to the string "5"--the expression should
      instead be { "5" } or { xs:string(5) }. To maintain usability, this
      change allows coercion, but limits it only to similar types where no
      loss of information/precision will occur. It is now an SDE if the
      types cannot be coerced. This required changing tests that were too
      lax and relied on incorrect type coercion.
    - Fixed a revealed bug where floats were incorrectly coerced to doubles
      when added/subtracted instead of staying floats.
    - Fixed a revealed bug where the round-half-to-even function did not
      properly carry the parameter type through to the result type, which
      resulted it incorrect coercion and sometimes an exception.
    
    DAFFODIL-2021, DAFFODIL-1044, DAFFODIL-2043
---
 .../org/apache/daffodil/dpath/Expression.scala     |  76 +++++++-
 .../org/apache/daffodil/dpath/NodeInfoUtils.scala  |   4 +-
 .../daffodil/dpath/TestDFDLExpressionTree.scala    |   4 +-
 .../apache/daffodil/dsom/TestInputValueCalc.scala  |   2 +-
 .../daffodil/section05/simple_types/Boolean.tdml   |  11 +-
 .../section07/discriminators/discriminator.tdml    |   8 +-
 .../section07/escapeScheme/escapeScheme.tdml       |   4 +-
 .../daffodil/section07/variables/variables.tdml    |   4 +-
 .../section07/variables/variables_01.dfdl.xsd      |   6 +-
 .../section14/sequence_groups/SequenceGroup.tdml   |  14 +-
 .../calc_value_properties/inputValueCalc.tdml      |  36 ++--
 .../calc_value_properties/outputValueCalc.tdml     |  26 +--
 .../calc_value_properties/outputValueCalc2.tdml    |  10 +-
 .../section23/dfdl_expressions/expressions.tdml    | 173 +++++++++++------
 .../section23/dfdl_expressions/expressions2.tdml   |   6 +-
 .../section23/dfdl_functions/Functions.tdml        | 208 ++++++++++++++-------
 .../TestDFDLExpressionsDebug.scala                 |   3 -
 .../dfdl_expressions/TestDFDLExpressions.scala     |   8 +-
 18 files changed, 406 insertions(+), 197 deletions(-)

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 03e5309..eeb6920 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
@@ -583,7 +583,41 @@ case class WholeExpression(
     // because if ifor was a function call, then the resulting function
     // object will have been created and given this as its parent pointer.
     //
-    Assert.invariant(subExpr == ifor | ifor.isInstanceOf[FunctionCallExpression])
+    Assert.invariant(subExpr == ifor || ifor.isInstanceOf[FunctionCallExpression])
+
+    // The result of this function will be used to coerce the result of the
+    // expression to the target type. However, we do not always want to allow
+    // type coercion even when it might be possible. For example, if the
+    // targetType is xs:string and the expression is { 5 }, we do not want to
+    // coerce that to the string "5", but instead want to throw an SDE
+    // signifying that we expected a string but the expression result was a
+    // numeric. But we sometimes do want coercion for usability purposes. For
+    // example, if the result of an expression is a int but the type is long,
+    // then we should still allow that coercion. Below we allow coercion
+    // between decimal-like types where precision would not be lost, and all
+    // integer-like types (which check for precision loss when evaluated).
+
+    val allowCoercion = (inherentType, targetType) match {
+      case (_, _) if inherentType == targetType => true
+      case (_, _) if (inherentType.isSubtypeOf(NodeInfo.String) && targetType.isSubtypeOf(NodeInfo.String)) => true
+      case (_, _) if (inherentType.isSubtypeOf(NodeInfo.Integer) && targetType.isSubtypeOf(NodeInfo.Integer)) => true
+      case (_, NodeInfo.Float) if (inherentType.isSubtypeOf(NodeInfo.Integer)) => true
+      case (_, NodeInfo.Double) if (inherentType.isSubtypeOf(NodeInfo.Integer)) => true
+      case (_, NodeInfo.Decimal) if (inherentType.isSubtypeOf(NodeInfo.Integer)) => true
+      case (NodeInfo.Float, NodeInfo.Double) => true
+      case (NodeInfo.Float, NodeInfo.Decimal) => true
+      case (NodeInfo.Double, NodeInfo.Decimal) => true
+      case (NodeInfo.Nothing, _) => true
+      case (_, NodeInfo.AnyType) => true
+      case _ => false
+    }
+
+    if (!allowCoercion) {
+      SDE("Expression result type (%s) cannot be coerced to the expected type (%s)",
+        inherentType,
+        targetType)
+    }
+
     targetType
   }
 
@@ -1502,13 +1536,13 @@ case class FunctionCallExpression(functionQNameString: String, expressions: List
       }
 
       case (RefQName(_, "round-half-to-even", FUNC), args) if args.length == 1 => {
-        FNOneArgExpr(functionQNameString, functionQName, args,
-          NodeInfo.Numeric, NodeInfo.Numeric, FNRoundHalfToEven1(_, _))
+        FNOneArgMathExpr(functionQNameString, functionQName, args,
+          FNRoundHalfToEven1(_, _))
       }
 
       case (RefQName(_, "round-half-to-even", FUNC), args) => {
-        FNTwoArgsExpr(functionQNameString, functionQName, args,
-          NodeInfo.Numeric, NodeInfo.Numeric, NodeInfo.Integer, FNRoundHalfToEven2(_))
+        FNTwoArgsMathExpr(functionQNameString, functionQName, args,
+          NodeInfo.Integer, FNRoundHalfToEven2(_))
       }
 
       case (RefQName(_, "string-length", FUNC), args) => {
@@ -1764,6 +1798,38 @@ case class FNOneArgMathExpr(nameAsParsed: String, fnQName: RefQName,
   }
 }
 
+/**
+ * Preserves the inherent type of the argument to the function as the type of
+ * the result, that is if the argument type is a numeric type, and if the
+ * argument type is a subtype thereof. The inherent type comes from the first
+ * argument
+ */
+case class FNTwoArgsMathExpr(nameAsParsed: String, fnQName: RefQName,
+  args: List[Expression], arg2Type: NodeInfo.Kind, constructor: List[CompiledDPath] => RecipeOp)
+  extends FNTwoArgsExprBase(nameAsParsed, fnQName, args, NodeInfo.Numeric, NodeInfo.Numeric, arg2Type, constructor) {
+
+  override lazy val inherentType = {
+    schemaDefinitionUnless(argInherentType.isSubtypeOf(NodeInfo.Numeric),
+      "First argument must be of numeric type but was %s.", argInherentType)
+    argInherentType
+  }
+
+  lazy val argInherentType = {
+    schemaDefinitionUnless(args.length == 2, "Function %s takes 2 arguments.",
+      fnQName.toPrettyString)
+    args(0).inherentType
+  }
+
+  override def targetTypeForSubexpression(subexp: Expression): NodeInfo.Kind = {
+    if (subexp == arg1)
+      inherentType
+    else if (subexp == arg2)
+      arg2Type
+    else
+      Assert.invariantFailed("subexpression %s is not an argument.".format(subexp))
+  }
+}
+
 case class FNZeroArgExpr(nameAsParsed: String, fnQName: RefQName,
   resultType: NodeInfo.Kind, argType: NodeInfo.Kind, constructor: (CompiledDPath, NodeInfo.Kind) => RecipeOp)
   extends FunctionCallBase(nameAsParsed, fnQName, Nil) {
diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/dpath/NodeInfoUtils.scala b/daffodil-core/src/main/scala/org/apache/daffodil/dpath/NodeInfoUtils.scala
index a6424bd..8d9052f 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/dpath/NodeInfoUtils.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/dpath/NodeInfoUtils.scala
@@ -109,8 +109,8 @@ object NodeInfoUtils {
       case (Decimal, _) => (Decimal, Decimal)
       case (_, Double) => (Double, Double)
       case (Double, _) => (Double, Double)
-      case (_, Float) => (Double, Double)
-      case (Float, _) => (Double, Double)
+      case (_, Float) => (Float, Float)
+      case (Float, _) => (Float, Float)
       case (_, Integer) => (Integer, Integer)
       case (Integer, _) => (Integer, Integer)
       case (_, NonNegativeInteger) => (NonNegativeInteger, Integer)
diff --git a/daffodil-core/src/test/scala/org/apache/daffodil/dpath/TestDFDLExpressionTree.scala b/daffodil-core/src/test/scala/org/apache/daffodil/dpath/TestDFDLExpressionTree.scala
index 35089a5..9d0e849 100644
--- a/daffodil-core/src/test/scala/org/apache/daffodil/dpath/TestDFDLExpressionTree.scala
+++ b/daffodil-core/src/test/scala/org/apache/daffodil/dpath/TestDFDLExpressionTree.scala
@@ -84,7 +84,7 @@ class TestDFDLExpressionTree extends Parsers {
   val aSchema = SchemaUtils.dfdlTestSchema(
     <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>,
     <dfdl:format ref="tns:GeneralFormat"/>,
-    <xs:element name="a" type="xs:string" dfdl:lengthKind="explicit" dfdl:length="{ xs:unsignedInt(5) }"/>)
+    <xs:element name="a" type="xs:string" dfdl:lengthKind="explicit" dfdl:length="{ xs:string(xs:unsignedInt(5)) }"/>)
 
   @Test def test_a() = {
     testExpr2(aSchema, "{ /tns:a }") { (ce, erd) =>
@@ -107,7 +107,7 @@ class TestDFDLExpressionTree extends Parsers {
       <xs:complexType>
         <xs:sequence>
           <xs:element name="i" type="xs:int" dfdl:lengthKind="explicit" dfdl:length="2"/>
-          <xs:element name="a" maxOccurs="2" type="xs:string" dfdl:lengthKind="explicit" dfdl:length="{ xs:unsignedInt(5) }"/>
+          <xs:element name="a" maxOccurs="2" type="xs:string" dfdl:lengthKind="explicit" dfdl:length="{ xs:string(xs:unsignedInt(5)) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>)
diff --git a/daffodil-core/src/test/scala/org/apache/daffodil/dsom/TestInputValueCalc.scala b/daffodil-core/src/test/scala/org/apache/daffodil/dsom/TestInputValueCalc.scala
index bbcd18b..1e28f89 100644
--- a/daffodil-core/src/test/scala/org/apache/daffodil/dsom/TestInputValueCalc.scala
+++ b/daffodil-core/src/test/scala/org/apache/daffodil/dsom/TestInputValueCalc.scala
@@ -29,7 +29,7 @@ class TestInputValueCalc extends Logging {
     val testSchema = SchemaUtils.dfdlTestSchema(
       <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>,
       <dfdl:format ref="tns:GeneralFormat"/>,
-      <xs:element name="data" type="xs:string" dfdl:textNumberRep="standard" dfdl:representation="text" dfdl:terminator="" dfdl:emptyValueDelimiterPolicy="none" dfdl:inputValueCalc="{ 42 }" dfdl:initiator="" dfdl:lengthKind="explicit" dfdl:length="1"/>)
+      <xs:element name="data" type="xs:string" dfdl:textNumberRep="standard" dfdl:representation="text" dfdl:terminator="" dfdl:emptyValueDelimiterPolicy="none" dfdl:inputValueCalc="{ xs:string(42) }" dfdl:initiator="" dfdl:lengthKind="explicit" dfdl:length="1"/>)
     val (_, actual) = TestUtils.testString(testSchema, "")
     val expected: Node = <data>42</data>
     TestUtils.assertEqualsXMLElements(expected, actual)
diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section05/simple_types/Boolean.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section05/simple_types/Boolean.tdml
index 5e18d0c..0bc5d22 100644
--- a/daffodil-test/src/test/resources/org/apache/daffodil/section05/simple_types/Boolean.tdml
+++ b/daffodil-test/src/test/resources/org/apache/daffodil/section05/simple_types/Boolean.tdml
@@ -118,7 +118,7 @@
           <xs:sequence dfdl:separator="," dfdl:terminator=";">
             <xs:element name="y" type="xs:boolean" maxOccurs="unbounded" dfdl:textTrimKind="padChar"
               dfdl:textBooleanJustification="center"
-              dfdl:textBooleanTrueRep="{ 5-3 }" dfdl:textBooleanFalseRep="{'a b c'}" />
+              dfdl:textBooleanTrueRep="{ xs:string(5-3) }" dfdl:textBooleanFalseRep="{'a b c'}" />
           </xs:sequence>
         </xs:sequence>
       </xs:complexType>
@@ -134,7 +134,7 @@
           <xs:sequence dfdl:separator="," dfdl:terminator=";">
             <xs:element name="y" type="xs:boolean" maxOccurs="unbounded" dfdl:textTrimKind="padChar"
               dfdl:textBooleanJustification="center"
-              dfdl:textBooleanTrueRep="{ 5-3 }" dfdl:textBooleanFalseRep="{'a b c'}" dfdl:ignoreCase="yes" />
+              dfdl:textBooleanTrueRep="{ xs:string(5-3) }" dfdl:textBooleanFalseRep="{'a b c'}" dfdl:ignoreCase="yes" />
           </xs:sequence>
         </xs:sequence>
       </xs:complexType>
@@ -173,12 +173,13 @@
           <xs:element name="b" type="xs:string" />
           <xs:sequence dfdl:separator="," dfdl:terminator=";">
             <xs:element name="x" type="xs:boolean" maxOccurs="unbounded"
-              dfdl:textBooleanTrueRep="{ dfdl:valueLength( ../ex:a, 'bytes') }" dfdl:textBooleanFalseRep="{ dfdl:valueLength( ../ex:b, 'bytes') }" />
+              dfdl:textBooleanTrueRep="{ xs:string(dfdl:valueLength( ../ex:a, 'bytes')) }"
+              dfdl:textBooleanFalseRep="{ xs:string(dfdl:valueLength( ../ex:b, 'bytes')) }" />
           </xs:sequence>
           <xs:element name="c" type="xs:boolean"
-            dfdl:textBooleanTrueRep="{ dfdl:valueLength( ../ex:a, 'bytes') }" dfdl:textBooleanFalseRep="no" />
+            dfdl:textBooleanTrueRep="{ xs:string(dfdl:valueLength( ../ex:a, 'bytes')) }" dfdl:textBooleanFalseRep="no" />
           <xs:element name="d" type="xs:boolean"
-            dfdl:textBooleanTrueRep="{ dfdl:valueLength( ../ex:c, 'bytes') }" dfdl:textBooleanFalseRep="no" />
+            dfdl:textBooleanTrueRep="{ xs:string(dfdl:valueLength( ../ex:c, 'bytes')) }" dfdl:textBooleanFalseRep="no" />
         </xs:sequence>
       </xs:complexType>
     </xs:element>
diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section07/discriminators/discriminator.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section07/discriminators/discriminator.tdml
index 2bf4adf..a4e4c87 100644
--- a/daffodil-test/src/test/resources/org/apache/daffodil/section07/discriminators/discriminator.tdml
+++ b/daffodil-test/src/test/resources/org/apache/daffodil/section07/discriminators/discriminator.tdml
@@ -787,11 +787,11 @@
         <xs:sequence>
           <xs:annotation>
             <xs:appinfo source="http://www.ogf.org/dfdl/">
-              <dfdl:setVariable ref="ex:var">{ 41 }</dfdl:setVariable>
+              <dfdl:setVariable ref="ex:var">{ xs:string(41) }</dfdl:setVariable>
               <dfdl:discriminator testKind="pattern" testPattern="o_o" message="Discriminator failed for pattern 'o_o'" />
             </xs:appinfo>
           </xs:annotation>
-          <xs:element name="e1" dfdl:lengthKind="explicit" dfdl:length="2" type="xs:int" dfdl:inputValueCalc="{ $ex:var }"/>
+          <xs:element name="e1" dfdl:lengthKind="explicit" dfdl:length="2" type="xs:int" dfdl:inputValueCalc="{ xs:int($ex:var) }"/>
           <xs:element name="extra" type="xs:string" dfdl:lengthKind="delimited" />
         </xs:sequence>
       </xs:complexType>
@@ -802,11 +802,11 @@
         <xs:sequence>
           <xs:annotation>
             <xs:appinfo source="http://www.ogf.org/dfdl/">
-              <dfdl:setVariable ref="ex:var">{ 41 }</dfdl:setVariable>
+              <dfdl:setVariable ref="ex:var">{ xs:string(41) }</dfdl:setVariable>
               <dfdl:discriminator testKind="pattern" testPattern="41" message="Discriminator failed for pattern '41'" />
             </xs:appinfo>
           </xs:annotation>
-          <xs:element name="e1" dfdl:lengthKind="explicit" dfdl:length="2" type="xs:int" dfdl:inputValueCalc="{ $ex:var }"/>
+          <xs:element name="e1" dfdl:lengthKind="explicit" dfdl:length="2" type="xs:int" dfdl:inputValueCalc="{ xs:int($ex:var) }"/>
           <xs:element name="extra" type="xs:string" dfdl:lengthKind="delimited" />
         </xs:sequence>
       </xs:complexType>
diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section07/escapeScheme/escapeScheme.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section07/escapeScheme/escapeScheme.tdml
index 360e5ef..f437b53 100644
--- a/daffodil-test/src/test/resources/org/apache/daffodil/section07/escapeScheme/escapeScheme.tdml
+++ b/daffodil-test/src/test/resources/org/apache/daffodil/section07/escapeScheme/escapeScheme.tdml
@@ -310,8 +310,8 @@
     </dfdl:defineEscapeScheme>
     
     <dfdl:defineEscapeScheme name="fromData3">
-      <dfdl:escapeScheme escapeCharacter="{ xs:int(../tns:escapeChar) - 3 }"
-        escapeKind="escapeCharacter" escapeEscapeCharacter="{ xs:int(fn:ceiling(xs:float(../tns:escapeEscapeChar))) }" extraEscapedCharacters="" generateEscapeBlock="whenNeeded" />
+      <dfdl:escapeScheme escapeCharacter="{ xs:string(xs:int(../tns:escapeChar) - 3) }"
+        escapeKind="escapeCharacter" escapeEscapeCharacter="{ xs:string(xs:int(fn:ceiling(xs:float(../tns:escapeEscapeChar)))) }" extraEscapedCharacters="" generateEscapeBlock="whenNeeded" />
     </dfdl:defineEscapeScheme>
 
     <xs:element name="e1">
diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section07/variables/variables.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section07/variables/variables.tdml
index a7465f2..2e51bf6 100644
--- a/daffodil-test/src/test/resources/org/apache/daffodil/section07/variables/variables.tdml
+++ b/daffodil-test/src/test/resources/org/apache/daffodil/section07/variables/variables.tdml
@@ -557,7 +557,7 @@
           <xs:element name="one" type="xs:int" dfdl:inputValueCalc="{ $ex:v_with_default }" dfdl:lengthKind="delimited">
             <xs:annotation>
               <xs:appinfo source="http://www.ogf.org/dfdl/">
-                <dfdl:setVariable ref="ex:v_no_default">{ "BEEEP" }</dfdl:setVariable>
+                <dfdl:setVariable ref="ex:v_no_default">{ xs:int("BEEEP") }</dfdl:setVariable>
               </xs:appinfo>
             </xs:annotation>
           </xs:element>
@@ -592,7 +592,7 @@
           <xs:element name="one" type="xs:string" dfdl:lengthKind="delimited">
             <xs:annotation>
               <xs:appinfo source="http://www.ogf.org/dfdl/">
-                <dfdl:setVariable ref="ex:holder2" value="{ (.) }" />
+                <dfdl:setVariable ref="ex:holder2" value="{ xs:int(.) }" />
               </xs:appinfo>
             </xs:annotation>
           </xs:element>
diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section07/variables/variables_01.dfdl.xsd b/daffodil-test/src/test/resources/org/apache/daffodil/section07/variables/variables_01.dfdl.xsd
index 6608626..6d7dbea 100644
--- a/daffodil-test/src/test/resources/org/apache/daffodil/section07/variables/variables_01.dfdl.xsd
+++ b/daffodil-test/src/test/resources/org/apache/daffodil/section07/variables/variables_01.dfdl.xsd
@@ -76,7 +76,7 @@
   <xs:group name="h_e">
     <xs:sequence>
       <xs:element name="e" type="xsd:string" dfdl:lengthKind="delimited"
-          dfdl:outputValueCalc="{ $ex:v_no_default }" />
+          dfdl:outputValueCalc="{ xs:string($ex:v_no_default) }" />
     </xs:sequence>
   </xs:group>
   
@@ -86,7 +86,7 @@
         <xs:element name="d" type="xsd:string" dfdl:lengthKind="delimited">
           <xs:annotation>
             <xs:appinfo source="http://www.ogf.org/dfdl/">
-              <dfdl:setVariable ref="ex:v_no_default">{ . }</dfdl:setVariable>
+              <dfdl:setVariable ref="ex:v_no_default">{ xs:int(.) }</dfdl:setVariable>
             </xs:appinfo>
           </xs:annotation>
         </xs:element>
@@ -127,4 +127,4 @@
     </xs:complexType>
   </xs:element>
 
-</xsd:schema>
\ No newline at end of file
+</xsd:schema>
diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section14/sequence_groups/SequenceGroup.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section14/sequence_groups/SequenceGroup.tdml
index f6385ff..314e205 100644
--- a/daffodil-test/src/test/resources/org/apache/daffodil/section14/sequence_groups/SequenceGroup.tdml
+++ b/daffodil-test/src/test/resources/org/apache/daffodil/section14/sequence_groups/SequenceGroup.tdml
@@ -984,11 +984,11 @@ more ignored input
   <xs:group name="data">
     <xs:sequence dfdl:separator="">
       <xs:element name="_x" type="xs:int" dfdl:representation="text"
-        dfdl:terminator="%NL;" dfdl:outputValueCalc="{ ../ex:x }" />
+        dfdl:terminator="%NL;" dfdl:outputValueCalc="{ xs:int(../ex:x) }" />
       <xs:element name="_y" type="xs:int" dfdl:representation="text"
-        dfdl:terminator="%NL;" dfdl:outputValueCalc="{ ../ex:y }" />
+        dfdl:terminator="%NL;" dfdl:outputValueCalc="{ xs:int(../ex:y) }" />
       <xs:element name="_z" type="xs:int" dfdl:representation="text"
-        dfdl:terminator="%NL;" dfdl:outputValueCalc="{ ../ex:z }" />
+        dfdl:terminator="%NL;" dfdl:outputValueCalc="{ xs:int(../ex:z) }" />
     </xs:sequence>
   </xs:group>
 
@@ -1002,11 +1002,11 @@ more ignored input
           dfdl:inputValueCalc="{ /ex:table/ex:_x + /ex:table/ex:_y + /ex:table/ex:_z }" />
         <xs:element name="concat" type="xs:string"
           dfdl:inputValueCalc="{ fn:concat(fn:concat(/ex:table/ex:_x,/ex:table/ex:_y),/ex:table/ex:_z) }" />
-        <xs:element name="x" type="xs:string" dfdl:inputValueCalc="{ ../ex:_x }" />
-        <xs:element name="y" type="xs:string" dfdl:inputValueCalc="{ ../ex:_y }" />
-        <xs:element name="z" type="xs:string" dfdl:inputValueCalc="{ ../ex:_z }" />
+        <xs:element name="x" type="xs:string" dfdl:inputValueCalc="{ xs:string(../ex:_x) }" />
+        <xs:element name="y" type="xs:string" dfdl:inputValueCalc="{ xs:string(../ex:_y) }" />
+        <xs:element name="z" type="xs:string" dfdl:inputValueCalc="{ xs:string(../ex:_z) }" />
         <xs:element name="productAgain" type="xs:string"
-          dfdl:inputValueCalc="{ ../ex:product }" />
+          dfdl:inputValueCalc="{ xs:string(../ex:product) }" />
       </xs:sequence>
     </xs:complexType>
   </xs:element>
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 887fbc0..13da5e8 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
@@ -79,7 +79,7 @@
             dfdl:lengthKind="delimited" />
           <xs:element name="e3" type="xs:int"
             dfdl:lengthKind="delimited" />
-          <xs:element name="divide" type="xs:int"
+          <xs:element name="divide" type="xs:float"
             dfdl:inputValueCalc="{ xs:int(../ex:e2) div xs:int(../ex:e3) }" />
         </xs:sequence>
       </xs:complexType>
@@ -181,7 +181,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="num" type="xs:string" />
-          <xs:element name="ivc_int_range_min" type="xs:int" dfdl:inputValueCalc="{ ../ex:num }"/>
+          <xs:element name="ivc_int_range_min" type="xs:int" dfdl:inputValueCalc="{ xs:int(../ex:num) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -199,7 +199,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="num" type="xs:string" />
-          <xs:element name="ivc_int_range_max" type="xs:int" dfdl:inputValueCalc="{ ../ex:num }"/>
+          <xs:element name="ivc_int_range_max" type="xs:int" dfdl:inputValueCalc="{ xs:int(../ex:num) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -235,7 +235,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="num" type="xs:string" />
-          <xs:element name="ivc_short_range_min" type="xs:short" dfdl:inputValueCalc="{ ../ex:num }"/>
+          <xs:element name="ivc_short_range_min" type="xs:short" dfdl:inputValueCalc="{ xs:short(../ex:num) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -253,7 +253,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="num" type="xs:string" />
-          <xs:element name="ivc_short_range_max" type="xs:short" dfdl:inputValueCalc="{ ../ex:num }"/>
+          <xs:element name="ivc_short_range_max" type="xs:short" dfdl:inputValueCalc="{ xs:short(../ex:num) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -289,7 +289,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="num" type="xs:string" />
-          <xs:element name="ivc_uint_range_min" type="xs:unsignedInt" dfdl:inputValueCalc="{ ../ex:num }"/>
+          <xs:element name="ivc_uint_range_min" type="xs:unsignedInt" dfdl:inputValueCalc="{ xs:unsignedInt(../ex:num) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -307,7 +307,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="num" type="xs:string" />
-          <xs:element name="ivc_uint_range_max" type="xs:unsignedInt" dfdl:inputValueCalc="{ ../ex:num }"/>
+          <xs:element name="ivc_uint_range_max" type="xs:unsignedInt" dfdl:inputValueCalc="{ xs:unsignedInt(../ex:num) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -334,7 +334,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="num" type="xs:string" />
-          <xs:element name="ivc_ushort_range_min" type="xs:unsignedShort" dfdl:inputValueCalc="{ ../ex:num }"/>
+          <xs:element name="ivc_ushort_range_min" type="xs:unsignedShort" dfdl:inputValueCalc="{ xs:unsignedShort(../ex:num) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -352,7 +352,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="num" type="xs:string" />
-          <xs:element name="ivc_ushort_range_max" type="xs:unsignedShort" dfdl:inputValueCalc="{ ../ex:num }"/>
+          <xs:element name="ivc_ushort_range_max" type="xs:unsignedShort" dfdl:inputValueCalc="{ xs:unsignedShort(../ex:num) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -379,7 +379,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="num" type="xs:string" />
-          <xs:element name="ivc_long_range_min" type="xs:long" dfdl:inputValueCalc="{ ../ex:num }"/>
+          <xs:element name="ivc_long_range_min" type="xs:long" dfdl:inputValueCalc="{ xs:long(../ex:num) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -397,7 +397,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="num" type="xs:string" />
-          <xs:element name="ivc_long_range_max" type="xs:long" dfdl:inputValueCalc="{ ../ex:num }"/>
+          <xs:element name="ivc_long_range_max" type="xs:long" dfdl:inputValueCalc="{ xs:long(../ex:num) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -433,7 +433,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="num" type="xs:string" />
-          <xs:element name="ivc_ulong_range_min" type="xs:unsignedLong" dfdl:inputValueCalc="{ ../ex:num }"/>
+          <xs:element name="ivc_ulong_range_min" type="xs:unsignedLong" dfdl:inputValueCalc="{ xs:unsignedLong(../ex:num) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -451,7 +451,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="num" type="xs:string" />
-          <xs:element name="ivc_ulong_range_max" type="xs:unsignedLong" dfdl:inputValueCalc="{ ../ex:num }"/>
+          <xs:element name="ivc_ulong_range_max" type="xs:unsignedLong" dfdl:inputValueCalc="{ xs:unsignedLong(../ex:num) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -478,7 +478,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="num" type="xs:string" />
-          <xs:element name="ivc_byte_range_min" type="xs:byte" dfdl:inputValueCalc="{ ../ex:num }"/>
+          <xs:element name="ivc_byte_range_min" type="xs:byte" dfdl:inputValueCalc="{ xs:byte(../ex:num) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -496,7 +496,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="num" type="xs:string" />
-          <xs:element name="ivc_byte_range_max" type="xs:byte" dfdl:inputValueCalc="{ ../ex:num }"/>
+          <xs:element name="ivc_byte_range_max" type="xs:byte" dfdl:inputValueCalc="{ xs:byte(../ex:num) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -532,7 +532,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="num" type="xs:string" />
-          <xs:element name="ivc_ubyte_range_min" type="xs:unsignedByte" dfdl:inputValueCalc="{ ../ex:num }"/>
+          <xs:element name="ivc_ubyte_range_min" type="xs:unsignedByte" dfdl:inputValueCalc="{ xs:unsignedByte(../ex:num) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -550,7 +550,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="num" type="xs:string" />
-          <xs:element name="ivc_ubyte_range_max" type="xs:unsignedByte" dfdl:inputValueCalc="{ ../ex:num }"/>
+          <xs:element name="ivc_ubyte_range_max" type="xs:unsignedByte" dfdl:inputValueCalc="{ xs:unsignedByte(../ex:num) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -567,7 +567,7 @@
     <xs:element name="ivc_20">
       <xs:complexType>
         <xs:sequence>
-          <xs:element name="a" type="xs:double" dfdl:inputValueCalc="{ 'nan' }" />
+          <xs:element name="a" type="xs:double" dfdl:inputValueCalc="{ xs:double('nan') }" />
         </xs:sequence>
       </xs:complexType>
     </xs:element>
diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section17/calc_value_properties/outputValueCalc.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section17/calc_value_properties/outputValueCalc.tdml
index 3b7ad43..db2ecd4 100644
--- a/daffodil-test/src/test/resources/org/apache/daffodil/section17/calc_value_properties/outputValueCalc.tdml
+++ b/daffodil-test/src/test/resources/org/apache/daffodil/section17/calc_value_properties/outputValueCalc.tdml
@@ -42,11 +42,11 @@
 						dfdl:lengthKind="explicit" />
 
 					<xs:element name="x" type="xs:string"
-						dfdl:outputValueCalc="{ dfdl:valueLength(../ex:y,'bytes') }"
+						dfdl:outputValueCalc="{ xs:string(dfdl:valueLength(../ex:y,'bytes')) }"
 						dfdl:initiator="{ ../ex:xi }" dfdl:lengthKind="delimited"
 						dfdl:terminator=";" />
 					<xs:element name="y" type="xs:string"
-						dfdl:outputValueCalc="{ dfdl:valueLength(../ex:z, 'bytes') }"
+						dfdl:outputValueCalc="{ xs:string(dfdl:valueLength(../ex:z, 'bytes')) }"
 						dfdl:initiator="{ ../ex:yi }" dfdl:lengthKind="delimited"
 						dfdl:terminator=";" />
 					<xs:element name="z" type="xs:string" dfdl:initiator="{ ../ex:zi }"
@@ -66,11 +66,11 @@
 						dfdl:lengthKind="explicit" />
 
 					<xs:element name="x" type="xs:string"
-						dfdl:outputValueCalc="{ dfdl:valueLength(../ex:y,'bytes') }"
+						dfdl:outputValueCalc="{ xs:string(dfdl:valueLength(../ex:y,'bytes')) }"
 						dfdl:terminator="{ ../ex:xt }" dfdl:lengthKind="delimited"
 						dfdl:initiator=";" />
 					<xs:element name="y" type="xs:string"
-						dfdl:outputValueCalc="{ dfdl:valueLength(../ex:z, 'bytes') }"
+						dfdl:outputValueCalc="{ xs:string(dfdl:valueLength(../ex:z, 'bytes')) }"
 						dfdl:terminator="{ ../ex:yt }" dfdl:lengthKind="delimited"
 						dfdl:initiator=";" />
 					<xs:element name="z" type="xs:string" dfdl:terminator="{ ../ex:zt }"
@@ -94,12 +94,12 @@
 							<xs:sequence dfdl:separator="{ ../ex:xsep }"
 								dfdl:separatorPosition="prefix">
 								<xs:element name="x" type="xs:string"
-									dfdl:outputValueCalc="{ dfdl:valueLength(../ex:y,'bytes') }"
+									dfdl:outputValueCalc="{ xs:string(dfdl:valueLength(../ex:y,'bytes')) }"
 									dfdl:lengthKind="delimited" />
 								<xs:sequence dfdl:separator="{ ../ex:ysep  }"
 									dfdl:separatorPosition="prefix">
 									<xs:element name="y" type="xs:string"
-										dfdl:outputValueCalc="{ dfdl:valueLength(../ex:z, 'bytes') }"
+										dfdl:outputValueCalc="{ xs:string(dfdl:valueLength(../ex:z, 'bytes')) }"
 										dfdl:lengthKind="delimited" />
 									<xs:sequence dfdl:separator="{ ../ex:zsep }"
 										dfdl:separatorPosition="prefix">
@@ -118,21 +118,21 @@
 			<xs:complexType>
 				<xs:sequence>
 					<xs:element name="xonl" type="xs:string" dfdl:length="2"
-						dfdl:outputValueCalc="{ dfdl:decodeDFDLEntities('%NEL;') }"
+						dfdl:outputValueCalc="{ xs:string(dfdl:decodeDFDLEntities('%NEL;')) }"
 						dfdl:lengthKind="explicit" />
 					<xs:element name="yonl" type="xs:string" dfdl:length="1"
-						dfdl:outputValueCalc="{ dfdl:decodeDFDLEntities('%LF;') }"
+						dfdl:outputValueCalc="{ xs:string(dfdl:decodeDFDLEntities('%LF;')) }"
 						dfdl:lengthKind="explicit" />
 					<xs:element name="zonl" type="xs:string" dfdl:length="1"
-						dfdl:outputValueCalc="{ dfdl:decodeDFDLEntities('%CR;') }"
+						dfdl:outputValueCalc="{ xs:string(dfdl:decodeDFDLEntities('%CR;')) }"
 						dfdl:lengthKind="explicit" />
 
 					<xs:element name="x" type="xs:string" dfdl:initiator="|"
-						dfdl:outputValueCalc="{ dfdl:valueLength(../ex:y,'bytes') }"
+						dfdl:outputValueCalc="{ xs:string(dfdl:valueLength(../ex:y,'bytes')) }"
 						dfdl:outputNewLine="{ dfdl:encodeDFDLEntities(../ex:xonl) }"
 						dfdl:lengthKind="delimited" dfdl:terminator="%NL;|" />
 					<xs:element name="y" type="xs:string"
-						dfdl:outputValueCalc="{ dfdl:valueLength(../ex:z, 'bytes') }"
+						dfdl:outputValueCalc="{ xs:string(dfdl:valueLength(../ex:z, 'bytes')) }"
 						dfdl:outputNewLine="{ dfdl:encodeDFDLEntities(../ex:yonl) }"
 						dfdl:lengthKind="delimited" dfdl:terminator="%NL;|" />
 					<xs:element name="z" type="xs:string"
@@ -199,7 +199,7 @@
 					<xs:element name="delimA" type="xs:string" dfdl:length="1"
 						dfdl:lengthKind="explicit" dfdl:terminator="--" />
 					<xs:element name="x" type="xs:string"
-						dfdl:outputValueCalc="{ dfdl:valueLength(../ex:nestA/ex:y, 'bytes') }"
+						dfdl:outputValueCalc="{ xs:string(dfdl:valueLength(../ex:nestA/ex:y, 'bytes')) }"
 						dfdl:lengthKind="delimited" dfdl:terminator=";" />
 					<xs:element name="nestA" dfdl:initiator="{ ../ex:delim }">
 						<xs:complexType>
@@ -207,7 +207,7 @@
 								<xs:element name="delimB" type="xs:string"
 									dfdl:length="1" dfdl:lengthKind="explicit" />
 								<xs:element name="y" type="xs:string"
-									dfdl:outputValueCalc="{ dfdl:valueLength(../ex:nestB/ex:z, 'bytes') }"
+									dfdl:outputValueCalc="{ xs:string(dfdl:valueLength(../ex:nestB/ex:z, 'bytes')) }"
 									dfdl:lengthKind="delimited" dfdl:terminator=";" />
 								<xs:element name="nestB" dfdl:initiator="{ ../../ex:delimA }">
 									<xs:complexType>
diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section17/calc_value_properties/outputValueCalc2.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section17/calc_value_properties/outputValueCalc2.tdml
index d286f68..8ff943c 100644
--- a/daffodil-test/src/test/resources/org/apache/daffodil/section17/calc_value_properties/outputValueCalc2.tdml
+++ b/daffodil-test/src/test/resources/org/apache/daffodil/section17/calc_value_properties/outputValueCalc2.tdml
@@ -231,7 +231,7 @@
               <xs:sequence>
                 <xs:element name="checksum" type="xs:int"/>
                 <xs:sequence dfdl:hiddenGroupRef="ex:IPSrcGrp"/>
-                <xs:element name="IPSrc" type="xs:string" dfdl:lengthKind="explicit" dfdl:length="1" dfdl:inputValueCalc="{ ../sbyte1 }"/>
+                <xs:element name="IPSrc" type="xs:string" dfdl:lengthKind="explicit" dfdl:length="1" dfdl:inputValueCalc="{ xs:string(../sbyte1) }"/>
               </xs:sequence>
             </xs:complexType>
           </xs:element>
@@ -315,8 +315,8 @@
           <xs:element name="yi" type="xs:string" dfdl:length="1" dfdl:lengthKind="explicit"/>
           <xs:element name="zi" type="xs:string" dfdl:length="1" dfdl:lengthKind="explicit"/>
 
-          <xs:element name="x" type="xs:string" dfdl:outputValueCalc="{ dfdl:valueLength(../y, 'bytes') }" dfdl:initiator="{../xi}"  dfdl:lengthKind="delimited" dfdl:terminator=";"/>
-          <xs:element name="y" type="xs:string" dfdl:outputValueCalc="{ dfdl:valueLength(../z, 'bytes')}"  dfdl:initiator="Y"  dfdl:lengthKind="delimited" dfdl:terminator=";"/>
+          <xs:element name="x" type="xs:string" dfdl:outputValueCalc="{ xs:string(dfdl:valueLength(../y, 'bytes')) }" dfdl:initiator="{../xi}"  dfdl:lengthKind="delimited" dfdl:terminator=";"/>
+          <xs:element name="y" type="xs:string" dfdl:outputValueCalc="{ xs:string(dfdl:valueLength(../z, 'bytes')) }" dfdl:initiator="Y"  dfdl:lengthKind="delimited" dfdl:terminator=";"/>
           <xs:element name="z" type="xs:string" dfdl:initiator="Z"  dfdl:lengthKind="delimited" dfdl:terminator=";"/>
         </xs:sequence>
       </xs:complexType>
@@ -371,8 +371,8 @@
           <xs:element name="yi" type="xs:string" dfdl:length="5" dfdl:lengthKind="explicit"/>
           <xs:element name="zi" type="xs:string" dfdl:length="5" dfdl:lengthKind="explicit"/>
 
-          <xs:element name="x" type="xs:date" dfdl:lengthKind="delimited" dfdl:representation="text" dfdl:calendarPattern="EEEE MMMM yyyy" dfdl:calendarLanguage="{ ../xi }" dfdl:outputValueCalc="{ fn:concat('2017-8-',dfdl:valueLength(../y, 'bytes')) }" dfdl:calendarPatternKind="explicit" />
-          <xs:element name="y" type="xs:date" dfdl:lengthKind="delimited" dfdl:representation="text" dfdl:calendarPattern="EEEE MMMM yyyy" dfdl:calendarLanguage="{ ../yi }" dfdl:outputValueCalc="{ fn:concat('1986-6-',dfdl:valueLength(../z, 'bytes')) }" dfdl:calendarPatternKind="explicit" />
+          <xs:element name="x" type="xs:date" dfdl:lengthKind="delimited" dfdl:representation="text" dfdl:calendarPattern="EEEE MMMM yyyy" dfdl:calendarLanguage="{ ../xi }" dfdl:outputValueCalc="{ xs:date(fn:concat('2017-8-',dfdl:valueLength(../y, 'bytes'))) }" dfdl:calendarPatternKind="explicit" />
+          <xs:element name="y" type="xs:date" dfdl:lengthKind="delimited" dfdl:representation="text" dfdl:calendarPattern="EEEE MMMM yyyy" dfdl:calendarLanguage="{ ../yi }" dfdl:outputValueCalc="{ xs:date(fn:concat('1986-6-',dfdl:valueLength(../z, 'bytes'))) }" dfdl:calendarPatternKind="explicit" />
           <xs:element name="z" type="xs:date" dfdl:lengthKind="delimited" dfdl:representation="text" dfdl:calendarPattern="EEEE MMMM yyyy" dfdl:calendarLanguage="{ ../zi }" dfdl:calendarPatternKind="explicit" dfdl:encoding="UTF-8" />
         </xs:sequence>
       </xs:complexType>
diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_expressions/expressions.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_expressions/expressions.tdml
index 76058d3..df5ff73 100644
--- a/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_expressions/expressions.tdml
+++ b/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_expressions/expressions.tdml
@@ -90,7 +90,7 @@
               </xs:sequence>
             </xs:complexType>
           </xs:element>
-          <xs:element name="items" type="xs:string" dfdl:inputValueCalc="{ /ex:e1/ex:seq/ex:item }"/>
+          <xs:element name="items" type="xs:int" dfdl:inputValueCalc="{ /ex:e1/ex:seq/ex:item }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -105,7 +105,7 @@
               </xs:sequence>
             </xs:complexType>
           </xs:element>
-          <xs:element name="items" type="xs:string" dfdl:inputValueCalc="{ /ex:e2/ex:seq/../ex:seq/../ex:seq/ex:item[2] }"/>
+          <xs:element name="items" type="xs:string" dfdl:inputValueCalc="{ xs:string(/ex:e2/ex:seq/../ex:seq/../ex:seq/ex:item[2]) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -134,7 +134,7 @@
               </xs:sequence>
             </xs:complexType>
           </xs:element>
-          <xs:element name="items" type="xs:string" dfdl:inputValueCalc="{ /ex:e3/ex:seq/ex:item[2] + /ex:e3/ex:seq/../ex:seq2/ex:item[1] + /ex:e3/ex:seq3/../ex:seq2/../ex:seq/../ex:seq3/ex:item[4] }"/>
+          <xs:element name="items" type="xs:string" dfdl:inputValueCalc="{ xs:string(/ex:e3/ex:seq/ex:item[2] + /ex:e3/ex:seq/../ex:seq2/ex:item[1] + /ex:e3/ex:seq3/../ex:seq2/../ex:seq/../ex:seq3/ex:item[4]) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -1769,7 +1769,7 @@ c]]></value>
           <xs:element name="e1" type="xs:string"
             dfdl:inputValueCalc="{ 'notAnInt' }" />
           <xs:element name="e3" type="xs:int"
-            dfdl:inputValueCalc="{ ../ex:e1 }" /> <!-- type error -->
+            dfdl:inputValueCalc="{ xs:int(../ex:e1) }" /> <!-- type error -->
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -1783,6 +1783,33 @@ c]]></value>
       </xs:complexType>
     </xs:element>
 
+    <xs:element name="i" dfdl:lengthKind="implicit">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="e1" type="xs:boolean"
+            dfdl:inputValueCalc="{ 'true' }" /><!-- no type coercion to the target type -->
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+
+    <xs:element name="j" dfdl:lengthKind="implicit">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="e1" type="xs:string"
+            dfdl:inputValueCalc="{ 5 }" /><!-- no type coercion to the target type -->
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+
+    <xs:element name="k" dfdl:lengthKind="implicit">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="e1" type="xs:float"
+            dfdl:inputValueCalc="{ xs:double(5) }" /><!-- no type coercion to the target type -->
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+
   </tdml:defineSchema>
 
   <tdml:parserTestCase name="expression_type_error1"
@@ -1805,7 +1832,10 @@ c]]></value>
     <tdml:document />
     <tdml:errors>
       <tdml:error>Schema Definition Error</tdml:error>
-      <tdml:error>convert</tdml:error>
+      <tdml:error>Expression result type</tdml:error>
+      <tdml:error>cannot be coerced</tdml:error>
+      <tdml:error>Double</tdml:error>
+      <tdml:error>Int</tdml:error>
     </tdml:errors>
   </tdml:parserTestCase>
 
@@ -1836,7 +1866,46 @@ c]]></value>
       <tdml:error>string</tdml:error>      
     </tdml:errors>
   </tdml:parserTestCase>
-  
+
+  <tdml:parserTestCase name="expression_type_error5"
+    root="i" model="expression-type-errors.dfdl.xsd"
+    description="get a type error from an expression at compilation time - no coercion">
+    <tdml:document />
+    <tdml:errors>
+      <tdml:error>Schema Definition Error</tdml:error>
+      <tdml:error>Expression result type</tdml:error>
+      <tdml:error>cannot be coerced</tdml:error>
+      <tdml:error>String</tdml:error>
+      <tdml:error>Boolean</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="expression_type_error6"
+    root="j" model="expression-type-errors.dfdl.xsd"
+    description="get a type error from an expression at compilation time - no coercion">
+    <tdml:document />
+    <tdml:errors>
+      <tdml:error>Schema Definition Error</tdml:error>
+      <tdml:error>Expression result type</tdml:error>
+      <tdml:error>cannot be coerced</tdml:error>
+      <tdml:error>Int</tdml:error>
+      <tdml:error>String</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="expression_type_error7"
+    root="k" model="expression-type-errors.dfdl.xsd"
+    description="get a type error from an expression at compilation time - no coercion">
+    <tdml:document />
+    <tdml:errors>
+      <tdml:error>Schema Definition Error</tdml:error>
+      <tdml:error>Expression result type</tdml:error>
+      <tdml:error>cannot be coerced</tdml:error>
+      <tdml:error>Double</tdml:error>
+      <tdml:error>Float</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
+
   <tdml:defineSchema name="elementFormWithWhitespace">
 
     <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
@@ -6954,48 +7023,48 @@ c]]></value>
     <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
     <dfdl:format ref="ex:GeneralFormat"/>
 
-    <xs:element name="div01" type="xs:string" dfdl:inputValueCalc="{ xs:double(5) div xs:double(2) }" />
-    <xs:element name="div02" type="xs:string" dfdl:inputValueCalc="{ xs:float(5) div xs:float(2) }" />
-    <xs:element name="div03" type="xs:string" dfdl:inputValueCalc="{ xs:decimal(5) div xs:decimal(2) }" />
-    <xs:element name="div04" type="xs:string" dfdl:inputValueCalc="{ xs:integer(5) div xs:integer(2) }" />
-    <xs:element name="div05" type="xs:string" dfdl:inputValueCalc="{ xs:int(5) div xs:int(2) }" />
-    <xs:element name="div06" type="xs:string" dfdl:inputValueCalc="{ xs:short(5) div xs:short(2) }" />
-    <xs:element name="div07" type="xs:string" dfdl:inputValueCalc="{ xs:double(5) div xs:double(0) }" />
-    <xs:element name="div08" type="xs:string" dfdl:inputValueCalc="{ xs:float(5) div xs:float(0) }" />
-    <xs:element name="div09" type="xs:string" dfdl:inputValueCalc="{ xs:decimal(5) div xs:decimal(0) }" />
-    <xs:element name="div10" type="xs:string" dfdl:inputValueCalc="{ xs:integer(5) div xs:integer(0) }" />
-    <xs:element name="div11" type="xs:string" dfdl:inputValueCalc="{ xs:int(5) div xs:int(0) }" />
-    <xs:element name="div12" type="xs:string" dfdl:inputValueCalc="{ xs:short(5) div xs:short(0) }" />
-    <xs:element name="div13" type="xs:string" dfdl:inputValueCalc="{ xs:double('INF') div xs:double(2) }" />
-    <xs:element name="div14" type="xs:string" dfdl:inputValueCalc="{ xs:float('INF') div xs:float(2) }" />
-    <xs:element name="div15" type="xs:string" dfdl:inputValueCalc="{ xs:double('NaN') div xs:double(2) }" />
-    <xs:element name="div16" type="xs:string" dfdl:inputValueCalc="{ xs:float('NaN') div xs:float(2) }" />
-    <xs:element name="div17" type="xs:string" dfdl:inputValueCalc="{ xs:double(5) div xs:double('NaN') }" />
-    <xs:element name="div18" type="xs:string" dfdl:inputValueCalc="{ xs:float(5) div xs:float('NaN') }" />
-    <xs:element name="div19" type="xs:string" dfdl:inputValueCalc="{ xs:double(5) div xs:double('INF') }" />
-    <xs:element name="div20" type="xs:string" dfdl:inputValueCalc="{ xs:float(5) div xs:float('INF') }" />
-    <xs:element name="div21" type="xs:string" dfdl:inputValueCalc="{ 90.0 div 1234567.0 }" />
-
-    <xs:element name="idiv01" type="xs:string" dfdl:inputValueCalc="{ xs:double(5) idiv xs:double(2) }" />
-    <xs:element name="idiv02" type="xs:string" dfdl:inputValueCalc="{ xs:float(5) idiv xs:float(2) }" />
-    <xs:element name="idiv03" type="xs:string" dfdl:inputValueCalc="{ xs:decimal(5) idiv xs:decimal(2) }" />
-    <xs:element name="idiv04" type="xs:string" dfdl:inputValueCalc="{ xs:integer(5) idiv xs:integer(2) }" />
-    <xs:element name="idiv05" type="xs:string" dfdl:inputValueCalc="{ xs:int(5) idiv xs:int(2) }" />
-    <xs:element name="idiv06" type="xs:string" dfdl:inputValueCalc="{ xs:short(5) idiv xs:short(2) }" />
-    <xs:element name="idiv07" type="xs:string" dfdl:inputValueCalc="{ xs:double(5) idiv xs:double(0) }" />
-    <xs:element name="idiv08" type="xs:string" dfdl:inputValueCalc="{ xs:float(5) idiv xs:float(0) }" />
-    <xs:element name="idiv09" type="xs:string" dfdl:inputValueCalc="{ xs:decimal(5) idiv xs:decimal(0) }" />
-    <xs:element name="idiv10" type="xs:string" dfdl:inputValueCalc="{ xs:integer(5) idiv xs:integer(0) }" />
-    <xs:element name="idiv11" type="xs:string" dfdl:inputValueCalc="{ xs:int(5) idiv xs:int(0) }" />
-    <xs:element name="idiv12" type="xs:string" dfdl:inputValueCalc="{ xs:short(5) idiv xs:short(0) }" />
-    <xs:element name="idiv13" type="xs:string" dfdl:inputValueCalc="{ xs:double('INF') idiv xs:double(2) }" />
-    <xs:element name="idiv14" type="xs:string" dfdl:inputValueCalc="{ xs:float('INF') idiv xs:float(2) }" />
-    <xs:element name="idiv15" type="xs:string" dfdl:inputValueCalc="{ xs:double('NaN') idiv xs:double(2) }" />
-    <xs:element name="idiv16" type="xs:string" dfdl:inputValueCalc="{ xs:float('NaN') idiv xs:float(2) }" />
-    <xs:element name="idiv17" type="xs:string" dfdl:inputValueCalc="{ xs:double(5) idiv xs:double('NaN') }" />
-    <xs:element name="idiv18" type="xs:string" dfdl:inputValueCalc="{ xs:float(5) idiv xs:float('NaN') }" />
-    <xs:element name="idiv19" type="xs:string" dfdl:inputValueCalc="{ xs:double(5) idiv xs:double('INF') }" />
-    <xs:element name="idiv20" type="xs:string" dfdl:inputValueCalc="{ xs:float(5) idiv xs:float('INF') }" />
+    <xs:element name="div01" type="xs:double" dfdl:inputValueCalc="{ xs:double(5) div xs:double(2) }" />
+    <xs:element name="div02" type="xs:float" dfdl:inputValueCalc="{ xs:float(5) div xs:float(2) }" />
+    <xs:element name="div03" type="xs:decimal" dfdl:inputValueCalc="{ xs:decimal(5) div xs:decimal(2) }" />
+    <xs:element name="div04" type="xs:decimal" dfdl:inputValueCalc="{ xs:integer(5) div xs:integer(2) }" />
+    <xs:element name="div05" type="xs:float" dfdl:inputValueCalc="{ xs:int(5) div xs:int(2) }" />
+    <xs:element name="div06" type="xs:float" dfdl:inputValueCalc="{ xs:short(5) div xs:short(2) }" />
+    <xs:element name="div07" type="xs:double" dfdl:inputValueCalc="{ xs:double(5) div xs:double(0) }" />
+    <xs:element name="div08" type="xs:float" dfdl:inputValueCalc="{ xs:float(5) div xs:float(0) }" />
+    <xs:element name="div09" type="xs:decimal" dfdl:inputValueCalc="{ xs:decimal(5) div xs:decimal(0) }" />
+    <xs:element name="div10" type="xs:decimal" dfdl:inputValueCalc="{ xs:integer(5) div xs:integer(0) }" />
+    <xs:element name="div11" type="xs:float" dfdl:inputValueCalc="{ xs:int(5) div xs:int(0) }" />
+    <xs:element name="div12" type="xs:float" dfdl:inputValueCalc="{ xs:short(5) div xs:short(0) }" />
+    <xs:element name="div13" type="xs:double" dfdl:inputValueCalc="{ xs:double('INF') div xs:double(2) }" />
+    <xs:element name="div14" type="xs:float" dfdl:inputValueCalc="{ xs:float('INF') div xs:float(2) }" />
+    <xs:element name="div15" type="xs:double" dfdl:inputValueCalc="{ xs:double('NaN') div xs:double(2) }" />
+    <xs:element name="div16" type="xs:float" dfdl:inputValueCalc="{ xs:float('NaN') div xs:float(2) }" />
+    <xs:element name="div17" type="xs:double" dfdl:inputValueCalc="{ xs:double(5) div xs:double('NaN') }" />
+    <xs:element name="div18" type="xs:float" dfdl:inputValueCalc="{ xs:float(5) div xs:float('NaN') }" />
+    <xs:element name="div19" type="xs:double" dfdl:inputValueCalc="{ xs:double(5) div xs:double('INF') }" />
+    <xs:element name="div20" type="xs:float" dfdl:inputValueCalc="{ xs:float(5) div xs:float('INF') }" />
+    <xs:element name="div21" type="xs:double" dfdl:inputValueCalc="{ 90.0 div 1234567.0 }" />
+
+    <xs:element name="idiv01" type="xs:int" dfdl:inputValueCalc="{ xs:double(5) idiv xs:double(2) }" />
+    <xs:element name="idiv02" type="xs:int" dfdl:inputValueCalc="{ xs:float(5) idiv xs:float(2) }" />
+    <xs:element name="idiv03" type="xs:int" dfdl:inputValueCalc="{ xs:decimal(5) idiv xs:decimal(2) }" />
+    <xs:element name="idiv04" type="xs:int" dfdl:inputValueCalc="{ xs:integer(5) idiv xs:integer(2) }" />
+    <xs:element name="idiv05" type="xs:int" dfdl:inputValueCalc="{ xs:int(5) idiv xs:int(2) }" />
+    <xs:element name="idiv06" type="xs:int" dfdl:inputValueCalc="{ xs:short(5) idiv xs:short(2) }" />
+    <xs:element name="idiv07" type="xs:int" dfdl:inputValueCalc="{ xs:double(5) idiv xs:double(0) }" />
+    <xs:element name="idiv08" type="xs:int" dfdl:inputValueCalc="{ xs:float(5) idiv xs:float(0) }" />
+    <xs:element name="idiv09" type="xs:int" dfdl:inputValueCalc="{ xs:decimal(5) idiv xs:decimal(0) }" />
+    <xs:element name="idiv10" type="xs:int" dfdl:inputValueCalc="{ xs:integer(5) idiv xs:integer(0) }" />
+    <xs:element name="idiv11" type="xs:int" dfdl:inputValueCalc="{ xs:int(5) idiv xs:int(0) }" />
+    <xs:element name="idiv12" type="xs:int" dfdl:inputValueCalc="{ xs:short(5) idiv xs:short(0) }" />
+    <xs:element name="idiv13" type="xs:int" dfdl:inputValueCalc="{ xs:double('INF') idiv xs:double(2) }" />
+    <xs:element name="idiv14" type="xs:int" dfdl:inputValueCalc="{ xs:float('INF') idiv xs:float(2) }" />
+    <xs:element name="idiv15" type="xs:int" dfdl:inputValueCalc="{ xs:double('NaN') idiv xs:double(2) }" />
+    <xs:element name="idiv16" type="xs:int" dfdl:inputValueCalc="{ xs:float('NaN') idiv xs:float(2) }" />
+    <xs:element name="idiv17" type="xs:int" dfdl:inputValueCalc="{ xs:double(5) idiv xs:double('NaN') }" />
+    <xs:element name="idiv18" type="xs:int" dfdl:inputValueCalc="{ xs:float(5) idiv xs:float('NaN') }" />
+    <xs:element name="idiv19" type="xs:int" dfdl:inputValueCalc="{ xs:double(5) idiv xs:double('INF') }" />
+    <xs:element name="idiv20" type="xs:int" dfdl:inputValueCalc="{ xs:float(5) idiv xs:float('INF') }" />
 
   </tdml:defineSchema>
 
@@ -7031,12 +7100,12 @@ c]]></value>
 
   <tdml:parserTestCase name="div07" root="div07" model="XPathDiv" description="Section 23 - DFDL Expressions - div">
     <tdml:document></tdml:document>
-    <tdml:infoset><tdml:dfdlInfoset><div07>Infinity</div07></tdml:dfdlInfoset></tdml:infoset>
+    <tdml:infoset><tdml:dfdlInfoset><div07>INF</div07></tdml:dfdlInfoset></tdml:infoset>
   </tdml:parserTestCase>
 
   <tdml:parserTestCase name="div08" root="div08" model="XPathDiv" description="Section 23 - DFDL Expressions - div">
     <tdml:document></tdml:document>
-    <tdml:infoset><tdml:dfdlInfoset><div08>Infinity</div08></tdml:dfdlInfoset></tdml:infoset>
+    <tdml:infoset><tdml:dfdlInfoset><div08>INF</div08></tdml:dfdlInfoset></tdml:infoset>
   </tdml:parserTestCase>
 
   <tdml:parserTestCase name="div09" root="div09" model="XPathDiv" description="Section 23 - DFDL Expressions - div">
@@ -7069,12 +7138,12 @@ c]]></value>
 
   <tdml:parserTestCase name="div13" root="div13" model="XPathDiv" description="Section 23 - DFDL Expressions - div">
     <tdml:document></tdml:document>
-    <tdml:infoset><tdml:dfdlInfoset><div13>Infinity</div13></tdml:dfdlInfoset></tdml:infoset>
+    <tdml:infoset><tdml:dfdlInfoset><div13>INF</div13></tdml:dfdlInfoset></tdml:infoset>
   </tdml:parserTestCase>
 
   <tdml:parserTestCase name="div14" root="div14" model="XPathDiv" description="Section 23 - DFDL Expressions - div">
     <tdml:document></tdml:document>
-    <tdml:infoset><tdml:dfdlInfoset><div14>Infinity</div14></tdml:dfdlInfoset></tdml:infoset>
+    <tdml:infoset><tdml:dfdlInfoset><div14>INF</div14></tdml:dfdlInfoset></tdml:infoset>
   </tdml:parserTestCase>
 
   <tdml:parserTestCase name="div15" root="div15" model="XPathDiv" description="Section 23 - DFDL Expressions - div">
diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_expressions/expressions2.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_expressions/expressions2.tdml
index 8d5ac97..5e4239a 100644
--- a/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_expressions/expressions2.tdml
+++ b/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_expressions/expressions2.tdml
@@ -65,7 +65,7 @@
    <xs:complexType>
     <xs:sequence>
      <xs:element name="count" type="xs:unsignedByte" dfdl:length="2" />
-     <xs:element name="ovc" type="xs:unsignedByte" dfdl:inputValueCalc="{ if (../count eq 1) then ../count div 0.75 else 0 }" />
+     <xs:element name="ovc" type="xs:unsignedByte" dfdl:inputValueCalc="{ xs:unsignedByte(if (../count eq 1) then ../count div 0.75 else 0) }" />
     </xs:sequence>
    </xs:complexType>
   </xs:element>
@@ -74,7 +74,7 @@
    <xs:complexType>
     <xs:sequence>
      <xs:element name="count" type="xs:unsignedByte" dfdl:length="2" />
-     <xs:element name="ovc" type="xs:unsignedByte" dfdl:inputValueCalc="{ 5 + (if (../count eq 1) then ../count div 0.75 else 0) + 6 }" />
+     <xs:element name="ovc" type="xs:unsignedByte" dfdl:inputValueCalc="{ xs:unsignedByte(5 + (if (../count eq 1) then ../count div 0.75 else 0) + 6) }" />
     </xs:sequence>
    </xs:complexType>
   </xs:element>
@@ -83,7 +83,7 @@
    <xs:complexType>
     <xs:sequence>
      <xs:element name="count" type="xs:unsignedByte" dfdl:length="2" />
-     <xs:element name="ovc" type="xs:unsignedByte" dfdl:inputValueCalc="{ 5 + (if (../count eq 1) then ../count div 0.75 else '0') + 6 }" />
+     <xs:element name="ovc" type="xs:unsignedByte" dfdl:inputValueCalc="{ xs:unsignedByte(5 + (if (../count eq 1) then ../count div 0.75 else '0') + 6) }" />
     </xs:sequence>
    </xs:complexType>
   </xs:element>
diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_functions/Functions.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_functions/Functions.tdml
index b8c3d94..f74396e 100644
--- a/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_functions/Functions.tdml
+++ b/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_functions/Functions.tdml
@@ -296,7 +296,7 @@
         <xs:sequence dfdl:separator=",">
           <xs:element name="str" type="xs:string"  dfdl:lengthKind="delimited" dfdl:textTrimKind="padChar" 
             dfdl:textStringPadCharacter="/" dfdl:textStringJustification="center" />
-          <xs:element name="valLen" type="xs:string"
+          <xs:element name="valLen" type="xs:long"
             dfdl:lengthKind="delimited" dfdl:inputValueCalc="{ dfdl:valueLength( ../ex:str, 'bits') }" />
         </xs:sequence>
       </xs:complexType>
@@ -307,7 +307,7 @@
         <xs:sequence dfdl:separator=",">
           <xs:element name="str" type="xs:string"  dfdl:lengthKind="delimited" dfdl:textTrimKind="padChar" 
             dfdl:textStringPadCharacter="/" dfdl:textStringJustification="center" />
-          <xs:element name="valLen" type="xs:string"
+          <xs:element name="valLen" type="xs:long"
             dfdl:lengthKind="delimited" dfdl:inputValueCalc="{ dfdl:valueLength( ../ex:str, 'bytes' ) }" />
         </xs:sequence>
       </xs:complexType>
@@ -318,7 +318,7 @@
         <xs:sequence dfdl:separator=",">
           <xs:element name="str" type="xs:string" dfdl:lengthKind="delimited" dfdl:textTrimKind="padChar"
             dfdl:textStringPadCharacter="/" dfdl:textStringJustification="center" />
-          <xs:element name="valLen" type="xs:string"
+          <xs:element name="valLen" type="xs:long"
             dfdl:lengthKind="delimited" dfdl:inputValueCalc="{ dfdl:valueLength( ../ex:str, 'characters') }" />
         </xs:sequence>
       </xs:complexType>
@@ -336,7 +336,7 @@
           <xs:element name="str" type="xs:string"  dfdl:lengthKind="delimited" dfdl:textTrimKind="padChar"
             dfdl:textStringPadCharacter="/" dfdl:textStringJustification="center" dfdl:escapeSchemeRef="ex:es1"
             dfdl:terminator=";" />
-          <xs:element name="valLen" type="xs:string"
+          <xs:element name="valLen" type="xs:long"
             dfdl:lengthKind="delimited" dfdl:inputValueCalc="{ dfdl:valueLength( ../ex:str, 'bytes' ) }" />
         </xs:sequence>
       </xs:complexType>
@@ -349,7 +349,7 @@
             dfdl:textStringPadCharacter="/" dfdl:textStringJustification="center" dfdl:escapeSchemeRef="ex:es1"
             dfdl:terminator=";" />
           <xs:element name="valLen" type="xs:string"
-            dfdl:lengthKind="delimited" dfdl:outputValueCalc="{ dfdl:valueLength( ../ex:str, 'bits' ) }" />
+            dfdl:lengthKind="delimited" dfdl:outputValueCalc="{ xs:string(dfdl:valueLength( ../ex:str, 'bits' )) }" />
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -360,7 +360,7 @@
           <xs:element name="str" type="xs:string"  dfdl:lengthKind="delimited" dfdl:textTrimKind="padChar"
             dfdl:textStringPadCharacter="/" dfdl:textStringJustification="center" />
           <xs:element name="valLen" type="xs:string"
-            dfdl:lengthKind="delimited" dfdl:outputValueCalc="{ dfdl:valueLength( ../ex:str, 'characters') }" />
+            dfdl:lengthKind="delimited" dfdl:outputValueCalc="{ xs:string(dfdl:valueLength( ../ex:str, 'characters')) }" />
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -371,7 +371,7 @@
           <xs:element name="str" type="xs:string"  dfdl:lengthKind="delimited" dfdl:textTrimKind="padChar"
             dfdl:textStringPadCharacter="/" dfdl:textStringJustification="center" />
           <xs:element name="valLen" type="xs:string"
-            dfdl:lengthKind="delimited" dfdl:outputValueCalc="{ dfdl:valueLength( ../ex:str, 'bytes') }" />
+            dfdl:lengthKind="delimited" dfdl:outputValueCalc="{ xs:string(dfdl:valueLength( ../ex:str, 'bytes')) }" />
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -381,7 +381,7 @@
         <xs:sequence dfdl:separator=",">
           <xs:element name="str" type="xs:string"  dfdl:lengthKind="delimited"
              nillable="true" dfdl:nilKind="literalValue" dfdl:nilValue="NIL" />
-          <xs:element name="valLen" type="xs:string"
+          <xs:element name="valLen" type="xs:long"
             dfdl:lengthKind="delimited" dfdl:inputValueCalc="{ dfdl:valueLength( ../ex:str, 'bytes' ) }" />
         </xs:sequence>
       </xs:complexType>
@@ -393,7 +393,7 @@
           <xs:element name="str" type="xs:string"  dfdl:lengthKind="delimited"
              nillable="true" dfdl:nilKind="literalValue" dfdl:nilValue="NIL" />
           <xs:element name="valLen" type="xs:string"
-            dfdl:lengthKind="delimited" dfdl:outputValueCalc="{ dfdl:valueLength( ../ex:str, 'bytes' ) }" />
+            dfdl:lengthKind="delimited" dfdl:outputValueCalc="{ xs:string(dfdl:valueLength( ../ex:str, 'bytes' )) }" />
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -411,7 +411,7 @@
               </xs:sequence>
             </xs:complexType>
           </xs:element>
-          <xs:element name="valLen" type="xs:string"
+          <xs:element name="valLen" type="xs:long"
             dfdl:lengthKind="delimited" dfdl:inputValueCalc="{ dfdl:valueLength( ../ex:seq, 'bytes' ) }" />
         </xs:sequence>
       </xs:complexType>
@@ -431,7 +431,7 @@
             </xs:complexType>
           </xs:element>
           <xs:element name="valLen" type="xs:string"
-            dfdl:lengthKind="delimited" dfdl:outputValueCalc="{ dfdl:valueLength( ../ex:seq, 'bytes' ) }" />
+            dfdl:lengthKind="delimited" dfdl:outputValueCalc="{ xs:string(dfdl:valueLength( ../ex:seq, 'bytes' )) }" />
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -441,7 +441,7 @@
         <xs:sequence dfdl:separator=",">
           <xs:element name="str" type="xs:string"  dfdl:lengthKind="delimited" />
           <xs:element name="valLen" type="xs:string"
-            dfdl:lengthKind="delimited" dfdl:inputValueCalc="{ dfdl:valueLength( ../ex:str, 'wrong') }" />
+            dfdl:lengthKind="delimited" dfdl:inputValueCalc="{ xs:string(dfdl:valueLength( ../ex:str, 'wrong')) }" />
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -462,7 +462,7 @@
         <xs:sequence dfdl:separator=",">
           <xs:element name="str" type="xs:string"  dfdl:lengthKind="delimited" dfdl:textTrimKind="padChar" 
             dfdl:textStringPadCharacter="/" dfdl:textStringJustification="center" />
-          <xs:element name="conLen" dfdl:lengthKind="delimited" type="xs:string" dfdl:inputValueCalc="{ dfdl:contentLength( ../ex:str, 'bits' ) }" />
+          <xs:element name="conLen" dfdl:lengthKind="delimited" type="xs:long" dfdl:inputValueCalc="{ dfdl:contentLength( ../ex:str, 'bits' ) }" />
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -490,7 +490,7 @@
       </xs:complexType>
     </xs:element>
 
-    <xs:element name="e_concat4" type="xs:int" dfdl:inputValueCalc="{ fn:concat(1, 2) }" />
+    <xs:element name="e_concat4" type="xs:int" dfdl:inputValueCalc="{ xs:int(fn:concat(1, 2)) }" />
     <xs:element name="e_concat5" type="xs:string" dfdl:inputValueCalc="{ fn:concat('a','','b','c') }" />
 
     <xs:element name="e_substring1" type="xs:string" dfdl:inputValueCalc="{ fn:substring('A substring test', 6) }" />
@@ -543,7 +543,7 @@
         <xs:sequence dfdl:separator=",">
           <xs:element name="one" type="xs:string" dfdl:lengthKind="delimited" />
           <xs:element name="two" type="xs:string" dfdl:lengthKind="delimited" />
-          <xs:element name="contains" type="xs:string" dfdl:inputValueCalc="{ fn:contains(../ex:one, ../ex:two) }"/>
+          <xs:element name="contains" type="xs:boolean" dfdl:inputValueCalc="{ fn:contains(../ex:one, ../ex:two) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -558,7 +558,7 @@
         <xs:sequence dfdl:separator=",">
           <xs:element name="one" type="xs:string" dfdl:lengthKind="delimited" />
           <xs:element name="two" type="xs:string" dfdl:lengthKind="delimited" />
-          <xs:element name="starts" type="xs:string" dfdl:inputValueCalc="{ fn:starts-with(../ex:one, ../ex:two) }"/>
+          <xs:element name="starts" type="xs:boolean" dfdl:inputValueCalc="{ fn:starts-with(../ex:one, ../ex:two) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -573,7 +573,7 @@
         <xs:sequence dfdl:separator=",">
           <xs:element name="one" type="xs:string" dfdl:lengthKind="delimited" />
           <xs:element name="two" type="xs:string" dfdl:lengthKind="delimited" />
-          <xs:element name="ends" type="xs:string" dfdl:inputValueCalc="{ fn:ends-with(../ex:one, ../ex:two) }"/>
+          <xs:element name="ends" type="xs:boolean" dfdl:inputValueCalc="{ fn:ends-with(../ex:one, ../ex:two) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -4191,13 +4191,13 @@
       </xs:complexType>
     </xs:element>
  
-    <xs:element name="ceil" type="xs:int" dfdl:inputValueCalc="{ fn:ceiling(4.2) }"/>
+    <xs:element name="ceil" type="xs:double" dfdl:inputValueCalc="{ fn:ceiling(4.2) }"/>
 
     <xs:element name="ceil02">
       <xs:complexType>
         <xs:sequence>
           <xs:element name="val" type="xs:float" dfdl:lengthKind="delimited"/>
-          <xs:element name="ceilval" type="xs:int" dfdl:inputValueCalc="{ fn:ceiling(../ex:val) }"/>
+          <xs:element name="ceilval" type="xs:float" dfdl:inputValueCalc="{ fn:ceiling(../ex:val) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -4206,7 +4206,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="val" type="xs:string" dfdl:lengthKind="delimited"/>
-          <xs:element name="ceilval" type="xs:int" dfdl:inputValueCalc="{ fn:ceiling(xs:double(../ex:val)) }"/>
+          <xs:element name="ceilval" type="xs:double" dfdl:inputValueCalc="{ fn:ceiling(xs:double(../ex:val)) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -4215,7 +4215,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="val" type="xs:string" dfdl:lengthKind="delimited"/>
-          <xs:element xmlns:tst="http://www.w3.org/2005/xpath-functions" name="ceilval" type="xs:int" dfdl:inputValueCalc="{ tst:ceiling(xs:double(../ex:val)) }"/>
+          <xs:element xmlns:tst="http://www.w3.org/2005/xpath-functions" name="ceilval" type="xs:double" dfdl:inputValueCalc="{ tst:ceiling(xs:double(../ex:val)) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -4224,7 +4224,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="val" type="xs:hexBinary" dfdl:lengthKind="delimited" dfdl:encoding="ISO-8859-1"/>
-          <xs:element name="ceilval" type="xs:int" dfdl:inputValueCalc="{ fn:ceiling(../ex:val) }"/>
+          <xs:element name="ceilval" type="xs:double" dfdl:inputValueCalc="{ fn:ceiling(../ex:val) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -4235,7 +4235,7 @@
           <xs:element name="val" type="xs:float" dfdl:lengthKind="delimited"/>
           <xs:element name="ceilval" dfdl:inputValueCalc="{ fn:ceiling(../ex:val) }">
             <xs:simpleType>
-              <xs:restriction base="xs:int">
+              <xs:restriction base="xs:float">
                 <xs:maxExclusive value="50"/>
                 <xs:minExclusive value="0"/>
               </xs:restriction>
@@ -4249,18 +4249,18 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="val" type="xs:string" dfdl:lengthKind="delimited"/>
-          <xs:element name="ceilval" type="xs:int" dfdl:inputValueCalc="{ fn:ceiling(../ex:val) }"/>
+          <xs:element name="ceilval" type="xs:double" dfdl:inputValueCalc="{ fn:ceiling(../ex:val) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
     
-    <xs:element name="floor" type="xs:int" dfdl:inputValueCalc="{ fn:floor(4.2) }"/>
+    <xs:element name="floor" type="xs:double" dfdl:inputValueCalc="{ fn:floor(4.2) }"/>
 
     <xs:element name="floor02">
       <xs:complexType>
         <xs:sequence>
           <xs:element name="val" type="xs:float" dfdl:lengthKind="delimited"/>
-          <xs:element name="floorval" type="xs:int" dfdl:inputValueCalc="{ fn:floor(../ex:val) }"/>
+          <xs:element name="floorval" type="xs:float" dfdl:inputValueCalc="{ fn:floor(../ex:val) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -4269,7 +4269,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="val" type="xs:string" dfdl:lengthKind="delimited"/>
-          <xs:element name="floorval" type="xs:int" dfdl:inputValueCalc="{ fn:floor(xs:double(../ex:val)) }"/>
+          <xs:element name="floorval" type="xs:double" dfdl:inputValueCalc="{ fn:floor(xs:double(../ex:val)) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -4278,7 +4278,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="val" type="xs:string" dfdl:lengthKind="delimited"/>
-          <xs:element xmlns:tst="http://www.w3.org/2005/xpath-functions" name="floorval" type="xs:int" dfdl:inputValueCalc="{ tst:floor(xs:double(../ex:val)) }"/>
+          <xs:element xmlns:tst="http://www.w3.org/2005/xpath-functions" name="floorval" type="xs:double" dfdl:inputValueCalc="{ tst:floor(xs:double(../ex:val)) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -4289,7 +4289,7 @@
           <xs:element name="val" type="xs:float" dfdl:lengthKind="delimited"/>
           <xs:element name="floorval" dfdl:inputValueCalc="{ fn:floor(../ex:val) }">
             <xs:simpleType>
-              <xs:restriction base="xs:int">
+              <xs:restriction base="xs:float">
                 <xs:maxExclusive value="50"/>
                 <xs:minExclusive value="0"/>
               </xs:restriction>
@@ -4312,18 +4312,18 @@
       <xs:complexType>
         <xs:sequence dfdl:separator=",">
           <xs:element name="val" type="xs:float" dfdl:representation="binary" dfdl:lengthKind="explicit" dfdl:length="4"/>
-          <xs:element name="floorval" type="xs:int" dfdl:inputValueCalc="{ fn:floor(../ex:val) }"/>
+          <xs:element name="floorval" type="xs:float" dfdl:inputValueCalc="{ fn:floor(../ex:val) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
     
-    <xs:element name="round" type="xs:int" dfdl:inputValueCalc="{ fn:round(4.2) }"/>
+    <xs:element name="round" type="xs:double" dfdl:inputValueCalc="{ fn:round(4.2) }"/>
 
     <xs:element name="round02">
       <xs:complexType>
         <xs:sequence>
           <xs:element name="val" type="xs:float" dfdl:lengthKind="delimited" dfdl:textStandardInfinityRep="INF" dfdl:textStandardNaNRep="NaN"/>
-          <xs:element name="roundval" type="xs:int" dfdl:inputValueCalc="{ fn:round(../ex:val) }"/>
+          <xs:element name="roundval" type="xs:float" dfdl:inputValueCalc="{ fn:round(../ex:val) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -4332,7 +4332,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="val" type="xs:string" dfdl:lengthKind="delimited"/>
-          <xs:element name="roundval" type="xs:int" dfdl:inputValueCalc="{ fn:round(xs:double(../ex:val)) }"/>
+          <xs:element name="roundval" type="xs:double" dfdl:inputValueCalc="{ fn:round(xs:double(../ex:val)) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -4341,7 +4341,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="val" type="xs:string" dfdl:lengthKind="delimited"/>
-          <xs:element xmlns:tst="http://www.w3.org/2005/xpath-functions" name="roundval" type="xs:int" dfdl:inputValueCalc="{ tst:round(xs:double(../ex:val)) }"/>
+          <xs:element xmlns:tst="http://www.w3.org/2005/xpath-functions" name="roundval" type="xs:double" dfdl:inputValueCalc="{ tst:round(xs:double(../ex:val)) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -4350,7 +4350,7 @@
       <xs:complexType>
         <xs:sequence>
           <xs:element name="val" type="xs:float" dfdl:representation="binary" dfdl:lengthKind="explicit" dfdl:length="4"/>
-          <xs:element name="roundval" type="xs:int" dfdl:inputValueCalc="{ fn:round(../ex:val) }"/>
+          <xs:element name="roundval" type="xs:float" dfdl:inputValueCalc="{ fn:round(../ex:val) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -4360,7 +4360,7 @@
         <xs:sequence>
           <xs:element name="one" type="xs:float" dfdl:representation="binary" dfdl:lengthKind="explicit" dfdl:length="4"/>
           <xs:element name="two" type="xs:float" dfdl:representation="binary" dfdl:lengthKind="explicit" dfdl:length="4"/>
-          <xs:element name="roundval" type="xs:int" dfdl:inputValueCalc="{ fn:round(../ex:one + ../ex:two) }"/>
+          <xs:element name="roundval" type="xs:float" dfdl:inputValueCalc="{ fn:round(../ex:one + ../ex:two) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -4418,7 +4418,7 @@
       <xs:complexType>
         <xs:sequence dfdl:separator=",">
           <xs:element name="num" type="xs:string" dfdl:lengthKind="delimited"/>
-          <xs:element name="roundval" type="xs:float" dfdl:inputValueCalc="{ fn:round-half-to-even(xs:double(../ex:num)) }"/>
+          <xs:element name="roundval" type="xs:double" dfdl:inputValueCalc="{ fn:round-half-to-even(xs:double(../ex:num)) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -4427,7 +4427,26 @@
       <xs:complexType>
         <xs:sequence dfdl:separator=",">
           <xs:element name="num" dfdl:representation="binary" type="xs:float" dfdl:lengthKind="explicit" dfdl:lengthUnits="bytes" dfdl:length="4"/>
-          <xs:element name="roundval" type="xs:float" dfdl:inputValueCalc="{ fn:round-half-to-even(xs:double(../ex:num)) }"/>
+          <xs:element name="roundval" type="xs:double" dfdl:inputValueCalc="{ fn:round-half-to-even(xs:double(../ex:num)) }"/>
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+
+    <xs:element name="round-hte-7">
+      <xs:complexType>
+        <xs:sequence dfdl:separator=",">
+          <xs:element name="num" type="xs:float" dfdl:lengthKind="delimited" dfdl:textNumberPattern="#.#######"/>
+          <xs:element name="precision" type="xs:int" dfdl:lengthKind="delimited"/>
+          <xs:element name="roundval" type="xs:int" dfdl:inputValueCalc="{ xs:int(fn:round-half-to-even(../ex:num,../ex:precision)) }"/>
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+
+    <xs:element name="round-hte-8">
+      <xs:complexType>
+        <xs:sequence dfdl:separator=",">
+          <xs:element name="num" type="xs:string" dfdl:lengthKind="delimited"/>
+          <xs:element name="roundval" type="xs:int" dfdl:inputValueCalc="{ xs:int(fn:round-half-to-even(xs:double(../ex:num))) }"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
@@ -5170,7 +5189,7 @@
     </tdml:document>
     <tdml:infoset>
       <tdml:dfdlInfoset>
-        <ceil>5</ceil>
+        <ceil>5.0</ceil>
       </tdml:dfdlInfoset>
     </tdml:infoset>
   </tdml:parserTestCase>
@@ -5192,7 +5211,7 @@
       <tdml:dfdlInfoset>
         <ceil02>
           <val>6.1</val>
-          <ceilval>7</ceilval>
+          <ceilval>7.0</ceilval>
         </ceil02>
       </tdml:dfdlInfoset>
     </tdml:infoset>
@@ -5237,7 +5256,7 @@
       <tdml:dfdlInfoset>
         <ceil04>
           <val>4.2</val>
-          <ceilval>5</ceilval>
+          <ceilval>5.0</ceilval>
         </ceil04>
       </tdml:dfdlInfoset>
     </tdml:infoset>
@@ -5260,7 +5279,7 @@
       <tdml:dfdlInfoset>
         <ceil04>
           <val>-3.4</val>
-          <ceilval>-3</ceilval>
+          <ceilval>-3.0</ceilval>
         </ceil04>
       </tdml:dfdlInfoset>
     </tdml:infoset>
@@ -5301,14 +5320,14 @@
       <tdml:dfdlInfoset>
         <ex:ceil06>
           <val>49.2</val>
-          <ceilval>50</ceilval>
+          <ceilval>50.0</ceilval>
         </ex:ceil06>
       </tdml:dfdlInfoset>
     </tdml:infoset>
     <tdml:validationErrors>
-      <tdml:error>'50'</tdml:error>
+      <tdml:error>'50.0'</tdml:error>
       <tdml:error>not facet-valid</tdml:error>
-      <tdml:error>maxExclusive '50'</tdml:error>
+      <tdml:error>maxExclusive</tdml:error>
     </tdml:validationErrors>
   </tdml:parserTestCase>
 
@@ -5346,7 +5365,7 @@
     </tdml:document>
     <tdml:infoset>
       <tdml:dfdlInfoset>
-        <floor>4</floor>
+        <floor>4.0</floor>
       </tdml:dfdlInfoset>
     </tdml:infoset>
   </tdml:parserTestCase>
@@ -5368,7 +5387,7 @@
       <tdml:dfdlInfoset>
         <floor02>
           <val>6.1</val>
-          <floorval>6</floorval>
+          <floorval>6.0</floorval>
         </floor02>
       </tdml:dfdlInfoset>
     </tdml:infoset>
@@ -5413,7 +5432,7 @@
       <tdml:dfdlInfoset>
         <floor04>
           <val>4.2</val>
-          <floorval>4</floorval>
+          <floorval>4.0</floorval>
         </floor04>
       </tdml:dfdlInfoset>
     </tdml:infoset>
@@ -5436,7 +5455,7 @@
       <tdml:dfdlInfoset>
         <floor04>
           <val>-3.4</val>
-          <floorval>-4</floorval>
+          <floorval>-4.0</floorval>
         </floor04>
       </tdml:dfdlInfoset>
     </tdml:infoset>
@@ -5458,14 +5477,14 @@
       <tdml:dfdlInfoset>
         <floor05>
           <val>0.8</val>
-          <floorval>0</floorval>
+          <floorval>0.0</floorval>
         </floor05>
       </tdml:dfdlInfoset>
     </tdml:infoset>
     <tdml:validationErrors>
-      <tdml:error>'0'</tdml:error>
+      <tdml:error>'0.0'</tdml:error>
       <tdml:error>not facet-valid</tdml:error>
-      <tdml:error>minExclusive '0'</tdml:error>
+      <tdml:error>minExclusive</tdml:error>
     </tdml:validationErrors>
   </tdml:parserTestCase>
 
@@ -5503,7 +5522,7 @@
       <tdml:dfdlInfoset>
         <floor07>
           <val>42.0</val>
-          <floorval>42</floorval>
+          <floorval>42.0</floorval>
         </floor07>
       </tdml:dfdlInfoset>
     </tdml:infoset>
@@ -5525,7 +5544,7 @@
     </tdml:document>
     <tdml:infoset>
       <tdml:dfdlInfoset>
-        <round>4</round>
+        <round>4.0</round>
       </tdml:dfdlInfoset>
     </tdml:infoset>
   </tdml:parserTestCase>
@@ -5547,7 +5566,7 @@
       <tdml:dfdlInfoset>
         <round02>
           <val>6.1</val>
-          <roundval>6</roundval>
+          <roundval>6.0</roundval>
         </round02>
       </tdml:dfdlInfoset>
     </tdml:infoset>
@@ -5592,7 +5611,7 @@
       <tdml:dfdlInfoset>
         <round04>
           <val>4.2</val>
-          <roundval>4</roundval>
+          <roundval>4.0</roundval>
         </round04>
       </tdml:dfdlInfoset>
     </tdml:infoset>
@@ -5615,7 +5634,7 @@
       <tdml:dfdlInfoset>
         <round04>
           <val>-3.4</val>
-          <roundval>-3</roundval>
+          <roundval>-3.0</roundval>
         </round04>
       </tdml:dfdlInfoset>
     </tdml:infoset>
@@ -5638,7 +5657,7 @@
       <tdml:dfdlInfoset>
         <round04>
           <val>.5</val>
-          <roundval>1</roundval>
+          <roundval>1.0</roundval>
         </round04>
       </tdml:dfdlInfoset>
     </tdml:infoset>
@@ -5680,7 +5699,7 @@
       <tdml:dfdlInfoset>
         <round05>
           <val>40.3</val>
-          <roundval>40</roundval>
+          <roundval>40.0</roundval>
         </round05>
       </tdml:dfdlInfoset>
     </tdml:infoset>
@@ -5703,7 +5722,7 @@
       <tdml:dfdlInfoset>
         <round05>
           <val>40.5</val>
-          <roundval>41</roundval>
+          <roundval>41.0</roundval>
         </round05>
       </tdml:dfdlInfoset>
     </tdml:infoset>
@@ -5727,7 +5746,7 @@
         <round06>
           <one>10.3</one>
           <two>10.4</two>
-          <roundval>21</roundval>
+          <roundval>21.0</roundval>
         </round06>
       </tdml:dfdlInfoset>
     </tdml:infoset>
@@ -5751,7 +5770,7 @@
         <round06>
           <one>10.3</one>
           <two>10.1</two>
-          <roundval>20</roundval>
+          <roundval>20.0</roundval>
         </round06>
       </tdml:dfdlInfoset>
     </tdml:infoset>
@@ -5770,9 +5789,14 @@
     <tdml:document>
       <tdml:documentPart type="text">INF</tdml:documentPart>
     </tdml:document>
-    <tdml:errors>
-      <tdml:error>Parse Error</tdml:error>
-    </tdml:errors>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <round02>
+          <val>INF</val>
+          <roundval>INF</roundval>
+        </round02>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
   </tdml:parserTestCase>
 
 <!--
@@ -5815,7 +5839,7 @@
       <tdml:dfdlInfoset>
         <round04>
           <val>-0.5</val>
-          <roundval>0</roundval>
+          <roundval>0.0</roundval>
         </round04>
       </tdml:dfdlInfoset>
     </tdml:infoset>
@@ -5838,7 +5862,7 @@
       <tdml:dfdlInfoset>
         <round04>
           <val>-0.0</val>
-          <roundval>0</roundval>
+          <roundval>0.0</roundval>
         </round04>
       </tdml:dfdlInfoset>
     </tdml:infoset>
@@ -6158,7 +6182,7 @@
       <tdml:documentPart type="text">three point two,5</tdml:documentPart>
     </tdml:document>
     <tdml:errors>
-      <tdml:error>String cannot be converted to Numeric</tdml:error>
+      <tdml:error>First argument must be of numeric type but was String</tdml:error>
     </tdml:errors>
   </tdml:parserTestCase>
 
@@ -6255,6 +6279,54 @@
       </tdml:dfdlInfoset>
     </tdml:infoset>
   </tdml:parserTestCase>
+
+<!--
+    Test Name: round_hte_17
+       Schema: XPathFunctions
+         Root: round-hte
+      Purpose: This test demonstrates the round-half-to-even function, converted to an xs:int
+-->
+
+  <tdml:parserTestCase name="round_hte_17" root="round-hte-7"
+    model="XPathFunctions" description="Section 23.5.2 - Standard XPath Functions - round-half-to-even - DFDL-23-098R">
+
+    <tdml:document>
+      <tdml:documentPart type="text">3.45,0</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <round-hte-7>
+          <num>3.45</num>
+          <precision>0</precision>
+          <roundval>3</roundval>
+        </round-hte-7>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+<!--
+    Test Name: round_hte_18
+       Schema: XPathFunctions
+         Root: round-hte-8
+      Purpose: This test demonstrates the round-half-to-even function, converted to an xs:int
+-->
+
+  <tdml:parserTestCase name="round_hte_18" root="round-hte-8"
+    model="XPathFunctions" description="Section 23.5.2 - Standard XPath Functions - round-half-to-even - DFDL-23-098R">
+
+    <tdml:document>
+      <tdml:documentPart type="text">3.5</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <round-hte-8>
+          <num>3.5</num>
+          <roundval>4</roundval>
+        </round-hte-8>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+  
   
   <tdml:defineSchema name="constructorSchema">
     <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
diff --git a/daffodil-test/src/test/scala-debug/org/apache/daffodil/section23/dfdl_expressions/TestDFDLExpressionsDebug.scala b/daffodil-test/src/test/scala-debug/org/apache/daffodil/section23/dfdl_expressions/TestDFDLExpressionsDebug.scala
index a0f7efa..c5fad72 100644
--- a/daffodil-test/src/test/scala-debug/org/apache/daffodil/section23/dfdl_expressions/TestDFDLExpressionsDebug.scala
+++ b/daffodil-test/src/test/scala-debug/org/apache/daffodil/section23/dfdl_expressions/TestDFDLExpressionsDebug.scala
@@ -80,9 +80,6 @@ class TestDFDLExpressionsDebug {
   // DFDL-1043
   @Test def test_checkConstraintsComplexTypeFails() { runner.runOneTest("checkConstraintsComplexTypeFails") }
 
-  // DFDL-1044
-  @Test def test_expression_type_error2() { runner.runOneTest("expression_type_error2") }
-
   //DFDL-1164
   @Test def test_predicate_02() { runner.runOneTest("predicate_02") }
   @Test def test_predicate_03() { runner.runOneTest("predicate_03") }
diff --git a/daffodil-test/src/test/scala/org/apache/daffodil/section23/dfdl_expressions/TestDFDLExpressions.scala b/daffodil-test/src/test/scala/org/apache/daffodil/section23/dfdl_expressions/TestDFDLExpressions.scala
index 9fee6fa..a89c4e4 100644
--- a/daffodil-test/src/test/scala/org/apache/daffodil/section23/dfdl_expressions/TestDFDLExpressions.scala
+++ b/daffodil-test/src/test/scala/org/apache/daffodil/section23/dfdl_expressions/TestDFDLExpressions.scala
@@ -226,10 +226,12 @@ class TestDFDLExpressions {
   @Test def test_ArrayOptElem_01() { runner.runOneTest("ArrayOptElem_01") }
   @Test def test_lke2_rel() { runner.runOneTest("lke2_rel") }
   @Test def test_expression_type_error1() { runner.runOneTest("expression_type_error1") }
-  // DFDL-1044
-  // @Test def test_expression_type_error2() { runner.runOneTest("expression_type_error2") }
+  @Test def test_expression_type_error2() { runner.runOneTest("expression_type_error2") }
   @Test def test_expression_type_error3() { runner.runOneTest("expression_type_error3") }
   @Test def test_expression_type_error4() { runner.runOneTest("expression_type_error4") }
+  @Test def test_expression_type_error5() { runner.runOneTest("expression_type_error5") }
+  @Test def test_expression_type_error6() { runner.runOneTest("expression_type_error6") }
+  @Test def test_expression_type_error7() { runner.runOneTest("expression_type_error7") }
   @Test def test_expression_unknown_prefix() { runner.runOneTest("expression_unknown_prefix") }
   @Test def test_ocke_rel() { runner.runOneTest("ocke_rel") }
   @Test def test_ocke_rel2() { runner.runOneTest("ocke_rel2") }
@@ -448,6 +450,8 @@ class TestDFDLExpressions {
   @Test def test_round_hte_14() { runner2.runOneTest("round_hte_14") }
   @Test def test_round_hte_15() { runner2.runOneTest("round_hte_15") }
   @Test def test_round_hte_16() { runner2.runOneTest("round_hte_16") }
+  @Test def test_round_hte_17() { runner2.runOneTest("round_hte_17") }
+  @Test def test_round_hte_18() { runner2.runOneTest("round_hte_18") }
 
   //DFDL-1080
   //@Test def test_empty_02() { runner2.runOneTest("empty_02") }