mozilla

Revision 41787 of Elements

  • Revision slug: XBL/XBL_1.0_Reference/Elements
  • Revision title: Elements
  • Revision id: 41787
  • Created:
  • Creator: Tservo
  • Is current revision? No
  • Comment /* getter */
Tags: 

Revision Content

bindings

<!ENTITY % bindings-content "(binding|script|stylesheet)*">
<!ELEMENT bindings %bindings-content;>
<!ATTLIST bindings
   id               ID           #IMPLIED
   type             CDATA        #IMPLIED
>

The bindings element is the root element of an XBL document. It contains zero or more binding elements as children. Each binding child element defines a unique binding that can be attached to elements in other documents. The bindings element can also contain script and stylesheet elements as children. These specify scripts and stylesheets that are used by the bindings.

<bindings xmlns="http://www.mozilla.org/xbl">
  <binding id="binding1">
    ...
  </binding>
  <binding id="binding2">
    ...
  </binding>
  ...
</bindings>
  • id - The id attribute is a document-unique identifier. The value of this identifier is often used to manipulate the element through a DOM interface (e.g., using document.getElementById).
  • type - The type attribute specifies the scripting language used by all bindings in the document. Bindings can selectively override this default by specifying type attributes of their own.

binding

<!ENTITY % binding-content "(content?,implementation?,handlers?)">
<!ELEMENT binding %binding-content;>
<!ATTLIST binding
   id                     ID             #REQUIRED
   extends                CDATA          #IMPLIED
   display                CDATA          #IMPLIED
   applyauthorstyles      false          #IMPLIED
   styleexplicitcontent   false          #IMPLIED
>

The binding element describes a single XBL binding that dynamically binds new information to XML elements in other documents. Each binding has three optional components.

  • Content - A binding can specify new content that is placed around the bound element. This content is anonymous and is hidden from the bound element's DOM.
  • Methods and Properties - A binding can specify additional methods that can be invoked on the element. It can also specify additional properties that can be retrieved or set on the element. In this way the functionality of the bound element becomes extensible.
  • Behavior - A binding can specify event handlers for specific actions like key and mouse events that can make use of the new functionality applied in the binding.
  • id - The id attribute is a document-unique identifier. For the binding element, this attribute is required, since it is used to uniquely identify a binding.
  • extends - The extends attribute is used to specify the URL of a binding that this binding inherits from. The URL specifies a particular binding document. The # notation must be used to point to a specific binding id within a binding document.
  • applyauthorstyles - The applyauthorstyles attribute indicates whether or not rules in author style sheets associated with the bound element's document apply to the anonymous content generated by the binding. If omitted, a value of false is assumed. See section 4.6 for more information.
  • styleexplicitcontent - The styleexplicitcontent attribute indicates whether or not style sheets loaded from an XBL document are applied to a bound element's explicit children (in addition to the bound element itself). If omitted, a value of false is assumed. See section 4.6 for more information.

content

<!ELEMENT content ANY>
<!ATTLIST content
   id               ID           #IMPLIED
>

The content element contains child nodes that can be in any namespace. The subtree specified by the content element is referred to as the anonymous content template. When a binding is attached and if the conditions specified by the template are met, the content element's child nodes are cloned and inserted into the bound document around the bound element. Because the nodes are hidden from their parent and exist outside the normal document tree, they are referred to as anonymous content.

  • id - The id attribute is a document-unique identifier.

children

<!ELEMENT children EMPTY>
<!ATTLIST children
   id               ID                           #IMPLIED
   includes         CDATA                        #IMPLIED
   type             (explicit|inherited)         explicit
>

The children element is used inside anonymous content to specify insertion points for explicit content that might already exist underneath the bound element or for anonymous content generated by the base binding. As far as the presentation model is concerned, any anonymous content the binding places between the bound element and the insertion point is interleaved between the bound element and its explicit children without affecting the document model.

