Alternate Hub Proposal Using XML Namespaces

From MemberWiki

Jump to: navigation, search

Contents

Introduction

This page recasts the Tibco/Dojo proposal, Tibco Dojo Proposal Toolkit Loading, Markup Mixing, using different XML markup in a manner that attempts to channel W3C vision about XML namespaces but still achieve a result that would work in legacy HTML4 browsers.

Quick background

The Tibco/Dojo proposal shows an example with the following markup:

<oa-embed oa-handler-for="dojo.widget.getParser().createComponents(frag)"
          oa-src="http://url/to/xdomain/dojo/installation/src"
          oa-id="dojo"
          oa-assert="dojo.widget.FishEye"
          id="uniqueHtmlDomId">
  <div class="outerbar">
    <div class="dojo-FisheyeList" dojo:itemWidth="50" >
      <div class="dojo-FisheyeListItem"></div>
      <div class="dojo-FisheyeListItem"></div>
      <div class="dojo-FisheyeListItem"></div>
    </div>
  </div>
</oa-embed>

<script language="JavaScript"
        src=" http://url/to/xdomain/dojo/installation/src"/>

where:

  • oa-id is a unique identifier for a particular toolkit
  • oa-src is the URL for loading the given toolkit

An alternative markup approach leveraging XML namespaces

Here is an attempt to channel W3C approaches, including XML namespaces, while still achieving a result that would work in legacy HTML4 browsers.

Toolkit identification

The unique identifiers for a particular toolkit could leverage the prefix feature used with XML namespaces and identification of toolkits could happen with the html:head element. For example:

<html
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:oa="http://www.openajaxalliance.org"
  xmlns:foo="http://www.foo-toolkit.org"
  xmlns:bar="http://www.bar-toolkit.org" >
<head>
<!-- All OpenAjax-compatible web pages would have to use a JavaScript
  library that implemented the feature set we define for our hub.
  The hub would have to be listed in the html:head before any references
  to any OpenAjax-compatible toolkits. -->
<script src="...URL to JavaScript for OpenAjax hub..." />

<!-- Each OpenAjax-compatible toolkit typically would load its bootstrapping
  JavaScript logic within the html:head after the OpenAjax hub were loaded. 
  The initialization routines for the bootstrapping JavaScript would register
  the same namespace prefix as was defined in the root element (e.g., "foo" and "bar").-->
<script src="...URL to bootstrap JavaScript for foo-toolkit" />
<script src="...URL to bootstrap JavaScript for bar-toolkit" />

</head>

Mixing Markup from Different Toolkits

The Tibco/Dojo proposal defines a new element, <oa-embed>, which acts as a "foreignObject" container to define sections of the document for handling by different toolkits. The <oa-embed> approach has at least one disadvantage: verbosity. If there are lots of small custom elements from toolkit B embedded within toolkit A, then there are going to be a lot of <oa-embed> elements.

The alternative approach is to define a standard OpenAjax attribute, such as oa:type, which can be included on any element, HTML or custom, which indicates both the toolkit which should handle this element and the type of widget which the toolkit should provide. Such an approach would make it unnecessary to introduce a new container element such as <oa-embed>. Here is an example which puts oa:type on html:div elements:

<div oa:type="foo:ButtonBar" >
  <div oa:type="bar:FancyButton" >Button label</div>
</div>

Here is another example that shows how things would work with custom elements:

<foo:ButtonBar>
  <bar:FancyButton>Button label</bar:FancyButton>
</foo:ButtonBar>


The idea is that the OpenAjax hub would do a one-time traversal of the document tree searching for all elements which have either an oa:type attribute or are particular tagnames. For each such element, it would invoke an appropriate callback JavaScript function that was registered at toolkit loading time.