XML宣言 (XMLDecl) は処理命令 (PI) ではない

XML宣言が PROCESSING_INSTRUCTION_NODE だと思っていて、以下のXHTML文書を書いていました。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja">
<head>
  <!--
    /**
     * サーバは次のHTTPヘッダを出力しています。
     * Content-Type: application/xhtml+xml; charset=UTF-8
     */
  -->
  <title>XHTML5</title>
</head>
<body>
  <script type="application/javascript"><![CDATA[
  console.log(document.firstChild.nodeType === Node.DOCUMENT_TYPE_NODE);                                                                    // true
  console.log(document.evaluate('child::processing-instruction()', document, null, 7, null).snapshotLength);                                // 0
  console.log(document.createProcessingInstruction('xml', 'version="1.0" encoding="UTF-8"').nodeType === Node.PROCESSING_INSTRUCTION_NODE); // true
  ]]></script>
</body>
</html>

しかし、XML宣言は PROCESSING_INSTRUCTION_NODE ではないので document からノードとして認識されません。
XML宣言の情報は Interface Document (DOM L3 Core) のプロパティとして定義されています。

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja">
<head>
  <title>XHTML5</title>
</head>
<body>
  <script type="application/javascript"><![CDATA[
  console.log(document.xmlVersion);    // "1.0"
  console.log(document.xmlEncoding);   // "UTF-8"
  console.log(document.xmlStandalone); // true
  ]]></script>
</body>
</html>


think49
いい方法が見つからないなあ。/ JavaScriptでのXML解析について質問です。 JavaScriptXMLファイルを読み込んで... - Yahoo!知恵袋
think49
XPath で PROCESSING_INSTRUCTION_NODE を得られると思ったら snapshotLength が 0 になってしまった。XPath式が間違ってるのかな。
think49
document.firstChild が PROCESSING_INSTRUCTION_NODE ではなく、DOCUMENT_TYPE_NODE になる。
think49
document.createProcessingInstruction('xml', 'version="1.0" encoding="UTF-8"'); は使えるので、PROCESSING_INSTRUCTION_NODE を認識しないわけではなさそう。
think49
@ ありがとうございます。2.6 Processing Instructions も合わせて読んで理解できました。
think49
" 'XML'や'xml'などの対象名は、この仕様書のこのバージョン及び将来のバージョンにおける標準化の為に予約されている。処理命令対象の正式な宣言の為に、XML記法機構が使われる事もある。"
think49
XMLDecl の <?xml version="1.0"?> と PI の <?xml version="1.0"?> は別物。
ただし、PITarget の "XML", "xml" は予約されており、将来のバージョンで使われる可能性がある。
think49
PITarget に "xml" は「使うべきではない」(SHOULD NOT) または「使ってはならない」(MUST NOT) と読んだ方がいいのだろう…。