See section 4.4 for more information.

  • id - The id attribute is a document-unique identifier.
  • includes - The includes attribute can be used to indicate that only certain content should be placed at the insertion point specified by the children element. Its value is an XPath selector as described in the XPath 1.0 specification. For the purposes of the evaluation, the bound element is treated as the context node. If the selector evaluates to anything other than a node set, it is ignored. A child can only be placed within the insertion point if it is matched by the XPath selector. Only immediate children are matched against the selector.
  • type - The type attribute can be used to indicate the type of the insertion point. There are two types of insertion points. An explicit insertion point is for the explicit children of the bound element only. An inherited insertion point is used to specify that anonymous content from the base binding can be generated and placed at the insertion point.

element

<!ELEMENT element ANY>
<!ATTLIST element
   id               ID           #IMPLIED
>

The element tag specifies the position of the bound element within the anonymous content of a binding. Normally anonymous content is generated underneath the bound element. If the element tag is used inside anonymous content it indicates the position at which the bound element should be placed relative to its anonymous content. This allows anonymous content ancestors to be generated by the binding (in addition to children).

If no element tag is specified, all anonymous content is generated underneath the bound element.

  • id - The id attribute is a document-unique identifier.

implementation

<!ENTITY % implementation-content "(method|property)*">
<!ELEMENT implementation %implementation-content;>
<!ATTLIST implementation
   id               ID           #IMPLIED
   name             CDATA        #IMPLIED
   implements       CDATA        #IMPLIED
   type             CDATA        #IMPLIED
>

The implementation element describes a set of methods and properties that are attached to the bound element. Once the binding is attached, these methods and properties can be invoked directly from the bound element.

  • id - The id attribute is a document-unique identifier.
  • name - The name attribute can be used to provide a specific name for an implementation. This name can then be used to reference the implementation. For example, in Javascript the value of this attribute represents the name of the corresponding class that is constructed for the implementation. If no name attribute is specified then the binding's document URI and id are used to uniquely reference the binding's implementation.
  • implements - The implements attribute can be used to describe a set of interfaces that are implemented by the binding. Its value is a comma-separated list of named interfaces. If supported, in strongly typed languages the bound element can be referenced not only as any of the interfaces that the element might already support (e.g., HTMLElement) but also as any of the interfaces described by this attribute. Support of this capability is optional.
  • type -The type attribute indicates the language used to describe the methods and properties of the implementation, e.g., text/javascript.

method

<!ENTITY % method-content "(parameter*,body?)">
<!ELEMENT method %method-content;>
<!ATTLIST method
   id               ID           #IMPLIED
   name             CDATA        #REQUIRED
   type             CDATA        #IMPLIED
>

The method element is used to describe a single method of a binding implementation.

<method name="scrollTo">
  <parameter name="index"/>
  <body>
    this.setAttribute("scrollpos", index);
  </body>
</method>
  • id - The id attribute is a document-unique identifier.
  • name - The name attribute's value is the name given to the method when it is attached to the bound element. The method can be invoked directly from the bound element using this value.
  • type - The type attribute indicates the language used for the body of the method, e.g., text/javascript.

parameter

<!ELEMENT parameter EMPTY>
<!ATTLIST parameter
   id               ID           #IMPLIED
   name             CDATA        #REQUIRED
>

The parameter element is used inside a method element. It represents a single parameter of a method.

{{mediawiki.external('Editor\'s Note: Should we support the capability to specify types? Assuming that only dynamic scripting languages are used, this may not be a requirement.')}}

  • id - The id attribute is a document-unique identifier.
  • name - The value of the name attribute is used by script within a method's body element to reference this parameter.

body

<!ELEMENT body CDATA>
<!ATTLIST body
   id               ID           #IMPLIED
>

The body element represents the implementation of its corresponding method. Its contents are the script that is executed when the method is invoked.

  • id - The id attribute is a document-unique identifier.

property

<!ENTITY % property-content "(getter?,setter?)|#PCDATA">
<!ELEMENT property %property-content;>
<!ATTLIST property
   id               ID                  #IMPLIED
   name             CDATA               #REQUIRED
   readonly         (true|false)        #IMPLIED
   onget            CDATA               #IMPLIED
   onset            CDATA               #IMPLIED
   element          IDREF               #IMPLIED
   attribute        CDATA               #IMPLIED
   property         CDATA               #IMPLIED 
   type             CDATA               #IMPLIED
