-
Notifications
You must be signed in to change notification settings - Fork 10.3k
XFA subform with occur min=0 and no bound data displaying. #14218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I didn't add a test to manifest.json because pdf in issue is not a link but attached file.
on subform_min_0 branch:
All went well but please lemme know if you would prefer me adding test to manifest.json and to test/pdfs. |
Please note that whenever feasible, we'd like all patches to include tests (since that helps avoid regressions later on). For those cases when a PDF document is attached to an issue, you've got two options for creating the test:
In this particular case, it looks like option two is actually feasible!
|
@Snuffleupagus yep no problem at all, will do in a bit 😊 |
c00c0e0
to
34b5125
Compare
@Snuffleupagus oh sorry, I just noticed you've mentioned amend, but I rebased (as my previous ones). Hope its okay! |
I really don't think it matters exactly how you do it, as long as the end result looks correct :-) |
/botio xfatest |
From: Bot.io (Linux m4)ReceivedCommand cmd_xfatest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/9ad95d886205346/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_xfatest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.193.163.58:8877/86b55d56b4da552/output.txt |
src/core/xfa/bind.js
Outdated
@@ -643,6 +643,9 @@ class Binder { | |||
: dataNode[$namespaceId]; | |||
match = child[$data] = new XmlObject(nsId, child.name); | |||
if (this.emptyMerge) { | |||
if (child.name === "nomin" && child.occur.min === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you point out where in the specifications you found that an element called nomin
is useless ?
Afaik, an element with a child <occur min="0" ...>
is useless when no data can be bound in this element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a look on:
Line 666 in 6a15973
uselessNodes.push(child); |
The node is useless when
match
is null (nothing has been found in the data tree which matches with the child from the template tree) and min <= 0
(i.e. min===0
).But because of a bug, with the pdf in the issue, we never hit this path.
So there are several possibilities:
- we've a
match
when we shouldn't; - we've
min > 0
when we shouldn't; - we never go there because there is a
continue
or areturn
somewhere.
From: Bot.io (Linux m4)FailedFull output at http://54.241.84.105:8877/9ad95d886205346/output.txt Total script time: 9.41 mins
Image differences available at: http://54.241.84.105:8877/9ad95d886205346/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/86b55d56b4da552/output.txt Total script time: 14.62 mins
Image differences available at: http://54.193.163.58:8877/86b55d56b4da552/reftest-analyzer.html#web=eq.log |
34b5125
to
7c76d8e
Compare
@@ -637,6 +637,9 @@ class Binder { | |||
if (!match) { | |||
// We're in matchTemplate mode so create a node in data to reflect | |||
// what we've in template. | |||
if (child.occur.min === 0) { | |||
uselessNodes.push(child); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The comment here doesn't apply to the added code so you should move it
- you should add a comment (you can quote the specification or add a link to it) to explain why the node is useless.
- once we know that the child is useless, you can then skip the code after.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏽
7c76d8e
to
2674850
Compare
src/core/xfa/bind.js
Outdated
@@ -635,6 +635,13 @@ class Binder { | |||
/* skipConsumed = */ this.emptyMerge | |||
).next().value; | |||
if (!match) { | |||
// If there is no match (no data) and occur.min === 0 | |||
// container is entirely excluded. | |||
// https://www.pdfa.org/norm-refs/XFA-3_3.pdf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That document is over 1500 pages long, please link directly to the relevant section instead; I'm guessing that https://www.pdfa.org/norm-refs/XFA-3_3.pdf#G23.1904923 might be correct here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this section is a bit more specific:
https://www.pdfa.org/norm-refs/XFA-3_3.pdf#G12.1428332
src/core/xfa/bind.js
Outdated
// If there is no match (no data) and occur.min === 0 | ||
// container is entirely excluded. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seem to be a couple of words missing in the middle, how about this instead:
// If there is no match (no data) and `occur.min === 0` then
// the container is entirely excluded.
2674850
to
d324ed4
Compare
/botio xfatest |
From: Bot.io (Linux m4)ReceivedCommand cmd_xfatest from @calixteman received. Current queue size: 0 Live output at: http://54.241.84.105:8877/04b5426ce943514/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_xfatest from @calixteman received. Current queue size: 0 Live output at: http://54.193.163.58:8877/8b50451de688d1d/output.txt |
src/core/xfa/bind.js
Outdated
// If there is no match (no data) and `occur.min === 0` then | ||
// the container is entirely excluded. | ||
// https://www.pdfa.org/norm-refs/XFA-3_3.pdf#G12.1428332 | ||
if (child.occur.min === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed that... but occur
could be null here.
We already get the min
info here:
Line 560 in 611627f
const [min, max] = this._getOccurInfo(child); |
so you should use this value instead.
From: Bot.io (Linux m4)FailedFull output at http://54.241.84.105:8877/04b5426ce943514/output.txt Total script time: 8.84 mins
Image differences available at: http://54.241.84.105:8877/04b5426ce943514/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/8b50451de688d1d/output.txt Total script time: 13.17 mins
Image differences available at: http://54.193.163.58:8877/8b50451de688d1d/reftest-analyzer.html#web=eq.log |
Subfrom nomin displays even though it's subform is set to <occur max=-1 min=0> If we look through specs of XFA 3.3 : https://www.pdfa.org/norm-refs/XFA-3_3.pdf - The min attribute is used when processing a form that contains data. Regardless of the data at least this number of instances is included. It is permissible to set this value to zero, in which case the container is entirely excluded if there is no data for it. However, in our case it doesn't happen, because we let our empty dataNode get through. Though by setting a clause: - eliminate unmatched data with occur min=0 we are checking our empty data and sending it to uselessNode array where at the end it gets removed;
d324ed4
to
56b5023
Compare
/botio xfatest |
From: Bot.io (Linux m4)ReceivedCommand cmd_xfatest from @calixteman received. Current queue size: 0 Live output at: http://54.241.84.105:8877/65b91f579bcac9e/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_xfatest from @calixteman received. Current queue size: 0 Live output at: http://54.193.163.58:8877/10cebcc8c8ec56b/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.241.84.105:8877/65b91f579bcac9e/output.txt Total script time: 9.61 mins
Image differences available at: http://54.241.84.105:8877/65b91f579bcac9e/reftest-analyzer.html#web=eq.log |
/botio-windows xfatest |
/botio-windows xfatest |
/botio-windows xfatest |
From: Bot.io (Windows)ReceivedCommand cmd_xfatest from @calixteman received. Current queue size: 0 Live output at: http://54.193.163.58:8877/611ed5e704d3543/output.txt |
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/611ed5e704d3543/output.txt Total script time: 16.38 mins
Image differences available at: http://54.193.163.58:8877/611ed5e704d3543/reftest-analyzer.html#web=eq.log |
/botio-linux preview |
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @calixteman received. Current queue size: 0 Live output at: http://54.241.84.105:8877/a6b0ab3f519f1a8/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/a6b0ab3f519f1a8/output.txt Total script time: 4.35 mins Published |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you for doing this.
/botio makeref |
From: Bot.io (Linux m4)ReceivedCommand cmd_makeref from @calixteman received. Current queue size: 0 Live output at: http://54.241.84.105:8877/8016f4a866ff359/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_makeref from @calixteman received. Current queue size: 1 Live output at: http://54.193.163.58:8877/c07828e3871ee59/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/8016f4a866ff359/output.txt Total script time: 21.03 mins
|
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/c07828e3871ee59/output.txt Total script time: 30.56 mins
|
/botio-windows makeref |
From: Bot.io (Windows)ReceivedCommand cmd_makeref from @calixteman received. Current queue size: 0 Live output at: http://54.193.163.58:8877/930af9bd00886d9/output.txt |
From: Bot.io (Windows)SuccessFull output at http://54.193.163.58:8877/930af9bd00886d9/output.txt Total script time: 39.03 mins
|
Because
Subform nomin displays, even though it's subform is set to
This pull request
Added condition to catch empty forms by check
And remove this empty forms via pushing it to a uselessNode array which later is removed.
Issue that this pull request solves
Closes: #14130