Changes

Jump to: navigation, search

XUL:Xul Templates

1,614 bytes removed, 21:31, 21 December 2004
Comments Sean McMurray
=== Comments Sean McMurray ===
I have a small xbl that is fairly rough, but allows written an XBL to me use do inline xsl XSL templates.It is less than 100 lines of xblThe XBL has two bindings: one for datasources, one for templates.
Right now it works against xml datasources. The datasource query can be affected by content outside the template. I think it could be modified to work with RDF, or to be extensible. But it would take more talent than I have. My XBL has two binding: one for datasources, one for templates.  '''Templates''' You place a template in your document like this: <myTemplate style="-moz-binding: url('myTemplateIdea.xbl#xslTemplate');" datasource="list;ofincluding;datasourcesmyDS">
<xsl:stylesheet ...../>
</myTemplatexslTemplateTemplates can be bound to one or more datasources. The datasources must be defined elsewhere within the document.  '''Datasources''' You place an datasource in your document like this: <myElement id="myDS" href="uri://to/a/datasource" style="-moz-binding: url('myTemplateIdea.xbl#datasource');"/> The href attribute points to the location of the data. This href is used to post an XMLHttpRequest. Datasources can also have a "request" attribute, the contents of which are included in the HTTP Post. Datasource elements can also contain js code that is invoked before the HTTP Post. This is useful for manipulating the href or request attributes. For example: <myElement id="myDS" ...> <![CDATA[ if(document.getElementById("someotherelement").value=="Just what I want") this.request="someparam=whateverIwant"; ]]> </myElement> The datasource also acts as a cache. It stores the response to the HTTP Post in an xbl property. Whenever that property is changed, all templates bound to the datasource are re-transformed.
<xmlDataSource id="myDS" href="uri://to/a/datasource" />
I think that my crude little XBL could be made to work for RDFFor more, SOAP, XMLRPC, or whatever. You could have a different XBL for each type of datasource. And with work from the geniuses around here, it could be cleaned up a lot.please see [[XUL Talk:Xul Templates]]
6
edits

Navigation menu