>

The property element represents a single property of an implementation. Properties come in two flavors. One type of property consists of a pair of getter/setter functions that can be defined using onget/onset attributes or getter/setter elements underneath the property element. The other type of property is a raw value whose initial value can be specified with a script contained underneath the property element. Like methods, once the binding is attached, the property can be obtained directly from the bound element.

  • id - The id attribute is a document-unique identifier.
  • name - The name of the property. This is the name used to refer to the property on the bound element.
  • readonly - The readonly attribute is used to designate a property as read-only. If set to true, the value of the property cannot be altered. If this attribute is omitted, the property will be readable and writable.
  • onget - The onget attribute's value is a script that executes when the value of the property is requested. If this attribute is set, any initial value contained underneath the element will be ignored. The return value of the script represents the value of the property that will be returned to the requestor. A property getter can also be specified as a child of the property element using the getter tag.
  • onset - The onset attribute's value is a script that executes when the value of the property is being altered. If this attribute is set, any initial value contained underneath the element will be ignored. Within the script, the parameter val represents the new value being assigned. The script should always return the actual value assigned in order to allow for chained assignment operations. A property setter can also be specified as a child of the property element using a setter tag.
  • element - The element attribute's value is the ID of an anonymous element generated by one of the bindings attached to the bound element. When this attribute is set, any getters and setters defined are ignored. Instead whenever the property is set on the bound element, a corresponding property or attribute is set on the anonymous element. Whenever the property is retrieved, it is obtained from the corresponding property or attribute on the anonymous element.
  • property - Used in conjunction with the element attribute, the property attribute links the property named by the attribute to the property specifed on the bound element. Its value is used when the bound element's property is accessed, and its value is set when the bound element's property is set.
  • attribute - Used in conjunction with the element attribute, this attribute links the specified attribute to the property specifed on the bound element. Its value is obtained when the bound element's property is accessed, and its value is set when the bound element's property is set.
  • type - The type attribute indicates the language used to describe the getters/setters for the property or the initial value of the property, e.g., text/javascript.

getter

<!ELEMENT getter PCDATA>
<!ATTLIST getter
   id               ID                  #IMPLIED
   type             CDATA               #IMPLIED
>

The getter element wraps a script for retrieving a specific property. It is always the child of a property element. The type attribute on the enclosing implementation element determines the language of the script.

  • id - The id attribute is a document-unique identifier.
  • type - The type attribute indicates the language used to describe the getter.

setter

handlers

handler

script

stylesheet

Revision Source

<p>
</p>
<h2 name="bindings">bindings</h2>
<pre>&lt;!ENTITY % bindings-content "(binding|script|stylesheet)*"&gt;
&lt;!ELEMENT bindings %bindings-content;&gt;
&lt;!ATTLIST bindings
   id               ID           #IMPLIED
   type             CDATA        #IMPLIED
&gt;
</pre>
<p>The <code>bindings</code> element is the root element of an XBL document. It contains zero or more <code>binding</code> elements as children. Each <code>binding</code> child element defines a unique binding that can be attached to elements in other documents. The <code>bindings</code> element can also contain <code>script</code> and <code>stylesheet</code> elements as children. These specify scripts and stylesheets that are used by the bindings.
</p>
<pre>&lt;bindings xmlns="http://www.mozilla.org/xbl"&gt;
  &lt;binding id="binding1"&gt;
    ...
  &lt;/binding&gt;
  &lt;binding id="binding2"&gt;
    ...
  &lt;/binding&gt;
  ...
&lt;/bindings&gt;
</pre>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier. The value of this identifier is often used to manipulate the element through a DOM interface (e.g., using <code>document.getElementById</code>). 
</li><li> <code><b>type</b></code> - The <code>type</code> attribute specifies the scripting language used by all bindings in the document. Bindings can selectively override this default by specifying <code>type</code> attributes of their own.
</li></ul>
<h2 name="binding">binding</h2>
<pre>&lt;!ENTITY % binding-content "(content?,implementation?,handlers?)"&gt;
&lt;!ELEMENT binding %binding-content;&gt;
&lt;!ATTLIST binding
   id                     ID             #REQUIRED
   extends                CDATA          #IMPLIED
   display                CDATA          #IMPLIED
   applyauthorstyles      false          #IMPLIED
   styleexplicitcontent   false          #IMPLIED
