1. 序論
選択子は、 ~HTML/~XML 内容~内のものを選択するために普及している仕組みである。 それらは、~CSS `CSS3SYN$r における利用のみならず,[ jQuery などの~library / `SELECTORS-API$r の様な新たに標準~化された~browser~API / ITS 2.0 の様な他の~Web標準 ]においても,自立的な~query言語として利用される。 ◎ Selectors are a very popular mechanism for selecting things in HTML and XML content. They are not used only in CSS [CSS3SYN] but also as a standalone query language in libraries like jQuery, in newer standardized browser APIs like [SELECTORS-API] and in other Web standards like ITS 2.0.
`SELECTORS4$r 仕様が定義している選択子は,文書から要素~nodeを選択するものに限られているが、他の型の~nodeを選択する選択子が~~望まれることもある。 この仕様は、文書~木~内の非要素~nodeを選択するための選択子を追加して, `SELECTORS4$r を拡張する。 ◎ The [SELECTORS4] specification only defines selectors for selecting element nodes from the document, but some uses of Selectors would like to select other types of nodes as well. This specification extends [SELECTORS4] with additional selectors that can be used for selecting non-element nodes in a document tree.
注記: 現在、この草案は属性~nodeを[ 選択する/照合する ]ための手段しか定義していないが、将来には ~comment/処理命令などの 他種の~nodeも~supportするかもしれない。 ◎ Note: Currently the draft only defines means for selecting and matching attribute nodes, but other kinds of nodes, such as comments or processing instructions, might be supported in the future.
2. 非要素 選択子
2.1. 属性~node選択子
`属性~node選択子@ は、文書~木~内の属性~nodeを表現する。 その構文は: ◎ An attribute node selector represents an attribute node in a document tree. Its syntax is:
`attr()@pe = ::attr( `namespace-attr$t? ) `namespace-attr@t = [ `na-prefix$t? '|' ]? `na-name$t `na-prefix@t = `ident$t | '*' `na-name@t = `ident$t | '*'
`namespace-attr$t を成す~tokenたちの合間には、空白は許容されない。 ◎ No whitespace is allowed between the tokens of <namespace-attr>.
`namespace-attr$t は、順に,次の 2 つの部分からなる:
- 文字 '`|^css' に先行する接頭辞(省略可の `na-prefix$t )
- 後続する属性~名( `na-name$t )
選択子は、`疑似要素$の構文を利用する。 選択子が合致するのは、`出自の要素$が有する属性~nodeのうち:
- `namespace-attr$t がまるごと省略されている場合、どの属性~nodeにも合致する。
-
他の場合、属性~nodeに関して次の両者とも満たされるとき,合致する:
-
`na-prefix$t に応じて,次のいずれかが満たされる:
- 文字 `*^css である。
- 省略されていて,属性は`~null名前空間$に属する。
- `ident$t として供されていて,それはある`宣言-済み$の`名前空間~接頭辞$に合致していて、属性は その接頭辞に対応付けられた名前空間に属する。 (合致する宣言-済みの`名前空間~接頭辞$がない場合、選択子は何にも合致しないことになる。) 【接頭辞が宣言されている~stylesheetはどれでもよいのか? 複数の~stylesheetが同じ接頭辞を宣言しつつ,異なる名前空間に対応付けている場合はどうなる?】
-
`na-name$t に応じて,次のいずれかが満たされる:
- 文字 `*^css である。
- `ident$t として供されていて,それは属性の名前に合致する。
-
次の ITS 規則は、属性~node選択子を利用して, `abbr^e 要素の `title^a 属性に対する翻訳可否を否に切替える。 ◎ The following ITS rules use an attribute node selector to switch off translatability of title attribute on abbr elements.
<rules xmlns="http://www.w3.org/2005/11/its" version="2.0" queryLanguage="css"> <translateRule selector="abbr::attr(title)" translate="no"/> </rules>
`属性~node選択子$は、~CSSの視野~内で利用されても まったく妥当であるが,それが~boxを生成することは決してない。 ◎ Although entirely valid in Selectors used in the scope of CSS, attribute node selectors never generate boxes.