Joerg Heinicke wrote:
On 25.04.2006 11:56, Reinhard Poetz wrote:*cocoon-cforms-xul-user-interfaceI think Jörg can comment on this much better than I but IIRC a talk with him at the GT, that there are conceptual mismatches that lead to problems. WDYT Jörg?There was no problem with a XUL interface in general, but with the built-in XUL templating engine. Claas Thiele (cc-ing him) started an XSLT-based templating engine and was quite successful with it AFAIR. But there has never been anything released. Maybe he can tell more about it or release it so that anyone can continue this work.Jörg
as attachments a prototype of the xsl template can be found.The idea is quite simple. The form data coming to clients browser is transformed with an xsl stylesheet to a DOM fragment and than inserted in the page DOM. The whole thing is encapsulated in a XBL element.
By the way, Firefow2.0 will have a new templating implemented, perhaps worthwhile to check this as well.
Claas
XSL templates for XUL ===================== Why? ---- XUL has its own template mechanism based on RDF. This template mechanism has some disadvantages: - RDF is not a very efficient format - sometimes it is a hard job to transform common datastructures to RDF via XSL - XUL-templating is propriatary and hard to understand (even harder than XSL) - XUL-templates have no logging or debugging facility - XUL-templates are badly maintained - there are some major bugs still open since years Goals ----- - An XML based format sending form data to the client should be found. - This format will be markup independent - should be usable with HTML and other markups too without any change on the server side. - XSL will be used to populate the markup based on the form data. This markup should be widget dependent, not depending on the page. The template is delivered by the widget provider once. - It should be still possible to overwrite or add functionality to the template utilizing the standard import/include mechanisms of XSL. Why Cocoons AJAX implementation is not reused? ---------------------------------------------- Current AJAX implementation is made for easy switching between AJAX normal HTML forms and ideally fitting in CForms. This implicates some disadvantages: - The whole form is filled, unchanged data are filtered out afterwards. This is inefficient for low performance backends. (But we have to deal with events between widgets!) - The XML format sent to the client relies on the markup (HTML) - Markup has to be tranferred to the client together with the form data because AJAX is simply replacing nodes in the DOM. Architecture ------------ On a containing element, the template element, is a XSL styleshhet bound. Calling a mehtod update(url) on this element will load the form data from the given url and transforms this data with the XSL stylesheet. The resulting DOM fragment replaces the child nodes of the template element. Implementation -------------- For XUL the template element is implemented using XBL. Files: - form.xml The form data initially loaded via page load - form2.xml Form data loaded after submit button was pressed - README.txt This file itself - template.xml The xsl stylesheet transforming the form data to the DOM fragment to be placed in the page DOM - test.xul XUL page demonstrating the templating mechanism - xulajax.css CSS file realising the XBL binding - xulajax-binding.xml The XBL file
<form> <message>This is the initial value loaded by the x-template.</message> </form>
<form> <message>This is another value loaded by x-template after submitting the form.</message> </form>
<?xml version="1.0"?>
<!--
Copyright 1999-2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<xsl:template match="/">
<textbox value="{form/message}" flex="1"/>
</xsl:template>
</xsl:stylesheet>
test.xul
Description: application/vnd.mozilla.xul
<?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="x-template"> <content/> <implementation> <field readonly="true" name="data"/> <property name="template"> <setter> return this.setAttribute("template", val); </setter> <getter> return this.getAttribute("template"); </getter> </property> <method name="update"> <parameter name="url"/> <body> <![CDATA[ this.request.open("GET", url, false); this.request.send(null); this.data = this.request.responseXML; var newFragment = this.processor.transformToFragment(this.data, window.document); var childs = this.childNodes; for(i = 0; i < childs.length; i++) { this.removeChild(childs[i]); } this.appendChild(newFragment, this); ]]> </body> </method> <property name="url"> <setter> return this.setAttribute("url", val); </setter> <getter> return this.getAttribute("url"); </getter> </property> <constructor> <![CDATA[ this.processor = new XSLTProcessor(); this.request = new XMLHttpRequest(); this.processor = new XSLTProcessor(); this.request.open("GET", this.template, false); this.request.send(null); this.processor.importStylesheet(this.request.responseXML); this.update(this.url); ]]> </constructor> </implementation> </binding> </bindings>
.x-template {
-moz-binding: url('xulajax-binding.xml#x-template');
}
