[
https://issues.apache.org/jira/browse/DAFFODIL-2977?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17931968#comment-17931968
]
Steve Lawrence commented on DAFFODIL-2977:
------------------------------------------
Note that the XMLTextInfosetOutputer has always output <foo></foo>, and that is
the only InfosetOutputter that actually writes infosets as strings. All other
infoset outputters just create objects (JDOM, ScalaXML, SAX events, etc.). Note
that the CLI Main does pretty print those objects, but that uses the the
features of the individual library--Daffodil doesn't really do anything special
aside from doing the equivalent of infosetOutputterResult.toString. So maybe a
library we used changed their behavior?
It looks like ScalaXML, used by the ScalaXMLInfosetOutputter does have some
kind of minimize mode option to determine how to output empty elements:
https://github.com/scala/scala-xml/blob/main/shared/src/main/scala/scala/xml/Utility.scala#L253-L264
Maybe you're looking at Scala XML output and maybe they changed their default?
> It's also possible that we should be special casing the filling in of
> string-type elements so that if the string value is length 0 we don't output
> any child at all. Filling in a child string object inside a DOM or JDOM node
> object where that child string is of zero length is going to perhaps cause
> this `<string></string>` vs. `<string/>` behavior. But in XML these are
> indistinguishable, so we should catch this case and not attach the child at
> all.
Note that this would have to be up to our individual infoset outputter
implementations on how they want to handle empty strings. For example,
JSONInfosetOutputter must always output double quotes for an empty string. And
this also might not have an affect for some infoset outputters For example, in
Scala-xml, it is a function how the pretty printer serializes to text--it
treats no-content vs empty string content the same.
> Empty XML element behavior has changed. Needs to be specific.
> -------------------------------------------------------------
>
> Key: DAFFODIL-2977
> URL: https://issues.apache.org/jira/browse/DAFFODIL-2977
> Project: Daffodil
> Issue Type: Bug
> Components: Back End
> Affects Versions: 3.10.0
> Reporter: Mike Beckerle
> Priority: Major
>
> XML output used to be `<foo></foo>` but now is `<foo/>` or vice versa.
> Needs to be definite one or the other. (I recommend `<foo/>`
> For any XML outputter, we need to control this behavior so that it is
> definitely one or the other and doesn't change from release to release.
> It's also possible that we should be special casing the filling in of
> string-type elements so that if the string value is length 0 we don't output
> any child at all. Filling in a child string object inside a DOM or JDOM node
> object where that child string is of zero length is going to perhaps cause
> this `<string></string>` vs. `<string/>` behavior. But in XML these are
> indistinguishable, so we should catch this case and not attach the child at
> all.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)