Based on the output, I'm guessing this has to do with Daffodil's constant
folding of expressions. When Daffodil compiles schemas it evaluates expressions
to determine if they are constant, and if they are then it saves the result and
uses that at runtime instead of evaluating the expression. This improves
performance.
In your save-parser command output, we do see the trace log:
> daffodil -v save-parser -s jpeg.trace.dfdl.xsd tracer
> [info] dfdlx:trace testing : DataValue(100)
By seeing the log in the save-parser command, this indicates that the arguments
of the trace function are a constant expression, and so Daffodil just saves the
result and does not log anything at runtime.
As a workaround, if you modify the expression to reference an element (or some
other change that makes it non-constant) then then trace log should appear when
using a saved parser. This is usually how dfdlx:trace is used, which
non-constant values, so I suspect most uses of dfdlx:trace won't run into the
issue you did.
Because logging functions are considered impure, I think our current behavior of
considering it a constant is probably not correct. I've opened a ticket here to
track this issue:
https://issues.apache.org/jira/browse/DAFFODIL-3105
- Steve
On 2026-10-20 01:50 PM, Larry Barber wrote:
I've been working on an issue with the VSCode extension dealing with
dfdlx:trace: https://github.com/apache/daffodil-vscode/issues/116
I got it partially working but was stuck on one particular issue.
The 1.6.0 pre-release extension now automatically saves/re-uses the compiled
parser if the schema doesn't get changed.
The dfdlx:trace output works when the schema gets compiled but would not work
when running the precompiled parser.
After beating my head on this for a while, I tried the CLI version...
The -v works with saved parser -- except the dfdlx:trace output is missing!
C:\Users\larry.barber\Documents\PaxRiver> daffodil -v parse -s
jpeg.trace.dfdl.xsd -o infoset.xml daffodil.jpg
[info] dfdlx:trace testing : DataValue(100)
[warn] Schema Definition Warning: Counterintuitive placement detected. Wrap the
discriminator or assert in an empty sequence to evaluate before the contents.
(id: discouragedDiscriminatorPlacement)
Schema context: sequence[2] Location line 637 column 58 in jpeg.trace.dfdl.xsd
[warn] Schema Definition Warning: Counterintuitive placement detected. Wrap the
discriminator or assert in an empty sequence to evaluate before the contents.
(id: discouragedDiscriminatorPlacement)
Schema context: sequence[1] Location line 629 column 58 in jpeg.trace.dfdl.xsd
[warn] Schema Definition Warning: Counterintuitive placement detected. Wrap the
discriminator or assert in an empty sequence to evaluate before the contents.
(id: discouragedDiscriminatorPlacement)
Schema context: sequence[2] Location line 365 column 46 in jpeg.trace.dfdl.xsd
[warn] Schema Definition Warning: Counterintuitive placement detected. Wrap the
discriminator or assert in an empty sequence to evaluate before the contents.
(id: discouragedDiscriminatorPlacement)
Schema context: sequence[1] Location line 350 column 46 in jpeg.trace.dfdl.xsd
[warn] Schema Definition Warning: Counterintuitive placement detected. Wrap the
discriminator or assert in an empty sequence to evaluate before the contents.
(id: discouragedDiscriminatorPlacement)
Schema context: sequence[3] Location line 767 column 30 in jpeg.trace.dfdl.xsd
[warn] Schema Definition Warning: Counterintuitive placement detected. Wrap the
discriminator or assert in an empty sequence to evaluate before the contents.
(id: discouragedDiscriminatorPlacement)
Schema context: sequence[2] Location line 736 column 30 in jpeg.trace.dfdl.xsd
[warn] Schema Definition Warning: Counterintuitive placement detected. Wrap the
discriminator or assert in an empty sequence to evaluate before the contents.
(id: discouragedDiscriminatorPlacement)
Schema context: sequence[1] Location line 720 column 30 in jpeg.trace.dfdl.xsd
[info] Time (compiling): 2892ms
[info] Time (parsing): 83ms
C:\Users\larry.barber\Documents\dfdlx_trace> daffodil -v save-parser -s
jpeg.trace.dfdl.xsd tracer
[info] dfdlx:trace testing : DataValue(100)
[warn] Schema Definition Warning: Counterintuitive placement detected. Wrap the
discriminator or assert in an empty sequence to evaluate before the contents.
(id: discouragedDiscriminatorPlacement)
Schema context: sequence[2] Location line 637 column 58 in jpeg.trace.dfdl.xsd
[warn] Schema Definition Warning: Counterintuitive placement detected. Wrap the
discriminator or assert in an empty sequence to evaluate before the contents.
(id: discouragedDiscriminatorPlacement)
Schema context: sequence[1] Location line 629 column 58 in jpeg.trace.dfdl.xsd
[warn] Schema Definition Warning: Counterintuitive placement detected. Wrap the
discriminator or assert in an empty sequence to evaluate before the contents.
(id: discouragedDiscriminatorPlacement)
Schema context: sequence[2] Location line 365 column 46 in jpeg.trace.dfdl.xsd
[warn] Schema Definition Warning: Counterintuitive placement detected. Wrap the
discriminator or assert in an empty sequence to evaluate before the contents.
(id: discouragedDiscriminatorPlacement)
Schema context: sequence[1] Location line 350 column 46 in jpeg.trace.dfdl.xsd
[warn] Schema Definition Warning: Counterintuitive placement detected. Wrap the
discriminator or assert in an empty sequence to evaluate before the contents.
(id: discouragedDiscriminatorPlacement)
Schema context: sequence[3] Location line 767 column 30 in jpeg.trace.dfdl.xsd
[warn] Schema Definition Warning: Counterintuitive placement detected. Wrap the
discriminator or assert in an empty sequence to evaluate before the contents.
(id: discouragedDiscriminatorPlacement)
Schema context: sequence[2] Location line 736 column 30 in jpeg.trace.dfdl.xsd
[warn] Schema Definition Warning: Counterintuitive placement detected. Wrap the
discriminator or assert in an empty sequence to evaluate before the contents.
(id: discouragedDiscriminatorPlacement)
Schema context: sequence[1] Location line 720 column 30 in jpeg.trace.dfdl.xsd
[info] Time (compiling): 2728ms
[info] Time (saving): 231ms
C:\Users\larry.barber\Documents\dfdlx_trace> daffodil -v parse -P tracer -o
infoset.xml daffodil.jpg
[info] Time (reloading): 383ms
[info] Time (parsing): 117ms
I don't know if this was the intended functionality, or if anyone cares to
change it. The extension will have the same limitation - it's just more
irritating since it automatically uses saved parsers, so users will have to
constantly modify their schema to get the trace output.
Also looks like the github schemas need to be updated to eliminate some warning
messages.