Bug 87888 - XPath expression `//node()` shouldn’t match the DOCTYPE node
Summary: XPath expression `//node()` shouldn’t match the DOCTYPE node
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL: https://bug-87888-attachments.webkit....
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-30 13:08 PDT by Mathias Bynens
Modified: 2022-07-28 13:21 PDT (History)
7 users (show)

See Also:


Attachments
test case (199 bytes, text/html)
2012-05-30 14:56 PDT, Alexey Proskuryakov
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mathias Bynens 2012-05-30 13:08:55 PDT
Test case:

data:text/html,<!DOCTYPE%20html><script>document.write(document.evaluate('%2F%2Fnode()'%2C%20document%2C%20null%2C%20XPathResult.FIRST_ORDERED_NODE_TYPE%2C%20null).singleNodeValue%20%3D%3D%20document.documentElement%20%3F%20'PASS'%20%3A%20'FAIL')<%2Fscript>
Comment 1 Alexey Proskuryakov 2012-05-30 14:56:57 PDT
Created attachment 144929 [details]
test case

Same test as attachment, because long URL breaks layout.
Comment 2 Alexey Proskuryakov 2012-05-30 14:59:35 PDT
Could you please explain why this is wrong? I'm not disagreeing with you, it's just not obvious.
Comment 3 Mathias Bynens 2012-05-30 21:48:51 PDT
(In reply to comment #2)
> Could you please explain why this is wrong? I'm not disagreeing with you, it's just not obvious.

The DOCTYPE declaration is not acknowledged in the XPath/XSLT data model. 

“support for DTDs in the data model” is listed in Appendix G of the XSLT 1.0 Recommendation as a feature under consideration for future versions.

http://www.w3.org/TR/xslt#section-Features-under-Consideration-for-Future-Versions-of-XSLT
Comment 4 Alexey Proskuryakov 2012-05-30 23:09:42 PDT
The XSLT spec doesn't govern XPathEvaluator behavior. The best we have is <http://www.w3.org/TR/DOM-Level-3-XPath/xpath.html>.
Comment 5 Mathias Bynens 2012-05-30 23:57:44 PDT
http://www.w3.org/TR/DOM-Level-3-XPath/xpath.html#Mapping only lists these:

> 1.2.1 Element Nodes
> 1.2.2 Attribute Nodes
> 1.2.3 Namespace Nodes
> 1.2.4 Text Nodes
> 1.2.5 Entity Reference Nodes
> 1.2.6 Comment Nodes
> 1.2.7 Processing Instruction Nodes
> 1.2.8 Document order

Document Type Nodes are not included.
Comment 6 Mathias Bynens 2012-05-31 06:50:02 PDT
This is probably a misinterpretation of http://www.w3.org/TR/xpath/#NT-NodeType, which says:

> A node test `node()` is true for any node of any type whatsoever.

This should have said:

> A node test `node()` is true for any node of any XPath-defined node type whatsoever.

This is clear when you look at the production below, which only mentions the specified node types:

> [7]   	NodeTest	   ::=   	NameTest	
> | NodeType '(' ')'	
> | 'processing-instruction' '(' Literal ')'	

Where `NodeTest` is defined as:

> [38]   	NodeType	   ::=   	'comment'	
> | 'text'	
> | 'processing-instruction'	
> | 'node'

Document type nodes are neither of those four options.
Comment 7 Lucas Forschler 2019-02-06 09:04:20 PST
Mass moving XML DOM bugs to the "DOM" Component.
Comment 8 Ahmad Saleem 2022-07-28 12:13:54 PDT
All browsers (Chrome Canary 106, Firefox Nightly 105 and Safari 15.6 on macOS 12.5) show "FAIL" in this test case, is it web-spec issue or all browsers haven't implemented something which is needed for this test?
Comment 9 Ryosuke Niwa 2022-07-28 13:21:13 PDT
All browsers agree -> Config Changed. Nothing to be done here.