Thread: [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 |
From: COUTHURES A. <ala...@ag...> - 2009-07-31 09:03:38
|
Hello Stephen, > 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. > The XForms 1.1 proposed recommendation says : "this function returns a node-set containing just the root element node (also called the document element node) of the referenced instance data" (AJAXForms was wrong returning the document node (/)...). > 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" > > **** > > Also in the W3C proposed recommendation : For instance data corresponding to this XML: <xforms:instance xmlns="" id="orderform"> <orderForm> <shipTo> <firstName>John</firstName> </shipTo> </orderForm> </xforms:instance> The following expression selects the |firstName| node. Note that the |instance| function returns an element node, effectively replacing the leftmost location step from the path: ref="instance('orderform')/shipTo/firstName" > As a matter of general interest, do you know of many people who have > used XSLForms in production as yet? > Mark Logic has developed an "Application Builder" application delivered with Mark Logic Server 4.1. All around the world, people are downloading and testing XSLTForms but, because it's free, I don't know who is using it in production. XForms is yet an emerging technology to be used in the promising XRX architecture. EMC has now its own engine named Formula but it seems that IBM is not working anymore on Ubiquity XForms project and I would not be surprised if this project is abandoned soon... XSLTForms is still the most mature of its kind !! Regards, -Alain |
From: COUTHURES A. <ala...@ag...> - 2009-07-31 09:39:26
|
I forgot to say that I have recently developed a small application for XBRL instances editing and rendering which is, of course, using XSLTForms. At this occasion, I designed the experimental formula extension allowing to enter, for example, "13+29" instead of "42" in numeric input fields. There are not yet many users for this application... but it might be shown to french financial students next year ! -Alain |