&gt;
</pre>
<p>The <code>binding</code> element describes a single XBL binding that dynamically binds new information to XML elements in other documents. Each binding has three optional components.
</p>
<ul><li> <i>Content</i> - A binding can specify new content that is placed around the bound element. This content is anonymous and is hidden from the bound element's DOM.
</li><li> <i>Methods and Properties</i> - A binding can specify additional methods that can be invoked on the element. It can also specify additional properties that can be retrieved or set on the element. In this way the functionality of the bound element becomes extensible.
</li><li> <i>Behavior</i> - A binding can specify event handlers for specific actions like key and mouse events that can make use of the new functionality applied in the binding.
</li></ul>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier. For the binding element, this attribute is required, since it is used to uniquely identify a binding. 
</li><li> <code><b>extends</b></code> - The <code>extends</code> attribute is used to specify the URL of a binding that this binding inherits from. The URL specifies a particular binding document. The # notation must be used to point to a specific binding <code>id</code> within a binding document. 
</li><li> <code><b>applyauthorstyles</b></code> - The <code>applyauthorstyles</code> attribute indicates whether or not rules in author style sheets associated with the bound element's document apply to the anonymous content generated by the binding. If omitted, a value of <code>false</code> is assumed. See <a href="en/Section_4.6">section 4.6</a> for more information. 
</li><li> <code><b>styleexplicitcontent</b></code> - The <code>styleexplicitcontent</code> attribute indicates whether or not style sheets loaded from an XBL document are applied to a bound element's explicit children (in addition to the bound element itself). If omitted, a value of <code>false</code> is assumed. See <a href="en/Section_4.6">section 4.6</a> for more information.
</li></ul>
<h2 name="content">content</h2>
<pre>&lt;!ELEMENT content ANY&gt;
&lt;!ATTLIST content
   id               ID           #IMPLIED
&gt;
</pre>
<p>The <code>content</code> element contains child nodes that can be in any namespace. The subtree specified by the <code>content</code> element is referred to as the <i>anonymous content template</i>. When a binding is attached and if the conditions specified by the template are met, the <code>content</code> element's child nodes are cloned and inserted into the bound document around the bound element. Because the nodes are hidden from their parent and exist outside the normal document tree, they are referred to as anonymous content.
</p>
<ul><li> <code><b>id</b></code> - The id attribute is a document-unique identifier.
</li></ul>
<h2 name="children">children</h2>
<pre>&lt;!ELEMENT children EMPTY&gt;
&lt;!ATTLIST children
   id               ID                           #IMPLIED
   includes         CDATA                        #IMPLIED
   type             (explicit|inherited)         explicit
&gt;
</pre>
<p>The <code>children</code> element is used inside anonymous content to specify insertion points for explicit content that might already exist underneath the bound element or for anonymous content generated by the base binding. As far as the presentation model is concerned, any anonymous content the binding places between the bound element and the insertion point is interleaved between the bound element and its explicit children without affecting the document model.
</p><p>See <a href="en/Section_4.4">section 4.4</a> for more information.
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier. 
</li><li> <code><b>includes</b></code> - The <code>includes</code> attribute can be used to indicate that only certain content should be placed at the insertion point specified by the <code>children</code> element. Its value is an XPath selector as described in the <a class="external" href="http://www.w3.org/TR/xpath.html">XPath 1.0</a> specification. For the purposes of the evaluation, the bound element is treated as the context node. If the selector evaluates to anything other than a node set, it is ignored. A child can only be placed within the insertion point if it is matched by the XPath selector. Only immediate children are matched against the selector. 
</li><li> <code><b>type</b></code> - The <code>type</code> attribute can be used to indicate the type of the insertion point. There are two types of insertion points. An <i>explicit</i> insertion point is for the explicit children of the bound element only. An <i>inherited</i> insertion point is used to specify that anonymous content from the base binding can be generated and placed at the insertion point.
</li></ul>
<h2 name="element">element</h2>
<pre>&lt;!ELEMENT element ANY&gt;
&lt;!ATTLIST element
   id               ID           #IMPLIED
