Skip to content

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

Merged
merged 1 commit into from
Nov 5, 2021

Conversation

janekotovich
Copy link
Contributor

@janekotovich janekotovich commented Nov 2, 2021

Because

Subform nomin displays, even though it's subform is set to

This pull request

Added condition to catch empty forms by check

if subform.name === "nomin" && subform.occur.min === 0

And remove this empty forms via pushing it to a uselessNode array which later is removed.

Issue that this pull request solves

Closes: #14130

@janekotovich
Copy link
Contributor Author

janekotovich commented Nov 2, 2021

I didn't add a test to manifest.json because pdf in issue is not a link but attached file.
I ran locally test by adding occurmin0.pdf to pdfs,
on master branch:

  • gulp makeref

on subform_min_0 branch:

  • gulp browsertest
  • gulp unitest
  • gulp lint

All went well but please lemme know if you would prefer me adding test to manifest.json and to test/pdfs.
Thanks!

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Nov 2, 2021

I didn't add a test to manifest.json because pdf in issue is not a link but attached file.

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:

  • Normally you'd treat this just as a linked test-case, getting the URL by right-clicking on the attached file and using the "Copy Link" alternative in the context menu.
  • If the attached PDF document is small/simple, without any personally identifiable information and without anything that looks like copyrighted content, you can actually include the file directly in the PDF.js repository.

In this particular case, it looks like option two is actually feasible!
To add a standard, non-linked, test-case you can e.g. follow this procedure:

  • Download the file, naming it issue14130.pdf in this case, and place it in the test/pdfs/ folder locally.
  • From the root of your local PDF.js repository, run node test/add_test.js test/pdfs/issue14130.pdf which will take care of adding an entry to the test/pdfs/.gitignore file and also update the test/test_manifest.json file.
  • In this case, since you want an XFA-test, you then need to manually add a "enableXfa": true-line to the new entry in the test/test_manifest.json file.
  • Finally, you just git add the files mentioned above (i.e. test/pdfs/.gitignore, test/pdfs/issue14130.pdf, and test/test_manifest.json) and amend your existing commit.

@janekotovich
Copy link
Contributor Author

@Snuffleupagus yep no problem at all, will do in a bit 😊
Thanks, I already knew how to add it, just wasn't sure regarding file attaching / link, so decided to ask here. Will update commit and push alltogether!

@janekotovich
Copy link
Contributor Author

@Snuffleupagus oh sorry, I just noticed you've mentioned amend, but I rebased (as my previous ones). Hope its okay!

@Snuffleupagus
Copy link
Collaborator

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 :-)

@Snuffleupagus
Copy link
Collaborator

/botio xfatest

@pdfjsbot
Copy link

pdfjsbot commented Nov 2, 2021

From: Bot.io (Linux m4)


Received

Command cmd_xfatest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.241.84.105:8877/9ad95d886205346/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Nov 2, 2021

From: Bot.io (Windows)


Received

Command cmd_xfatest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.193.163.58:8877/86b55d56b4da552/output.txt

@@ -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) {
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a look on:

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 a return somewhere.

@pdfjsbot
Copy link

pdfjsbot commented Nov 2, 2021

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/9ad95d886205346/output.txt

Total script time: 9.41 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 2

Image differences available at: http://54.241.84.105:8877/9ad95d886205346/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

pdfjsbot commented Nov 2, 2021

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/86b55d56b4da552/output.txt

Total script time: 14.62 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: FAILED
  • Regression tests: FAILED
  errors: 61

Image differences available at: http://54.193.163.58:8877/86b55d56b4da552/reftest-analyzer.html#web=eq.log

@@ -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);
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏽

@@ -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
Copy link
Collaborator

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?

Copy link
Contributor

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

Comment on lines 638 to 639
// If there is no match (no data) and occur.min === 0
// container is entirely excluded.
Copy link
Collaborator

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.

@calixteman
Copy link
Contributor

/botio xfatest

@pdfjsbot
Copy link

pdfjsbot commented Nov 4, 2021

From: Bot.io (Linux m4)


Received

Command cmd_xfatest from @calixteman received. Current queue size: 0

Live output at: http://54.241.84.105:8877/04b5426ce943514/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Nov 4, 2021

From: Bot.io (Windows)


Received

Command cmd_xfatest from @calixteman received. Current queue size: 0

Live output at: http://54.193.163.58:8877/8b50451de688d1d/output.txt

// 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) {
Copy link
Contributor

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:

const [min, max] = this._getOccurInfo(child);

so you should use this value instead.

