The W3C's XML Binding Language 2.0 (XBL) is a declarative language that can be used together with existing or new web documents to enhance their presentation, behavior, accessibility, and maintainability.
12. Binding Global Attributes
Implementation
p e e tat o xbl:pseudo
b pseudo
▪ For CSS pseudo selectors
Template
xbl:attr
▪ Content
▪ div ▪ For forwarding attributes
▪ Inherited
Resources
▪ Prefetch
▪ Style
Handlers
▪ Handler
Script
13. Same as HTML script <script>
Declare global var c = 0;
functions function magic(a,b ){
Scoped to the XBL return a + b c;
return a + b * c;
document }
</script?>
14. Allows you to define a binding:
How it behaves
H it b h
If it extends other bindings (inheritance model will
be discussed later)
What content it adds when bound to another
element
What resources it uses
15. Allows you to add new <binding element=“h1”>
DOM interfaces <implementation>
Define new functionality for ({
an object this.makeRed() =function(){
Define event handlers },
}
Define properties and fields this.onclick(e) = function{
this.makeRed();
}
})
</implementation>
/implementation
</binding>
...
<h1>
16. Template <binding id=“reshuffle”>
<template>
Contains a template of the
p
<content includes=“b”/>
content to be inserted into
a document <content includes=“a”/>
Content </template>
Inserts the “selected” </binding>
content of a bound ....
element
l t
<div id=“homepage”>
You can only use a selected
<h1 id=“a”>Welcome!</h1>
element once.
<h2 id=“b”>Marcos’
h id “b” M ’
The resulting DOM tree
page</h1>
is called shadow content
</div>
17. DIV <binding extends=“reshuffle”>
<template>
Used as a general container
<div state=“idle”>
mechanism (like HTML div)
<inherited>
Has a “state” attribute
Inherited <h1>
no one’s homepage
Used to insert the content of an
</h1>
extended binding into another
binding. </inherited>
<div>
</template>
p
<resources>
<style>
div[state=idle]{
color: yellow;
}
</style>
</ resources>
</binding>
18. Resources <binding>
<resources>
esou ces
Structural container
<style>
Style
button:active{
Styles applied to a binding
y pp g
border: solid red;
Author sheet styles can
background: url(fancy.png);
also be applied to a
binding
bi di }
Prefetch </style>
Primes the cache <prefetch src=“fancy.png”/>
fh “f ”/
</resources>
</binding>
19. Allows you to group event The bound document is:
handlers
Trap DOM events and re‐route
p <hotspot message=quot;Hello Worldquot;>
p g
them to functions defined in the <instruction>
<implementation> Activate this text.
Fine‐grained control over </instruction>
keyboard and mouse events </hotspot>
The binding is:
<binding>
g
<handlers>
<handler event=quot;clickquot;>
alert(
event.currentTarget.getAttribute(
event currentTarget getAttribute(
'message' ));
</handler>
</handlers>
</binding>
20. id key
event key‐location
key location
phase text
trusted prev‐value
prev value
propagate new‐value
default action
default‐action attr name
attr‐name
button attr‐change
click‐count
click count
modifiers
21. Document attachment Binding Detachment
Element.removeBinding(URI)
Processing Instruction
▪ <?xbl href=quot;foo.xmlquot;?>
New DOM interface
▪ document.loadBindingDocument('foo.xml');
Element Attachment
CSS
▪ ‐xbl‐binding: url(quot;foo.xmlquot;)
g ( )
Binding element
▪ <binding element=quot;#xquot;>
g