&gt;
</pre>
<p>The <code>element</code> tag specifies the position of the bound element within the anonymous content of a binding. Normally anonymous content is generated underneath the bound element. If the <code>element</code> tag is used inside anonymous content it indicates the position at which the bound element should be placed relative to its anonymous content. This allows anonymous content ancestors to be generated by the binding (in addition to children).
</p><p>If no <code>element</code> tag is specified, all anonymous content is generated underneath the bound element.
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier.
</li></ul>
<h2 name="implementation">implementation</h2>
<pre>&lt;!ENTITY % implementation-content "(method|property)*"&gt;
&lt;!ELEMENT implementation %implementation-content;&gt;
&lt;!ATTLIST implementation
   id               ID           #IMPLIED
   name             CDATA        #IMPLIED
   implements       CDATA        #IMPLIED
   type             CDATA        #IMPLIED
&gt;
</pre>
<p>The <code>implementation</code> element describes a set of methods and properties that are attached to the bound element. Once the binding is attached, these methods and properties can be invoked directly from the bound element.
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier. 
</li><li> <code><b>name</b></code> - The <code>name</code> attribute can be used to provide a specific name for an implementation. This name can then be used to reference the implementation. For example, in Javascript the value of this attribute represents the name of the corresponding class that is constructed for the implementation. If no name attribute is specified then the binding's document URI and id are used to uniquely reference the binding's implementation. 
</li><li> <code><b>implements</b></code> - The <code>implements</code> attribute can be used to describe a set of interfaces that are implemented by the binding. Its value is a comma-separated list of named interfaces. If supported, in strongly typed languages the bound element can be referenced not only as any of the interfaces that the element might already support (e.g., HTMLElement) but also as any of the interfaces described by this attribute. Support of this capability is optional. 
</li><li> <code><b>type</b></code> -The <code>type</code> attribute indicates the language used to describe the methods and properties of the implementation, e.g., <code>text/javascript</code>.
</li></ul>
<h2 name="method">method</h2>
<pre>&lt;!ENTITY % method-content "(parameter*,body?)"&gt;
&lt;!ELEMENT method %method-content;&gt;
&lt;!ATTLIST method
   id               ID           #IMPLIED
   name             CDATA        #REQUIRED
   type             CDATA        #IMPLIED
&gt;
</pre>
<p>The <code>method</code> element is used to describe a single method of a binding implementation.
</p>
<pre>&lt;method name="scrollTo"&gt;
  &lt;parameter name="index"/&gt;
  &lt;body&gt;
    this.setAttribute("scrollpos", index);
  &lt;/body&gt;
&lt;/method&gt;
</pre>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier. 
</li><li> <code><b>name</b></code> - The <code>name</code> attribute's value is the name given to the method when it is attached to the bound element. The method can be invoked directly from the bound element using this value. 
</li><li> <code><b>type</b></code> - The <code>type</code> attribute indicates the language used for the body of the method, e.g., <code>text/javascript</code>.
</li></ul>
<h2 name="parameter">parameter</h2>
<pre>&lt;!ELEMENT parameter EMPTY&gt;
&lt;!ATTLIST parameter
   id               ID           #IMPLIED
   name             CDATA        #REQUIRED
&gt;
</pre>
<p>The <code>parameter</code> element is used inside a <code>method</code> element. It represents a single parameter of a method.
</p><p>{{mediawiki.external('Editor\'s Note: Should we support the capability to specify types? Assuming that only dynamic scripting languages are used, this may not be a requirement.')}}
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier. 
</li><li> <code><b>name</b></code> - The value of the <code>name</code> attribute is used by script within a method's <code>body</code> element to reference this parameter.
</li></ul>
<h2 name="body">body</h2>
<pre>&lt;!ELEMENT body CDATA&gt;
&lt;!ATTLIST body
   id               ID           #IMPLIED
