Rule

A rule is used in a template. The children of the rule are used to declare the conditions in which the rule matches and the content that is generated. When the content needs to be displayed, the template builder scans through the RDF datasource searching for nodes that match the rules. When a rule is matched, the corresponding content is generated.

A rule contains two or three child elements. The conditions element is used to specify the conditions on which the resources in a datasource can match. Matching resources are used to generate content. Non-matching resources have no content generated for them. The action element specifies the content that is generated. The bindings element is optional and may specify additional variable bindings to be used.

All three children may use variables in place of attribute values. Variables are a question mark followed by a name. For a matched rule, each variable will be a reference to an RDF resource node. If the same variable appears multiple times, it must have the same value in each place.

A rule may use a shortcut syntax for matching that involves placing additional attributes on the rule element. The rule will match if the attribute matches an attribute on the RDF resource. When comparing attributes, the id, property and instanceOf attributes are ignored.

Each generated element will be given an id values automatically. The id values will correspond to an id of the resource in the datasource. You can use this id in a script to examine the resource.

More information about rule

rule 要素は template で利用される。 rule 要素の子要素は規則合致の条件と生成内容の宣言に利用される。内容が表示される必要が生じた時点で、テンプレートビルダ (template builder) が RDF データソース (RDF datasource) を走査し、規則に合致するノードを検索する。規則が合致すると、対応する内容が生成される。

rule 要素は 2 つか 3 つの子要素を持つ。データソースのリソースが合致すべき条件を指定するのには、 conditions 要素が使用される。合致したリソースを使用して、内容を生成する。合致しなかったリソースは、内容の生成に関わらない。 action 要素により、生成される内容が指定される。 bindings 要素はオプションであり、追加した変数バインディングが使用されることを指定する。

3 つの子要素は全て、属性値の場所に変数を使用できる。変数とは、名前の前にクエスチョンマーク (?) が付いたものである。合致した規則に対して、各変数は RDF リソースノードへの参照となる。同じ変数が複数回現れたときは、それぞれの場所に同じ値が入る必要がある。

rule 要素に属性を付け加えると、合致する規則に対してショートカット構文を使用することができる。その属性が RDF リソースの属性に合致したとき、規則は合致する。属性を比較する場合には、id、プロパティ、instanceOf 属性は無視される。

生成された要素には自動的に id 値が与えられる。この id 値は、データソース中のリソースの id に対応する。この id を使って、スクリプトでリソースを調べることができる。

rule の追加情報


属性:

XUL Element から継承:

align
allowevents
allownegativeassertions
class
coalesceduplicatearcs
collapsed
container
containment
context
contextmenu
datasources
debug
dir
empty
equalsize
flags
flex
height
hidden
id
insertafter
insertbefore
left
maxheight
maxwidth
menu
minheight
minwidth
mousethrough
observes
ordinal
orient
pack
persist
popup
position
ref
removeelement
sortDirection
sortResource
sortResource2
statustext
style
template
tooltip
tooltiptext
top
uri
wait-cursor
width

iscontainer

Type: boolean

Indicates whether rules match based on containment. If not specified, the rule may match regardless of whether a node is a container or not.

  • true: The rule will only match nodes that are marked as containers. This would apply to nodes that represent folders.
  • false: The rule will only match nodes that are not marked as containers.

型 : boolean

包含に基づいて規則が合致するかどうかを示す。指定しないときは、ノードがコンテナであるかコンテナではないかに関わらず、規則は合致する。

  • true: コンテナと印つけられたノードにのみ、規則は合致する。これはフォルダを表すノードに適用されよう。
  • false: コンテナと印つけられていないノードにのみ、規則は合致する。
isempty

Type: boolean

Indicates whether rules match based on emptyness. If not specified, the rule may match regardless of whether a node has children or not.

  • true: The rule will only match nodes that contain no child elements.
  • false: The rule will only match nodes that contain one or more child elements.

型 : boolean

空きに基づいて規則が合致するかどうかを示す。指定しないときは、ノードが子要素を持つか持たないかに関わらず、規則は合致する。

  • true: 子要素を持たないノードにのみ、規則は合致する。
  • false: 1 つ以上の子要素を持つノードにのみ、規則は合致する。
parent

Type: element tag name

If set, the rule will only match the corresponding tag. This may be used to have separate rules for leaf and container nodes with different tags.

型 : element tag name

設定すると、対応するタグにのみ規則は合致する。リーフとコンテナの異なるタグのノードに対して別個の規則を適用するために、これを使用する。

parsetype

Type: string

If this attribute is set to 'Integer', the rule will only match RDF nodes with a parse type of Integer.

型 : string

この属性を 'Integer' に設定すると、Integer の解析型を持つ RDF ノードにのみ規則は合致する。


プロパティとメソッド:

XUL Element から継承:

align allowEvents blur boxObject boxObject.element
boxObject.getLookAndFeelMetric boxObject.height boxObject.screenX boxObject.screenY boxObject.width
boxObject.x boxObject.y builder className click
collapsed contextMenu controllers database datasources
dir doCommand flex focus getElementsByAttribute
height hidden id left maxHeight
maxWidth menu minHeight minWidth observes
ordinal orient pack persist ref
resource statusText style tooltip tooltipText
top width

Element から継承:

addEventListener
appendChild
attributes
childNodes
cloneNode
dispatchEvent
firstChild
getAttribute
getAttributeNS
getAttributeNode
getAttributeNodeNS
getElementsByTagName
getElementsByTagNameNS
hasAttribute
hasAttributeNS
hasAttributes
hasChildNodes
insertBefore
isSupported
lastChild
localName
namespaceURI
nextSibling
nodeName
nodeType
nodeValue
normalize
ownerDocument
parentNode
prefix
previousSibling
removeAttribute
removeAttributeNS
removeAttributeNode
removeChild
removeEventListener
replaceChild
setAttribute
setAttributeNS
setAttributeNode
setAttributeNodeNS
tagName

Copyright (C) 1999 - 2004 XulPlanet.com