Spec2.8Chap10a

「Spec2.8Chap10a」の編集履歴(バックアップ)一覧はこちら

Spec2.8Chap10a - (2011/02/03 (木) 15:29:52) の最新版との変更点

追加された行は緑色になります。

削除された行は赤色になります。

* 第 10 章 XML 式とパターン (XML Expressions and Patterns) By Burak Emir #co(){----------------------------------------------------- bgn-hide0} This chapter describes the syntactic structure of XML expressions and patterns . It follows as closely as possible the XML 1.0 specification [W3C], changes being mandated by the possibility of embedding Scala code fragments . #co(){--------------------------------------------------- end-hide0} この章では XML 式とパターンの文法構造を記述します。 可能な限りしっかりと XML 1.0 仕様書[W3C]および、今後の Scala コードの 埋め込みで要求される変更に従います。 &br() &br() &aname(10.1,option=nolink){ } ** 10.1 XML 式 (XML Expressions) #co(){----------------------------------------------------- bgn-hide0} XML expressions are expressions generated by the following production, where the opening bracket '<' of the first element must be in a position to start the lexical XML mode (§1.5) . #co(){--------------------------------------------------- end-hide0} XML 式は次の文法規則によって生成される式です。ここで最初の要素の 始め山括弧 '<' は、字句上の XML モード(§1.5)を開始できる位置に なければなりません。 &bold(){構文:} #co(){----------------------------------------------------- bgn-code} XmlExpr ::= XmlContent {Element} #co(){--------------------------------------------------- end-code} #co(){----------------------------------------------------- bgn-hide0} Well-formedness constraints of the XML specification apply, which means for instance that start tags and end tags must match, and attributes may only be defined once, with the exception of constraints related to entity resolution . #co(){--------------------------------------------------- end-hide0} XML 仕様書の整形式制約が適用されます。その意味は例えば、開始タグと終了タグは マッチしなければならず、属性は一度だけ定義できる、ただしエンティティ解決と 関係する制約の例外がある、ということです。 #co(){----------------------------------------------------- bgn-hide0} The following productions describe Scala's extensible markup language, designed as close as possible to the W3C extensible markup language standard . Only the productions for attribute values and character data are changed . Scala does not support declarations, CDATA sections or processing instructions . Entity references are not resolved at runtime . #co(){--------------------------------------------------- end-hide0} 次の文法規則は Scala の XML を記述しており、W3C XML 標準規格に可能な限り近く 設計されています。 属性値と文字データの文法規則だけは変えられています。 Scala は、宣言、CDATA セクションあるいは処理命令をサポートしていません。 エンティティ参照は、実行時には解決されません。 &bold(){構文:} #co(){----------------------------------------------------- bgn-code} Element ::= EmptyElemTag | STag Content ETag EmptyElemTag ::= '<' Name {S Attribute} [S] '/>' STag ::= '<' Name {S Attribute} [S] '>' ETag ::= '</' Name [S] '>' Content ::= [CharData] {Content1 [CharData]} Content1 ::= XmlContent | Reference | ScalaExpr XmlContent ::= Element | CDSect | PI | Comment #co(){--------------------------------------------------- end-code} #co(){----------------------------------------------------- bgn-hide0} If an XML expression is a single element, its value is a runtime representation of an XML node (an instance of a subclass of scala.xml.Node). If the XML expression consists of more than one element, then its value is a runtime representation of a sequence of XML nodes (an instance of a subclass of scala.Seq[scala.xml.Node]) . #co(){--------------------------------------------------- end-hide0} #co(){----------------------------------------------------- bgn-hide0} If an XML expression is an entity reference, CDATA section, processing instructions or a comments, it is represented by an instance of the corresponding Scala runtime class . #co(){--------------------------------------------------- end-hide0} もし XML 式がただ 1 つの要素なら、その値は XML node (scala.xml.Node のサブクラスのインスタンス)の実行時表現です。 もし XML 式が 1 つより多くの要素から成るなら、その値は XML ノード (scala.Seq[scala.xml.Node] のサブクラスのインスタンス)のシーケンスの 実行時表現です。 もし XML 式がエンティティ参照、CDATA セクション、処理命令あるいはコメントなら、 それは、対応する Scala 実行時クラスのインスタンスによって表現されます。 #co(){----------------------------------------------------- bgn-hide0} By default, beginning and trailing whitespace in element content is removed, and consecutive occurrences of whitespace are replaced by a single space character \u0020. This behavior can be changed to preserve all whitespace with a compiler option . #co(){--------------------------------------------------- end-hide0} デフォルトでは、要素コンテンツ中の始まりとお終いの空白文字は削除され、 連続する空白文字はただ 1 つのスペース文字 \u0020 で置き換えられます。 この振る舞いはコンパイラ・オプションで、すべての空白文字を維持するように 変えることができます。 &bold(){構文:} #co(){----------------------------------------------------- bgn-code} Attribute ::= Name Eq AttValue AttValue ::= '"' {CharQ | CharRef} '"' | ''' {CharA | CharRef} ''' | ScalaExpr ScalaExpr ::= Block CharData ::= { CharNoRef } without {CharNoRef}'{'CharB {CharNoRef} and without {CharNoRef}']]>'{CharNoRef} #co(){--------------------------------------------------- end-code} #co(){----------------------------------------------------- bgn-hide0} XML expressions may contain Scala expressions as attribute values or within nodes . In the latter case, these are embedded using a single opening brace '{' and ended by a closing brace '}'. To express a single opening braces within XML text as generated by CharData, it must be doubled . Thus, '{{' represents the XML text '{' and does not introduce an embedded Scala expression . #co(){--------------------------------------------------- end-hide0} XML 式は、Scala 式を属性値としてあるいは node内に持つことができます。 後者の場合、それらは 1 つの左波括弧 '{' を使って埋め込まれ、 右波括弧 '}' で終わります。 CharData で生成された時の XML テキスト中で 1 つの左波括弧を表すには、 それを 2 重にします。 ですから、'{{' は XML テキスト '{' を表し、埋め込まれた Scala 式を 導入しません。 &bold(){構文:} #co(){----------------------------------------------------- bgn-code} BaseChar, Char, Comment, CombiningChar, Ideographic, NameChar, S, Reference ::= "W3C XML と同様" Char1 ::= Char without '<' | '&' CharQ ::= Char1 without '"' CharA ::= Char1 without ''' CharB ::= Char1 without '{' Name ::= XNameStart {NameChar} XNameStart ::= '_' | BaseChar | Ideographic ( W3C XMLと同じだが ':'なし #co(){--------------------------------------------------- end-code} &br() &br() &aname(10.2,option=nolink){ } ** 10.2 XML パターン (XML Patterns) #co(){----------------------------------------------------- bgn-hide0} XML patterns are patterns generated by the following production, where the opening bracket '<' of the element patterns must be in a position to start the lexical XML mode (§1.5) . #co(){--------------------------------------------------- end-hide0} XML パターンは次の文法規則によって生成されるパターンです。 ここで要素パターンの始め山括弧 '<' は、字句上の XML モード(§1.5)を 開始できる位置になければなりません。 &bold(){構文:} #co(){----------------------------------------------------- bgn-code} XmlPattern ::= ElementPattern #co(){--------------------------------------------------- end-code} #co(){----------------------------------------------------- bgn-hide0} Well-formedness constraints of the XML specification apply . An XML pattern has to be a single element pattern . It matches exactly those runtime representations of an XML tree that have the same structure as described by the pattern . XML patterns may contain Scala patterns(§8.4) . #co(){--------------------------------------------------- end-hide0} XML 仕様書の整形式制約が適用されます。 XML パターンは、ただ 1 つの要素パターンでなければなりません。 それは、パターンによって記述されたのと同じ構造を持つ、 それら XML ツリーの実行時表現と正確にマッチします。 XML パターンは Scala パターン(§8.4)を含んでいても構いません。 #co(){----------------------------------------------------- bgn-hide0} Whitespace is treated the same way as in XML expressions . Patterns that are entity references, CDATA sections, processing instructions and comments match runtime representations which are the the same . #co(){--------------------------------------------------- end-hide0} 空白文字は XML 中と同じ方法で扱われます。 エンティティ参照、CDATA セクション、処理命令とコメント等のパターンは、 同じ実行時表現とマッチします。 #co(){----------------------------------------------------- bgn-hide0} By default, beginning and trailing whitespace in element content is removed, and consecutive occurrences of whitespace are replaced by a single space character \u0020. This behavior can be changed to preserve all whitespace with a compiler option . #co(){--------------------------------------------------- end-hide0} デフォルトでは、要素コンテンツ中の始まりとお終いの空白文字は削除され、 連続する空白文字はただ 1 つのスペース文字 \u0020 で置き換えられます。 この振る舞いはコンパイラ・オプションで、すべての空白文字を維持するように 変えることができます。 &bold(){構文:} #co(){----------------------------------------------------- bgn-code} ElemPattern ::= EmptyElemTagP | STagP ContentP ETagP EmptyElemTagP ::= '<' Name [S] '/>' STagP ::= '<' Name [S] '>' ETagP ::= '</' Name [S]'>' ContentP ::= [CharData] {(ElemPattern|ScalaPatterns) [CharData]} ContentP1 ::= ElemPattern | Reference | CDSect | PI | Comment | ScalaPatterns ScalaPatterns ::= '{' Patterns '}' #co(){--------------------------------------------------- end-code} #center(){[[前ページ>Spec2.8Chap9a]]  [[目次>Spec2.8和訳]] [[次ページ>Spec2.8Chap11a]]}
#setmenu2(spec2.8-r-menu) * 第 10 章 XML 式とパターン (XML Expressions and Patterns) By Burak Emir This chapter describes the syntactic structure of XML expressions and patterns . It follows as closely as possible the XML 1.0 specification [W3C], changes being mandated by the possibility of embedding Scala code fragments . この章では XML 式とパターンの文法構造を記述します。 可能な限りしっかりと XML 1.0 仕様書[W3C]および、 今後の Scala コードの埋め込みで要求される変更に従います。 &br() &br() &aname(10.1,option=nolink){ } ** 10.1 XML 式 (XML Expressions) XML expressions are expressions generated by the following production, where the opening bracket '<' of the first element must be in a position to start the lexical XML mode (§1.5) . XML 式は次の文法規則によって生成される式です。ここで最初の要素の 始め山括弧 '<' は、字句上の XML モード (&link_anchor(1.5,page=Spec2.8Chap1a){§1.5}) を開始できる位置になければなりません。 &bold(){構文:} XmlExpr ::= XmlContent {Element} Well-formedness constraints of the XML specification apply, which means for instance that start tags and end tags must match, and attributes may only be defined once, with the exception of constraints related to entity resolution . XML 仕様書の整形式制約が適用されます。その意味は例えば、 開始タグと終了タグはマッチしなければならず、属性は一度だけ定義できる、 ただしエンティティ解決にかかわる制約の例外がある、ということです。 The following productions describe Scala's extensible markup language, designed as close as possible to the W3C extensible markup language standard . Only the productions for attribute values and character data are changed . Scala does not support declarations, CDATA sections or processing instructions . Entity references are not resolved at runtime . 次の文法規則は Scala の XML を記述しており、W3C XML 標準規格に可能な限り近く 設計されています。 属性値と文字データの文法規則だけは変えられています。 Scala は、宣言、CDATA セクションあるいは処理命令をサポートしていません。 エンティティ参照は、実行時には解決されません。 &bold(){構文:} Element ::= EmptyElemTag | STag Content ETag EmptyElemTag ::= '<' Name {S Attribute} [S] '/>' STag ::= '<' Name {S Attribute} [S] '>' ETag ::= '</' Name [S] '>' Content ::= [CharData] {Content1 [CharData]} Content1 ::= XmlContent | Reference | ScalaExpr XmlContent ::= Element | CDSect | PI | Comment If an XML expression is a single element, its value is a runtime representation of an XML node (an instance of a subclass of scala.xml.Node). If the XML expression consists of more than one element, then its value is a runtime representation of a sequence of XML nodes (an instance of a subclass of scala.Seq[scala.xml.Node]) . If an XML expression is an entity reference, CDATA section, processing instructions or a comments, it is represented by an instance of the corresponding Scala runtime class . もし XML 式がただ 1 つの要素なら、その値は XML ノード (scala.xml.Node のサブクラスのインスタンス)の実行時表現です。 もし XML 式が 1 つより多くの要素から成るなら、 その値は XML ノードのシーケンス (scala.Seq[scala.xml.Node] のサブクラスのインスタンス)の実行時表現です。 もし XML 式がエンティティ参照、CDATA セクション、処理命令あるいはコメントなら、 それは対応する Scala 実行時クラスのインスタンスによって表現されます。 By default, beginning and trailing whitespace in element content is removed, and consecutive occurrences of whitespace are replaced by a single space character \u0020. This behavior can be changed to preserve all whitespace with a compiler option . デフォルトでは、要素コンテンツ中の始まりとお終いの空白文字は削除され、 連続する空白文字はただ 1 つのスペース文字 \u0020 で置き換えられます。 この振る舞いはコンパイラ・オプションで、 すべての空白文字を維持するように変えることができます。 &bold(){構文:} Attribute ::= Name Eq AttValue AttValue ::= '"' {CharQ | CharRef} '"' | ''' {CharA | CharRef} ''' | ScalaExpr ScalaExpr ::= Block CharData ::= { CharNoRef } without {CharNoRef}'{'CharB {CharNoRef} and without {CharNoRef}']]>'{CharNoRef} XML expressions may contain Scala expressions as attribute values or within nodes . In the latter case, these are embedded using a single opening brace '{' and ended by a closing brace '}'. To express a single opening braces within XML text as generated by CharData, it must be doubled . Thus, '{{' represents the XML text '{' and does not introduce an embedded Scala expression . XML 式は、Scala 式を属性値としてあるいはノード内に含めることができます。 後者の場合、それらは 1 つの左波括弧 '{' を使って埋め込まれ、 右波括弧 '}' で終わります。 CharData で生成された時の XML テキスト中で 1 つの左波括弧を表すには、 それを 2 重にします。 ですから、'{{' は XML テキスト '{' を表し、埋め込まれた Scala 式を導入しません。 &bold(){構文:} BaseChar, Char, Comment, CombiningChar, Ideographic, NameChar, S, Reference ::= "W3C XML と同様" Char1 ::= Char without '<' | '&' CharQ ::= Char1 without '"' CharA ::= Char1 without ''' CharB ::= Char1 without '{' Name ::= XNameStart {NameChar} XNameStart ::= '_' | BaseChar | Ideographic (W3C XMLと同じだが ':'なし &br() &br() &aname(10.2,option=nolink){ } ** 10.2 XML パターン (XML Patterns) XML patterns are patterns generated by the following production, where the opening bracket '<' of the element patterns must be in a position to start the lexical XML mode (§1.5) . XML パターンは次の文法規則によって生成されるパターンです。 ここで要素パターンの始め山括弧 '<' は、字句上の XML モード (&link_anchor(1.5,page=Spec2.8Chap1a){§1.5}) を開始できる位置になければなりません。 &bold(){構文:} XmlPattern ::= ElementPattern Well-formedness constraints of the XML specification apply . An XML pattern has to be a single element pattern . It matches exactly those runtime representations of an XML tree that have the same structure as described by the pattern . XML patterns may contain Scala patterns(§8.4) . XML 仕様書の整形式制約が適用されます。 XML パターンは、ただ 1 つの要素パターンでなければなりません。 それは、パターンによって記述されたのと同じ構造を持つ XML ツリーの実行時表現と正確にマッチします。 XML パターンは Scala パターン (&link_anchor(8.4,page=Spec2.8Chap8b){§8.4})を含んでいても構いません。 Whitespace is treated the same way as in XML expressions . Patterns that are entity references, CDATA sections, processing instructions and comments match runtime representations which are the the same . 空白文字は XML 中と同じ方法で扱われます。 エンティティ参照、CDATA セクション、処理命令とコメント等のパターンは、 同じ実行時表現とマッチします。 By default, beginning and trailing whitespace in element content is removed, and consecutive occurrences of whitespace are replaced by a single space character \u0020. This behavior can be changed to preserve all whitespace with a compiler option . デフォルトでは、要素コンテンツ中の始まりとお終いの空白文字は削除され、 連続する空白文字はただ 1 つのスペース文字 \u0020 で置き換えられます。 この振る舞いはコンパイラ・オプションで、 すべての空白文字を維持するように変えることができます。 &bold(){構文:} ElemPattern ::= EmptyElemTagP | STagP ContentP ETagP EmptyElemTagP ::= '<' Name [S] '/>' STagP ::= '<' Name [S] '>' ETagP ::= '</' Name [S]'>' ContentP ::= [CharData] {(ElemPattern|ScalaPatterns) [CharData]} ContentP1 ::= ElemPattern | Reference | CDSect | PI | Comment | ScalaPatterns ScalaPatterns ::= '{' Patterns '}' #center(){[[前:9章>Spec2.8Chap9a]]  [[目次>Spec2.8和訳]] [[次:11章>Spec2.8Chap11a]]}

表示オプション

横に並べて表示:
変化行の前後のみ表示:
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。