#pattern
* Parsing HTML documents
#ja
$1 HTML 文書の構文解析
#en
This section only applies to user agents, data mining tools, and
conformance checkers.
#ja
この節は利用者エージェント、データ・マイニング・ツール、
適合性検査器のみに適用されます。
#en
The rules for parsing XML documents (and
thus XHTML documents) into DOM trees are covered by
the XML and Namespaces in XML specifications, and are out of scope of this
specification. [XML] [XMLNS]
#ja
XML 文書 (や XHTML 文書)
を構文解析して DOM 木を得るための規則は XML や XML 名前空間の仕様書で扱われており、
この仕様書の適用範囲外です。 [XML] HTML documents, user agents must use the
parsing rules described in this section to generate the DOM trees.
Together, these rules define what is referred to as the HTML parser.
#ja
HTML 文書については、利用者エージェントは、 DOM
木を生成するためにこの節で説明する構文解析規則を使用しなければ[[MUST:なりません]]。
また、この規則はHTML 構文解析器と呼ばれるものを定義します。
#en
While the HTML form of HTML5 bears a close resemblance to SGML and XML,
it is a separate language with its own parsing rules.
#ja
HTML5 の HTML 形式は SGML や XML によく似ていますが、
独自の構文解析規則を持つ別の言語です。
#en
Some earlier versions of HTML (in particular from HTML2 to HTML4) were
based on SGML and used SGML parsing rules. However, few (if any) web
browsers ever implemented true SGML parsing for HTML documents; the only
user agents to strictly handle HTML as an SGML application have
historically been validators. The resulting confusion — with
validators claiming documents to have one representation while widely
deployed Web browsers interoperably implemented a different
representation — has wasted decades of productivity. This version
of HTML thus returns to a non-SGML basis.
#ja
以前のいくつかの版の HTML (特に HTML2 から HTML4 まで) は SGML
に基づき、 SGML の構文解析規則を用いていました。しかし、 HTML
文書用に真の SGML 構文解析を実装していたウェブ・ブラウザは (あったとしても)
皆無に近い数でした。 HTML を厳密に SGML 応用として扱う唯一の利用者エージェントは歴史的に妥当性検証器だけでした。
その結果、妥当性検査器は文書がある形式であることを要求し、
一方で広く実用されている Web ブラウザはそれとは異なる形式を相互運用可能な形で実装するという混乱が生じ、
生産性を大きく低下させています。
ですので、この版の HTML は非 SGML ベースに回帰します。
#en
Authors interested in using SGML tools in their authoring pipeline are
encouraged to use XML tools and the XML serialization of HTML5.
#ja
文書準備の過程で SGML ツールを使いたいと考える著者には、
XML ツールと HTML5 の XML 直列化を用いることをお勧めします。
#en
This specification defines the parsing rules for HTML documents, whether
they are syntactically correct or not. Certain points in the parsing
algorithm are said to be parse
errors. The error handling for parse errors is well-defined: user
agents must either act as described below when encountering such problems,
or must abort processing at the first error that they encounter for which
they do not wish to apply the rules described below.
#ja
この仕様書は、構文的に正しいか否かに関わらず HTML
文書を構文解析する規則を定義します。構文解析算法中のいくつかの箇所は構文解析誤りであるとしています。
構文解析誤りの処理は明確に定義します。利用者エージェントは、
そのような問題に遭遇したときに後述のように動作するか、または後述の規則を適用することを望まないような誤りにはじめて遭遇した箇所で処理を停止しなければ[[MUST:なりません]]。
#en
Conformance checkers must report at least one parse error condition to
the user if one or more parse error conditions exist in the document and
must not report parse error conditions if none exist in the document.
Conformance checkers may report more than one parse error condition if
more than one parse error conditions exist in the document. Conformance
checkers are not required to recover from parse errors.
#ja
適合性検査器は、文書中に1つ以上の構文解析誤り条件が存在する場合、利用者に最低1つの構文解析誤り条件を報告しなければ[[MUST:ならず]]、
文書に誤りが存在しない場合、構文解析誤り条件を報告しては[[MUST NOT:なりません]]。
適合性検査器は、文書中に複数の構文解析誤り条件が存在する場合、
複数の構文解析誤り条件を報告して[[MAY:構いません]]。
適合性検査器は構文解析誤りから回復することを[[REQUIRED:要求]]されません。
#en
Parse errors are only errors with the syntax of
HTML. In addition to checking for parse errors, conformance checkers will
also verify that the document obeys all the other conformance requirements
described in this specification.
#ja
構文解析誤りは、 HTML の構文の誤りに過ぎません。
適合性検査器は、構文解析誤りの検査に加え、
文書がこの仕様書で説明されている他の適合性要件に従っているかも検査することになります。
#pattern
* The scripting state
#ja
$1 スクリプティング状態
#en
The scripting flag is set to "enabled" if the
Document with which the parser is associated was with script when the parser was created, and
"disabled" otherwise.
#ja
スクリプティング旗は、構文解析器が関連付けられている
Document が構文解析器の作成の時点でスクリプト付きである場合には「有効」、
それ以外の場合には「無効」です。
#pattern
* Tokenization
#ja
$1 字句化
#en
Implementations must act as if they used the following state machine to
tokenise HTML. The state machine must start in the data state. Most states consume a single character,
which may have various side-effects, and either switches the state machine
to a new state to reconsume the same character, or switches it to
a new state (to consume the next character), or repeats the same state (to
consume the next character). Some states have more complicated behavior
and can consume several characters before switching to another state.
#ja
実装は、次の状態機械を HTML の字句化に用いているかのように作用しなければ[[MUST:なりません]]。
状態機械は、データ状態で開始しなければ[[MUST:なりません]]。
ほとんどの状態は1文字消費しますが、
この時様々な副作用を持っても[[MAY:構わない]]他、
状態機械が新しい状態に切り替えられて同じ文字を再消費するか、
(次の文字を消費するために) 新しい状態に切り替えられるか、
(次の文字を消費するために) 同じ状態を繰り返すかのいずれかとなります。
より複雑な動作を持っていて、他の状態に切り替える前に複数の文字を消費することがある状態もあります。
#en
The exact behavior of certain states depends on a content model flag that is set after certain tokens are
emitted. The flag has several states: PCDATA, RCDATA, CDATA, and PLAINTEXT. Initially it must be in the PCDATA state. In the
RCDATA and CDATA states, a further escape flag is
used to control the behavior of the tokeniser. It is either true or false,
and initially must be set to the false state. The insertion
mode and the stack of open elements also
affects tokenization.
#ja
特定の状態の正確な動作は、特定の字句が放出された後に設定される内容モデル旗に依存します。
この旗は状態 PCDATA, RCDATA, CDATA, PLAINTEXT を持ちます。はじめは PCDATA
状態でなければ[[MUST:なりません]]。 RCDATA 状態と CDATA 状態では、
更に逃避旗が字句化器の動作を制御するために用いられます。
これは真か偽かのいずれかであり、はじめは偽の状態に設定されなければ[[MUST:なりません]]。
挿入モードと開いているようそのスタックも字句化器に影響します。
#en
The output of the tokenization step is a series of zero or more of the
following tokens: DOCTYPE, start tag, end tag, comment, character,
end-of-file. DOCTYPE tokens have a name, a public identifier, a system
identifier, and a force-quirks flag. When a DOCTYPE token is
created, its name, public identifier, and system identifier must be marked
as missing (which is a distinct state from the empty string), and the
force-quirks flag must be set to off (its other state is
on). Start and end tag tokens have a tag name, a self-closing
flag, and a list of attributes, each of which has a name and a value.
When a start or end tag token is created, its self-closing flag
must be unset (its other state is that it be set), and its attributes list
must be empty. Comment and character tokens have data.
#ja
字句化期の出力は、 DOCTYPE、開始タグ、終了タグ、注釈、文字、ファイル末のいずれかの字句の零個以上の系列です。
DOCTYPE 字句は名前、公開識別子、システム識別子、奇癖強制旗を持ちます。
When a DOCTYPE token is
created, its name, public identifier, and system identifier must be marked
as missing (which is a distinct state from the empty string), and the
force-quirks flag must be set to off (its other state is
on). Start and end tag tokens have a tag name, a self-closing
flag, and a list of attributes, each of which has a name and a value.
When a start or end tag token is created, its self-closing flag
must be unset (its other state is that it be set), and its attributes list
must be empty. Comment and character tokens have data.
#pattern
* Parse state
#ja
$1 構文解析状態
#pattern
* The insertion mode
#ja
$1 挿入モード
#en
Initially the insertion mode is "initial". It can change to "before html", "before head", "in head", "in head
noscript", "after
head", "in
body", "in
table", "in
caption", "in column group", "in table body", "in row", "in cell", "in select", "in select in table", "in foreign content", "after body", "in frameset",
"after
frameset", "after after body", and "after after frameset" during the course of the
parsing, as described in the tree
construction stage. The insertion mode affects how tokens are
processed and whether CDATA blocks are supported.
#ja
はじめ、挿入モードは "initial" です。挿入モードは、
構文解析の過程で、木構築期で説明するように、
"before html", "before head", "in head", "in head
noscript", "after
head", "in
body", "in
table", "in
caption", "in column group", "in table body", "in row", "in cell", "in select", "in select in table", "in foreign content", "after body", "