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


Attributes:

Inherited from XUL Element:

align
allowevents
allownegativeassertions
class
coalesceduplicatearcs
collapsed
container
containment
context
contextmenu
datasources
dir
empty
equalsize
flags
flex
height
hidden
id
insertafter
insertbefore
left
maxheight
maxwidth
menu
minheight
minwidth
mousethrough
observes
ordinal
orient
pack
persist
popup
position
preference-editable
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.

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.

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.

parsetype

Type: string

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


Properties and Methods:

Inherited from 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

Inherited from 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