mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-28 23:28:16 +02:00
XFA - Remove namespace from nodes under xfa:data node
- in real life some xfa contains xml like <xfa:data><xfa:Foo><xfa:Bar>...</xfa:data> since there are no Foo or Bar in the xfa namespace the JS representation are empty and that leads to errors. - so the idea is to make all nodes under xfa:data namespace agnostic which means that ns are removed from nodes in the parser but only xfa:data descendants.
This commit is contained in:
parent
6c9b6bc599
commit
5555114bb3
6 changed files with 43 additions and 5 deletions
|
@ -118,12 +118,12 @@ class XFAParser extends XMLParserBase {
|
|||
return [namespace, prefixes, attributeObj];
|
||||
}
|
||||
|
||||
_getNameAndPrefix(name) {
|
||||
_getNameAndPrefix(name, nsAgnostic) {
|
||||
const i = name.indexOf(":");
|
||||
if (i === -1) {
|
||||
return [name, null];
|
||||
}
|
||||
return [name.substring(i + 1), name.substring(0, i)];
|
||||
return [name.substring(i + 1), nsAgnostic ? "" : name.substring(0, i)];
|
||||
}
|
||||
|
||||
onBeginElement(tagName, attributes, isEmpty) {
|
||||
|
@ -131,7 +131,10 @@ class XFAParser extends XMLParserBase {
|
|||
attributes,
|
||||
tagName
|
||||
);
|
||||
const [name, nsPrefix] = this._getNameAndPrefix(tagName);
|
||||
const [name, nsPrefix] = this._getNameAndPrefix(
|
||||
tagName,
|
||||
this._builder.isNsAgnostic()
|
||||
);
|
||||
const node = this._builder.build({
|
||||
nsPrefix,
|
||||
name,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue