mbeckerle commented on a change in pull request #385:
URL: https://github.com/apache/incubator-daffodil/pull/385#discussion_r437525119



##########
File path: 
daffodil-runtime1/src/main/scala/org/apache/daffodil/dsom/CompiledExpression1.scala
##########
@@ -143,7 +143,7 @@ final case class ConstantExpression[+T <: AnyRef](
 
   lazy val sourceType: NodeInfo.Kind = NodeInfo.fromObject(value)
 
-  def isKnownNonEmpty = value != ""
+  def isKnownNonEmpty = value != "" && value != "%ES;" && !(value == "%WSP*;" 
&& qn.toQNameString == "dfdl:initiator")

Review comment:
       The initiator can be an expression. That expression might look at 
variables. So it may not be able to be evaluated at all at compile time. 
   
   So that means the best we can do is isKnownESMatching which is a heuristic 
to tell us the expression (or literal) for the initiator is definitely a 
problem for initiatedContent. Otherwise we need a runtime check. 
   
   I suggest not changing isKnownNotEmpty, because the meaning of that can't 
change. It means the literal, or return value of the expression, will not be 
"". We disallow delimiter expressions from returning "" because you can't 
change the way the schema lengthKind is compiled with a runtime change, and 
returning "" for a delimiter is turning off the delimited nature of the schema. 
   
   I think what we need for the initiatedContent check is two things. A compile 
time check 
   `
   lazy val isRequiredRuntimeCheckForEmptyInitiator =
   if (initiatedContent == YesNo.Yes) {
       SDEUnless(isKnownNonEmpty, "The initiator property cannot be '' (empty 
string) when initiatedContent='yes'.")
       SDEWhen(isKnownESMatching, "The initiator property value '%s' can match 
the empty string, which is incompatible with initiatedContent='yes'.",  
initiator)
      true
   } else 
     false 
   `
   
   I'm pseudo coding here. I'm not sure about the initiator argument to the 
SDEWhen above. Maybe a better way to get that for inclusion in the message 
string. (e.g., something like initiatorExpr.prettyString or some such). 
   
   Given the above, isKnownESMatching can make a best effort at determining if 
the expression, which evaluates to a delimiter that may contain entities, can 
then match empty string successfully. Checking for the obvious cases 
syntactically is fine here.  
   
   Then if our isRequiredRuntimeCheckForEmptyInitiator is true, we have to 
include that check at runtime. 
   
   
   
   

##########
File path: 
daffodil-runtime1/src/main/scala/org/apache/daffodil/dsom/CompiledExpression1.scala
##########
@@ -143,7 +143,7 @@ final case class ConstantExpression[+T <: AnyRef](
 
   lazy val sourceType: NodeInfo.Kind = NodeInfo.fromObject(value)
 
-  def isKnownNonEmpty = value != ""
+  def isKnownNonEmpty = value != "" && value != "%ES;" && !(value == "%WSP*;" 
&& qn.toQNameString == "dfdl:initiator")

Review comment:
       The initiator can be an expression. That expression might look at 
variables. So it may not be able to be evaluated at all at compile time. 
   
   So that means the best we can do is isKnownESMatching which is a heuristic 
to tell us the expression (or literal) for the initiator is definitely a 
problem for initiatedContent. Otherwise we need a runtime check. 
   
   I suggest not changing isKnownNotEmpty, because the meaning of that can't 
change. It means the literal, or return value of the expression, will not be 
"". We disallow delimiter expressions from returning "" because you can't 
change the way the schema lengthKind is compiled with a runtime change, and 
returning "" for a delimiter is turning off the delimited nature of the schema. 
   
   I think what we need for the initiatedContent check is two things. A compile 
time check 
   ```
   lazy val isRequiredRuntimeCheckForEmptyInitiator =
   if (initiatedContent == YesNo.Yes) {
       SDEUnless(isKnownNonEmpty, "The initiator property cannot be '' (empty 
string) when initiatedContent='yes'.")
       SDEWhen(isKnownESMatching, "The initiator property value '%s' can match 
the empty string, which is incompatible with initiatedContent='yes'.",  
initiator)
      true
   } else 
     false 
   ```
   
   I'm pseudo coding here. I'm not sure about the initiator argument to the 
SDEWhen above. Maybe a better way to get that for inclusion in the message 
string. (e.g., something like initiatorExpr.prettyString or some such). 
   
   Given the above, isKnownESMatching can make a best effort at determining if 
the expression, which evaluates to a delimiter that may contain entities, can 
then match empty string successfully. Checking for the obvious cases 
syntactically is fine here.  
   
   Then if our isRequiredRuntimeCheckForEmptyInitiator is true, we have to 
include that check at runtime. 
   
   
   
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to