@pdfjsbot
Copy link

pdfjsbot commented Nov 4, 2021

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/04b5426ce943514/output.txt

Total script time: 8.84 mins

  • Font tests: Passed
  • Unit tests: FAILED
  • Integration Tests: Passed
  • Regression tests: FAILED
  errors: 40

Image differences available at: http://54.241.84.105:8877/04b5426ce943514/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

pdfjsbot commented Nov 4, 2021

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/8b50451de688d1d/output.txt

Total script time: 13.17 mins

  • Font tests: Passed
  • Unit tests: FAILED
  • Integration Tests: Passed
  • Regression tests: FAILED
  errors: 81

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;
@calixteman
Copy link
Contributor

/botio xfatest

@pdfjsbot
Copy link

pdfjsbot commented Nov 4, 2021

From: Bot.io (Linux m4)


Received

Command cmd_xfatest from @calixteman received. Current queue size: 0

Live output at: http://54.241.84.105:8877/65b91f579bcac9e/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Nov 4, 2021

From: Bot.io (Windows)


Received

Command cmd_xfatest from @calixteman received. Current queue size: 0

Live output at: http://54.193.163.58:8877/10cebcc8c8ec56b/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Nov 4, 2021

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/65b91f579bcac9e/output.txt

Total script time: 9.61 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 1

Image differences available at: http://54.241.84.105:8877/65b91f579bcac9e/reftest-analyzer.html#web=eq.log

@calixteman
Copy link
Contributor

/botio-windows xfatest

@mozilla mozilla deleted a comment from pdfjsbot Nov 5, 2021
@mozilla mozilla deleted a comment from pdfjsbot Nov 5, 2021
@mozilla mozilla deleted a comment from pdfjsbot Nov 5, 2021
@calixteman
Copy link
Contributor

/botio-windows xfatest

@mozilla mozilla deleted a comment from pdfjsbot Nov 5, 2021
@mozilla mozilla deleted a comment from pdfjsbot Nov 5, 2021
@calixteman
Copy link
Contributor

/botio-windows xfatest

@pdfjsbot
Copy link

pdfjsbot commented Nov 5, 2021

From: Bot.io (Windows)


Received

Command cmd_xfatest from @calixteman received. Current queue size: 0

Live output at: http://54.193.163.58:8877/611ed5e704d3543/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Nov 5, 2021

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/611ed5e704d3543/output.txt

Total script time: 16.38 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: FAILED
  • Regression tests: FAILED
  different ref/snapshot: 2

Image differences available at: http://54.193.163.58:8877/611ed5e704d3543/reftest-analyzer.html#web=eq.log

@calixteman
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Nov 5, 2021

From: Bot.io (Linux m4)


Received

Command cmd_preview from @calixteman received. Current queue size: 0

Live output at: http://54.241.84.105:8877/a6b0ab3f519f1a8/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Nov 5, 2021

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/a6b0ab3f519f1a8/output.txt

Total script time: 4.35 mins

Published

Copy link
Contributor

@calixteman calixteman left a 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.

@calixteman calixteman merged commit e136afb into mozilla:master Nov 5, 2021
@calixteman
Copy link
Contributor

/botio makeref

@pdfjsbot
Copy link

pdfjsbot commented Nov 5, 2021

From: Bot.io (Linux m4)


Received

Command cmd_makeref from @calixteman received. Current queue size: 0

Live output at: http://54.241.84.105:8877/8016f4a866ff359/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Nov 5, 2021

From: Bot.io (Windows)


Received

Command cmd_makeref from @calixteman received. Current queue size: 1

Live output at: http://54.193.163.58:8877/c07828e3871ee59/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Nov 5, 2021

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/8016f4a866ff359/output.txt

Total script time: 21.03 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

@pdfjsbot
Copy link

pdfjsbot commented Nov 5, 2021

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/c07828e3871ee59/output.txt

Total script time: 30.56 mins

  • Lint: Passed
  • Make references: FAILED

@calixteman
Copy link
Contributor

/botio-windows makeref

@pdfjsbot
Copy link

pdfjsbot commented Nov 5, 2021

From: Bot.io (Windows)


Received

Command cmd_makeref from @calixteman received. Current queue size: 0

Live output at: http://54.193.163.58:8877/930af9bd00886d9/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Nov 5, 2021

From: Bot.io (Windows)


Success

Full output at http://54.193.163.58:8877/930af9bd00886d9/output.txt

Total script time: 39.03 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

XFA subform with occur min=0 and no bound data displaying
4 participants