Tuesday, 8 March 2011

More on standards for presentation layer

Encouraged by the steps that have been made with SVG, I turned for another look at XFORMS, a specification that I thought had some promise a few years back. Sadly, native browser support has not miraculously appeared and requiring browser plugins or extensions is not going to sit well with corporate IT.
With the increasing power available in the browser engine, javascript solutions are now practical. XSLTForms is a great piece of work and provides cross-browser support through the standard XSL transform approach.
So, for fans of declarative language solutions,  the next challenge is to mix SVG with XFORMS. The wiki here shows a starting point but your milage may differ when you try this. My effort is here and shows some limitation in the size of image in chrome and firefox 4.
The simplistic view is that we should be able to bind the attributes/properties that describe the graphic elements in SVG to instance data in the XFORMS representation.
Starting with a simple svg element:
 <circle r="50" cx="100" cy="100" fill="grey"/>
We could manipulate the colour by including the SVG as instance data :
<xf:model> <xf:instance id="inlinesvg" src="svg/simple.svg" /> </xf:model>

and then referencing the fill parameter in an XFORMS element:
<xf:input id="myInput" ref="//svg:circle@fill"/>

I am glad to see that this actually works for me in Chrome and IE8! Cross-browser SVG is relatively new in XSLTForms so there are some wrinkles to be ironed out. I suspect that there are improvements that could be made to my simple example here as the last serious coding I did was in Fortran 4.