stevedlawrence commented on code in PR #1105:
URL: https://github.com/apache/daffodil/pull/1105#discussion_r1376616235
##########
daffodil-lib/src/main/scala/org/apache/daffodil/lib/cookers/EntityReplacer.scala:
##########
@@ -774,18 +763,14 @@ class NonEmptyListOfStringLiteral(pn: String,
allowByteEntities: Boolean)
override def testCooked(cookedList: List[String], context: ThrowsSDE) = {
context.schemaDefinitionUnless(
- cookedList.exists { _.length > 0 },
+ cookedList.length > 0,
"Property dfdl:%s cannot be empty string. Use dfdl:nilValue='%%ES;' for
empty string as nil value.",
Review Comment:
Changed to use `%s` and `propName` so the error message should stay the same
so not break existing tests.
Semi-related, in making these changes, I noticed a lot of duplication in our
cookers (e.g. these multiple nil cookers). I'm thinking at some point we may
want to refactor these. For example, we have some really complicated cookers
that are like:
```scala
object ChoiceDispatchKeyCooker extends
StringLiteralNonEmptyNoCharClassEntitiesNoByteEntities()
```
I imagine we can replace these just just a bunch of mixins, e.g.
```scala
object ChoiceDispatchKeyCooker extends StringLiteral
with NonEmptyLiteral
with NoCharClassEntities
with NoByteEntities
```
So we just create a bunch of tiny specific traits that are easy to write and
verify, and stack them all together. It makes the cooker definitions a bit
longer, but makes it much easier to fix/change them without having to create
new 50+ character classes when a new property needs something slightly
different.
For another day though.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]