[Xsltforms-support] confusion over instance() function
Brought to you by:
alain-couthures
From: Stephen C. <Ste...@ut...> - 2009-07-31 08:46:08
|
Hello, I am still working away and developing my CRUD application with XSLForms, the only major issue so far is my forms won't work in IE 6.0. I think there is a javascript issue that I've not debugged as yet. However I have a bit of confusion over the instance() function, in XSLForms it returns the root node of the instance, if this is the specification then that is fine but it seems a bit counter-intuitive as '/' and '//' have different meanings in XPath. In the following example the first 2 'xf:output' elements work, the third is invalid, the fourth is valid. <?xml version="1.0" encoding="iso-8859-1"?> <?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?> <html menu="samples" xmlns="http://www.w3.org/1999/xhtml" xmlns:sample="http://www.agencexml.com/sample" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:ajx="http://www.ajaxforms.net/2006/ajx"> <head> <xf:model> <xf:instance id="nums"> <sample:data> <sample:item>2</sample:item> <sample:item>5</sample:item> <sample:item>7</sample:item> </sample:data> </xf:instance> <xf:instance id="letters"> <sample:data>abcdefg</sample:data> </xf:instance> </xf:model> </head> <body> <h3>XPath Functions</h3> <div id="xformControl"> <span> <input type="checkbox" onclick="$('console').style.display = this.checked? 'block' : 'none';" checked="checked"/> Debug </span> </div> <xf:output value="instance('nums')/sample:item[last()]"> <xf:label>number <b>last</b>()</xf:label> </xf:output> <xf:output value="sum(instance('nums')/sample:item)"> <xf:label>number <b>sum a</b></xf:label> </xf:output> <xf:output value="sum(instance('nums')/sample:data/sample:item)"> <xf:label>number <b>sum b</b></xf:label> </xf:output> <xf:output value="instance('letters')"> <xf:label>letters</xf:label> </xf:output> <div id="console"/> </body> </html> If this is correct behaviour then the example from http://www.w3schools.com/xforms/xforms_functions.asp(as below) is wrong. **** instance(string) An XForms Model can contain more than one instance. This function returns the root node of the specified instance data <xforms:instance id="orderform"> <firstName>John</firstName> </xforms:instance> ref="instance('orderform')/firstName" This example returns a node-set that consists of the firstName element node from the instance named "orderform" **** As a matter of general interest, do you know of many people who have used XSLForms in production as yet? Thanks for your assistance. -- Regards Stephen Cameron Data Programmer Integrated Marine Observing System (IMOS) eMarine Information Infrastructure Project University of Tasmania, Private Bag 21, Hobart, TAS 7001, Australia Tel: +61 3 6226 8507 Fax: +61 3 6226 2997 Email: ste...@ut... URL: http://www.imos.org.au/eMII.html |