mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-29 07:37:57 +02:00
XFA - Created data node mustn't belong to datasets namespace
- when some named nodes in the template don't have their counterpart in datasets we create some nodes: the main node mustn't belong to the datasets namespace because it doesn't make sense and Acrobat Reader isn't able to read pdf with such nodes. - so created nodes under a datasets node have a namespaceId set to -1 and consequently when serialized no namespace prefix will appear.
This commit is contained in:
parent
804abb3786
commit
57ae3a5a76
4 changed files with 82 additions and 8 deletions
|
@ -45,6 +45,8 @@ import { createDataNode, searchNode } from "./som.js";
|
|||
import { NamespaceIds } from "./namespaces.js";
|
||||
import { warn } from "../../shared/util.js";
|
||||
|
||||
const NS_DATASETS = NamespaceIds.datasets.id;
|
||||
|
||||
function createText(content) {
|
||||
const node = new Text({});
|
||||
node[$content] = content;
|
||||
|
@ -501,8 +503,12 @@ class Binder {
|
|||
if (dataChildren.length > 0) {
|
||||
this._bindOccurrences(child, [dataChildren[0]], null);
|
||||
} else if (this.emptyMerge) {
|
||||
const nsId =
|
||||
dataNode[$namespaceId] === NS_DATASETS
|
||||
? -1
|
||||
: dataNode[$namespaceId];
|
||||
const dataChild = (child[$data] = new XmlObject(
|
||||
dataNode[$namespaceId],
|
||||
nsId,
|
||||
child.name || "root"
|
||||
));
|
||||
dataNode[$appendChild](dataChild);
|
||||
|
@ -625,10 +631,11 @@ class Binder {
|
|||
if (!match) {
|
||||
// We're in matchTemplate mode so create a node in data to reflect
|
||||
// what we've in template.
|
||||
match = child[$data] = new XmlObject(
|
||||
dataNode[$namespaceId],
|
||||
child.name
|
||||
);
|
||||
const nsId =
|
||||
dataNode[$namespaceId] === NS_DATASETS
|
||||
? -1
|
||||
: dataNode[$namespaceId];
|
||||
match = child[$data] = new XmlObject(nsId, child.name);
|
||||
if (this.emptyMerge) {
|
||||
match[$consumed] = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue