<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>techno.blog(&#34;Dion&#34;) &#187; xbl</title>
	<atom:link href="http://almaer.com/blog/tag/xbl/feed" rel="self" type="application/rss+xml" />
	<link>http://almaer.com/blog</link>
	<description>blogging about life, the universe, and everything tech</description>
	<lastBuildDate>Fri, 30 Jul 2010 00:42:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Web Archeology: XML Binding Language (XBL)</title>
		<link>http://almaer.com/blog/web-archeology-xml-binding-language-xbl</link>
		<comments>http://almaer.com/blog/web-archeology-xml-binding-language-xbl#comments</comments>
		<pubDate>Wed, 09 Apr 2008 00:15:18 +0000</pubDate>
		<dc:creator>dion</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Web Browsing]]></category>
		<category><![CDATA[archeology]]></category>
		<category><![CDATA[htc]]></category>
		<category><![CDATA[xbl]]></category>

		<guid isPermaLink="false">http://almaer.com/blog/web-archeology-xml-binding-language-xbl</guid>
		<description><![CDATA[
First came IE behaviours (HTC), which allowed you to bind script and binary behaviour to tags via CSS, for IE only of course. Mozilla decided that it needed a language to tie behaviour to XUL widgets and XML elements in general, and they created the first version of XBL.
I met Jonas Sicking of Mozilla for [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://almaer.com/blog/uploads/archeology2.jpg' alt='Archeology' border='0'/></p>
<p>First came <a href="http://msdn2.microsoft.com/en-us/library/ms531079(VS.85).aspx">IE behaviours</a> (HTC), which allowed you to bind script and binary behaviour to tags via CSS, for IE only of course. Mozilla decided that it needed a language to tie behaviour to XUL widgets and XML elements in general, and they created the first version of XBL.</p>
<p>I met Jonas Sicking of Mozilla for the first time recently, and found out that he is working on XBL 2.0, a spec that was edited by none other than Ian Hickson. That man is a machine!</p>
<p>XBL 2.0 cleans up the original work from Mozilla, and gives you a really nice way to add scripting behaviour to tags.</p>
<p>The example application below gives you a good view of how you could implement &#8216;an inaccessible implementation of the proposed HTML5 details disclosure element: it opens and closes when clicked, and reflects its current state in the element&#8217;s &#8220;open&#8221; attribute.&#8217;</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xbl</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/ns/xbl&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;binding</span> <span style="color: #000066;">element</span>=<span style="color: #ff0000;">&quot;details&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;template<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;content</span> <span style="color: #000066;">includes</span>=<span style="color: #ff0000;">&quot;legend:first-child&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Details...<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/content<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">state</span>=<span style="color: #ff0000;">&quot;hidden&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;container&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;content</span><span style="color: #000000; font-weight: bold;">/&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/template<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;handlers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;handler</span> <span style="color: #000066;">event</span>=<span style="color: #ff0000;">&quot;click&quot;</span> <span style="color: #000066;">phase</span>=<span style="color: #ff0000;">&quot;default-action&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    this.open = !this.open;
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/handler<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;handler</span> <span style="color: #000066;">event</span>=<span style="color: #ff0000;">&quot;DOMAttrModified&quot;</span> <span style="color: #000066;">attr-name</span>=<span style="color: #ff0000;">&quot;open&quot;</span> <span style="color: #000066;">attr-change</span>=<span style="color: #ff0000;">&quot;addition&quot;</span> <span style="color: #000066;">phase</span>=<span style="color: #ff0000;">&quot;target&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    this.shadowTree.getElementById('container').setAttribute('state', 'visible');
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/handler<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;handler</span> <span style="color: #000066;">event</span>=<span style="color: #ff0000;">&quot;DOMAttrModified&quot;</span> <span style="color: #000066;">attr-name</span>=<span style="color: #ff0000;">&quot;open&quot;</span> <span style="color: #000066;">attr-change</span>=<span style="color: #ff0000;">&quot;removal&quot;</span> <span style="color: #000066;">phase</span>=<span style="color: #ff0000;">&quot;target&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    this.shadowTree.getElementById('container').setAttribute('state', 'hidden');
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/handler<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/handlers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;implementation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   ({
     get open() { return this.boundElement.hasAttribute('open'); },
     set open(val) {
       if (val)
         this.boundElement.setAttribute('open', 'open');
       else
         this.boundElement.removeAttribute('open');
       return this.open;
     },
   })
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/implementation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;resources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    #container[state=hidden] { display: none; }
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/resources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/binding<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xbl<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>What I find interesting is how you bind this behaviour via CSS a la IE behaviours:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">details <span style="color: #00AA00;">&#123;</span> binding<span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span>details<span style="color: #6666ff;">.xml</span><span style="color: #cc00cc;">#details</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>You can also do so programatically:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'details'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  el.<span style="color: #660066;">addBinding</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;details.xml#details&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Once you have this behaviour setup, you are fully embedded in the DOM. You see &#8216;details&#8217; as a true node, rather than a processing hack that would put in divs and spans in their place. You will notice the <code>shadowTree</code> that let&#8217;s you have a full DOM behind the scenes.</p>
<p>Imagine if this spec was implemented by a series of browsers. Is there a way to have a shim that could take XBL 2 and map it to IE behaviours? That is a question for Dean Edwards ;)</p>
<p>In general, this seems like a great extension point to let us take generic behaviour and reuse it. It could be a great way to add functionality to older browsers too, just as we were able to add alpha transparency to IE via binary behaviours.</p>
<p><b>Do you see value?</b></p>
<p>Other posts on Web archelogy:</p>
<ul>
<li><a href="http://almaer.com/blog/web-archeology-java-pluglet-api">Java Pluglet API</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://almaer.com/blog/web-archeology-xml-binding-language-xbl/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
