Project

Profile

Help

Can Saxon-JS process a HTML DOM document with a DOCTYPE node?

Added by Martin Honnen almost 2 years ago

I tried to fed a HTML document in the browser to Saxon-JS 2.3, it seems if the document has a DOCTYPE node (from e.g. <!DOCTYPE html>) then Saxon-JS (at least during an identity copy) bails out on the "node kind 10" with e.g.

code: "SXJS0003" message: "Unknown node kind 10"

What does that error message mean, does it come from the serializer of Saxon-JS? Or is the XSLT processing failing due to the DOCTYPE node in the tree? If so, shouldn't Saxon ignore it?


Replies (6)

Please register to reply

RE: Can Saxon-JS process a HTML DOM document with a DOCTYPE node? - Added by Martin Honnen almost 2 years ago

Sample is at https://martin-honnen.github.io/xslt/2022/replaceChildrenTest1.html, after using the button Chrome console shows

{
    "message": "Unknown node kind 10",
    "stack": "Error\n    at new J (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:3881:51)\n    at Object.p [as di] (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4197:468)\n    at SC (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4822:294)\n    at h.bf (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4826:415)\n    at https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4824:192\n    at rc.ba.forEachItem (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4008:389)\n    at h.Kb (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4824:159)\n    at https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4822:383\n    at Object.p [as di] (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4197:120)\n    at SC (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4822:294)\n    at h.bf (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4826:415)\n    at https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4824:192\n    at rc.ba.forEachItem (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4008:389)\n    at h.Kb (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4824:159)\n    at Object.h [as internalTransform] (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4841:33)\n    at transform (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4414:187)\n    at https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4471:434\n    at https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4484:445\n    at Object.T [as evaluate] (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4440:317)\n    at Object.evaluate (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4679:210)\n    at runXslt (https://martin-honnen.github.io/xslt/2022/replaceChildrenTest1.html:27:43)\n    at HTMLInputElement.onclick (https://martin-honnen.github.io/xslt/2022/replaceChildrenTest1.html:45:60)",
    "name": "XError",
    "code": "SXJS0003"
}

RE: Can Saxon-JS process a HTML DOM document with a DOCTYPE node? - Added by Michael Kay almost 2 years ago

Yes, if there's a DOCTYPE node present in the DOM then we should ignore it, and on some paths we do -- you've obviously found a path where we don't. Is this XML supplied as source to the parser, or programmatically constructed?

If we can reproduce it then it should be easy enough to resolve.

RE: Can Saxon-JS process a HTML DOM document with a DOCTYPE node? - Added by Martin Honnen almost 2 years ago

It is the browser's HTML DOM document of the main browser window, so it is the browser's HTML parser that created the HTML DOM document and I feed it to the Saxon-JS APIs.

RE: Can Saxon-JS process a HTML DOM document with a DOCTYPE node? - Added by Martin Honnen almost 2 years ago

The error is the same if the browser parses an XHTML document (loaded in a browser window) with its XML parser: https://martin-honnen.github.io/xslt/2022/replaceChildrenTest1.xhtml:

Uncaught J {message: 'Unknown node kind 10', stack: 'Error\n    at new J (https://martin-honnen.github.i…ub.io/xslt/2022/replaceChildrenTest1.xhtml:16:59)', name: 'XError', code: 'SXJS0003'}code: "SXJS0003"message: "Unknown node kind 10"name: "XError"stack: "Error\n    at new J (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:3881:51)\n    at Object.p [as di] (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4197:468)\n    at SC (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4822:294)\n    at h.bf (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4826:415)\n    at https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4824:192\n    at rc.ba.forEachItem (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4008:389)\n    at h.Kb (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4824:159)\n    at https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4822:383\n    at Object.p [as di] (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4197:120)\n    at SC (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4822:294)\n    at h.bf (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4826:415)\n    at https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4824:192\n    at rc.ba.forEachItem (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4008:389)\n    at h.Kb (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4824:159)\n    at Object.h [as internalTransform] (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4841:33)\n    at transform (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4414:187)\n    at https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4471:434\n    at https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4484:445\n    at Object.T [as evaluate] (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4440:317)\n    at Object.evaluate (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4679:210)\n    at runXslt (https://martin-honnen.github.io/xslt/2022/runXsltTest1.js:13:43)\n    at HTMLInputElement.onclick (https://martin-honnen.github.io/xslt/2022/replaceChildrenTest1.xhtml:16:59)"[[Prototype]]: Error
transform @ SaxonJS2.js:4414
(anonymous) @ SaxonJS2.js:4471
(anonymous) @ SaxonJS2.js:4484
T @ SaxonJS2.js:4440
evaluate @ SaxonJS2.js:4679
runXslt @ runXsltTest1.js:13
onclick @ replaceChildrenTest1.xhtml:16

RE: Can Saxon-JS process a HTML DOM document with a DOCTYPE node? - Added by Martin Honnen almost 2 years ago

Another test using SaxonJS.transform({ sourceLocation : 'someXMLWithDoctype.xml', ...}) also fails: https://martin-honnen.github.io/xslt/2022/doctypeParsingTest1.html:

Transformation failure: Error SXJS0003 at identity1.xsl#11  SaxonJS2.js:4866
    Unknown node kind 10
Uncaught (in promise) Jcode: "SXJS0003"message: "Unknown node kind 10"name: "XError"stack: "Error\n    at new J (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:3881:51)\n    at Object.p [as di] (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4197:468)\n    at SC (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4822:294)\n    at h.bf (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4826:415)\n    at https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4824:192\n    at rc.ba.forEachItem (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4008:389)\n    at h.Kb (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4824:159)\n    at https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4822:383\n    at Object.p [as di] (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4197:120)\n    at SC (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4822:294)\n    at h.bf (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4826:415)\n    at h.Jj (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4824:456)\n    at https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4221:263\n    at https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4193:528\n    at Array.forEach (<anonymous>)\n    at https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4193:501\n    at Object.push (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4223:358)\n    at h.bf (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4826:330)\n    at https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4824:192\n    at rc.ba.forEachItem (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4008:389)\n    at h.Kb (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4824:159)\n    at h (https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4841:33)\n    at https://martin-honnen.github.io/Saxon-JS-2.3/SaxonJS2.js:4866:410"xsltLineNr: "11"xsltModule: "identity1.xsl"[[Prototype]]: ErrorXe: falsecode: nullconstructor: ƒ J(a,b,h)errorObject: nullgetMessage: ƒ ()getStackTrace: ƒ ()toString: ƒ ()xsltLineNr: nullxsltModule: null[[Prototype]]: Object
    (1-6/6)

    Please register to reply