Difference between revisions of "XBL"

From CDOT Wiki
Jump to: navigation, search
Line 1: Line 1:
=What is XBL?=
 
 
XBL stands for eXtensible Bindings Language, which is an XML language that is used for declaring the behavious of XUL widgets. Bindings can be attached to elements using either cascading stylesheets or the document object model. The element that the binding is attached to, called the bound element, acquires the new behavior specified by the binding.
 
 
=What Does XBL Do?=
 
 
Basically, XBL is a langauge that describes a set of bindings that can be attached and bound to elements on the screen. When bound, the binding implements new methods and properties to the associated element. In essence, the widgets on the screen are layed out using XUL and then given functionality using XBL.
 
 
=How does XBL work?=
 
 
==XBL Elements==
 
==XBL Elements==
 
:'''Bindings'''
 
:'''Bindings'''
Line 18: Line 9:
 
:'''Binding'''
 
:'''Binding'''
 
::The '''Binding''' element describes a single XBL binding.
 
::The '''Binding''' element describes a single XBL binding.
::
+
::The '''Binding''' element has the ability to add additional methods to an element.
 
+
::The '''Binding''' element has the ability to add additional or modify the properties of an element.
  
 
<pre>
 
<pre>
Line 32: Line 23:
 
>
 
>
 
</pre>
 
</pre>
 
=Resources/Examples=
 
==API Reference==
 
 
The [http://www.mozilla.org/projects/xbl/xbl.html Mozilla Webpage] has a list of Tags and examples that document the usage of XBL.
 
 
==Test Cases==
 
 
In this example, we can use XUL to define the layout of user interface and then use XBL to change the widgets functionality. <br/><br/>
 
 
Here is the XUL Code that lays out the widgets:
 
<pre>
 
<?xml version="1.0"?>
 
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
 
<?xml-stylesheet href="chrome://example/skin/example.css" type="text/css"?>
 
 
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
  <box class="okcancelbuttons"/>
 
</window>
 
</pre>
 
 
This lays out an interface with the buttons for OK and Cancel. To give these buttons functionality, XBL is used:
 
<pre>
 
<?xml version="1.0"?>
 
<bindings xmlns="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
  <binding id="okcancel">
 
    <content>
 
      <xul:button label="OK"/>
 
      <xul:button label="Cancel"/>
 
    </content>
 
  </binding>
 
</bindings>
 
</pre>
 
 
==Newsgroup==
 
 
[http://groups.google.ca/group/netscape.public.mozilla.xbl netscape.public.mozilla.xbl]
 

Revision as of 19:52, 5 October 2006

XBL Elements

Bindings
The Bindings element contains many Binding elements.
DTD decleration
<!ELEMENT bindings ( binding* ) > [ where * indicates zero or more of the binding element]
XML representation
<bindings ...><binding id="binding1"><binding><binding id="binding2"><binding></bindings>
Binding
The Binding element describes a single XBL binding.
The Binding element has the ability to add additional methods to an element.
The Binding element has the ability to add additional or modify the properties of an element.
<!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
>