&gt;
</pre>
<p>The <code>body</code> element represents the implementation of its corresponding <code>method</code>. Its contents are the script that is executed when the method is invoked.
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier.
</li></ul>
<h2 name="property">property</h2>
<pre>&lt;!ENTITY % property-content "(getter?,setter?)|#PCDATA"&gt;
&lt;!ELEMENT property %property-content;&gt;
&lt;!ATTLIST property
   id               ID                  #IMPLIED
   name             CDATA               #REQUIRED
   readonly         (true|false)        #IMPLIED
   onget            CDATA               #IMPLIED
   onset            CDATA               #IMPLIED
   element          IDREF               #IMPLIED
   attribute        CDATA               #IMPLIED
   property         CDATA               #IMPLIED 
   type             CDATA               #IMPLIED
&gt;
</pre>
<p>The <code>property</code> element represents a single property of an implementation. Properties come in two flavors. One type of property consists of a pair of getter/setter functions that can be defined using <code>onget</code>/<code>onset</code> attributes or <code>getter</code>/<code>setter</code> elements underneath the <code>property</code> element. The other type of property is a raw value whose initial value can be specified with a script contained underneath the <code>property</code> element. Like methods, once the binding is attached, the property can be obtained directly from the bound element.
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier. 
</li><li> <code><b>name</b></code> - The name of the property. This is the name used to refer to the property on the bound element. 
</li><li> <code><b>readonly</b></code> - The <code>readonly</code> attribute is used to designate a property as read-only. If set to <code>true</code>, the value of the property cannot be altered. If this attribute is omitted, the property will be readable and writable. 
</li><li> <code><b>onget</b></code> - The <code>onget</code> attribute's value is a script that executes when the value of the property is requested. If this attribute is set, any initial value contained underneath the element will be ignored. The return value of the script represents the value of the property that will be returned to the requestor. A property getter can also be specified as a child of the <code>property</code> element using the <code>getter</code> tag. 
</li><li> <code><b>onset</b></code> - The <code>onset</code> attribute's value is a script that executes when the value of the property is being altered. If this attribute is set, any initial value contained underneath the element will be ignored. Within the script, the parameter <code>val</code> represents the new value being assigned. The script should always return the actual value assigned in order to allow for chained assignment operations. A property setter can also be specified as a child of the <code>property</code> element using a <code>setter</code> tag. 
</li><li> <code><b>element</b></code> - The <code>element</code> attribute's value is the ID of an anonymous element generated by one of the bindings attached to the bound element. When this attribute is set, any getters and setters defined are ignored. Instead whenever the property is set on the bound element, a corresponding property or attribute is set on the anonymous element. Whenever the property is retrieved, it is obtained from the corresponding property or attribute on the anonymous element. 
</li><li> <code><b>property</b></code> - Used in conjunction with the <code>element</code> attribute, the <code>property</code> attribute links the property named by the attribute to the property specifed on the bound element. Its value is used when the bound element's property is accessed, and its value is set when the bound element's property is set. 
</li><li> <code><b>attribute</b></code> - Used in conjunction with the <code>element</code> attribute, this attribute links the specified attribute to the property specifed on the bound element. Its value is obtained when the bound element's property is accessed, and its value is set when the bound element's property is set. 
</li><li> <code><b>type</b></code> - The <code>type</code> attribute indicates the language used to describe the getters/setters for the property or the initial value of the property, e.g., <code>text/javascript</code>.
</li></ul>
<h2 name="getter">getter</h2>
<pre>&lt;!ELEMENT getter PCDATA&gt;
&lt;!ATTLIST getter
   id               ID                  #IMPLIED
   type             CDATA               #IMPLIED
&gt;
</pre>
<p>The <code>getter</code> element wraps a script for retrieving a specific property. It is always the child of a <code>property</code> element. The <code>type</code> attribute on the enclosing implementation element determines the language of the script.
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier. 
</li><li> <code><b>type</b></code> - The <code>type</code> attribute indicates the language used to describe the getter.
</li></ul>
<h2 name="setter">setter</h2>
<h2 name="handlers">handlers</h2>
<h2 name="handler">handler</h2>
<h2 name="script">script</h2>
<h2 name="stylesheet">stylesheet</h2>
Revert to this revision