You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "Steve Lawrence (Jira)" <ji...@apache.org> on 2021/08/11 14:08:00 UTC

[jira] [Created] (DAFFODIL-2554) Debugger infoset output is confusing with hidden groups

Steve Lawrence created DAFFODIL-2554:
----------------------------------------

             Summary: Debugger infoset output is confusing with hidden groups
                 Key: DAFFODIL-2554
                 URL: https://issues.apache.org/jira/browse/DAFFODIL-2554
             Project: Daffodil
          Issue Type: Bug
          Components: Debugger
            Reporter: Steve Lawrence


When the CLI debugger outputs the infoset with the "info infoset" command, it defaults to showing hidden groups. This is useful when debugging since you usually want to see everything that happens during parse, even if it won't end up in the final infoset.

But when outputting complex types that are completely hidden we get things that look like this:
{code:xml}
<f>
  <h>
    <f xmlns="">2</f></h></f>
{code}
Note how the closing tags are not on a newline. This isn't too bad, but when infosets get big it becomes hard to read.

I think the underlying issues is that the XMLTextInfosetOutputter uses "hasVisibleChildren" to determine when we should output newlines when end complex elements. If a complex element has no visible children (either because there are no children or because they are all hidden), then this causes us to output <foo></foo> without a newline. This is the expected behavior.

We probably want to keep this behavior but need to change how we figure out when to output newlines. This is because an element might not have any visible children, but they will still be output by the debugger, so there are visible children from the debuggers perspective and so we need newlines.

So I think we first want to get rid of hasVisibleChildren completely. It's only used by the XMLTextInfosetOutputter, so we can just need adjust that class to keep track of the logic. And I think we can do so by just adding a single mutable member variable to the class, something like:

{code:scala}
var currentComplexElementHasChildren: Boolean = false
{code}

When startComplex is called, we always set this variable to false, since this is the current complex and we don't know yet if it has children.

When startSimple is called, we always set this variable to true, since we now know the current complex has at least one child.

When endComplex is called, we output a newline only if the variable is true. Additionally, we then always set the variable to true. This is because if we are ending a complex, that means all parent complex elements must have children (because this complex element we are ending is a child of all those parent complex elements). This will ensure when all parent complex elements output newlines when they too are ended.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)