Thread: [Xsltforms-support] getInstanceDocument
Brought to you by:
alain-couthures
From: Mark S. <m_s...@ma...> - 2009-09-21 10:20:09
|
Hi, I have just been experimenting with XSLTForms as distributed as part of the latest eXist build. Can you tell me if there is any support, or plan to support getInstanceDocument, or any alternative mechanism for providing access to XForms instance documents and Javascript? All the best Mark |
From: COUTHURES A. <ala...@ag...> - 2009-09-22 20:26:34
|
Hi Mark, > I have just been experimenting with XSLTForms as distributed as part > of the latest eXist build. Can you tell me if there is any support, or > plan to support getInstanceDocument, or any alternative mechanism for > providing access to XForms instance documents and Javascript? > Because of your question about getInstanceDocument support, I decided to have a closer look at W3C XForms Test #4.8.1.a which is non-normative : <?xml version="1.0" encoding="ISO-8859-1"?> <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms"> <xhtml:head> <xhtml:title>4.8.1.a getInstanceDocument() method (non-normative)</xhtml:title> <xhtml:link rel="stylesheet" href="../../../driverPages/forms/TestSuite11.css" type="text/css"/> <xforms:model id="my_model1"> <xforms:instance id="my_data1"> <car> <color>blue</color> </car> </xforms:instance> </xforms:model> </xhtml:head> <xhtml:body> <xforms:group> <xforms:label class="title">4.8.1.a getInstanceDocument() method (non-normative)</xforms:label> </xforms:group> <xforms:group> <xforms:label> This test case uses Javascript to execute the getInstanceDocument() method. You may have seen a message box with the value "blue". </xforms:label> </xforms:group> <xhtml:script type="text/javascript"> var model = document.getElementById('my_model1'); var inst1 = model.getInstanceDocument('my_data1'); var my_color = inst1.getElementsByTagName('color')[0]; alert(my_color.textContent); </xhtml:script> </xhtml:body> </xhtml:html> Yes, it was already possible to manipulate instances managed by XSLTForms directly with Javascript instructions but there were no well-known function for that. So, I added, in the very latest SVN version, the ones mentioned in this test (textContent attribute having to be replaced by getTextContent()). I had to postpone the specific Javascript calls so they are executed after the generated init() function which is called from body onload. This is the modified working test : <?xml version="1.0" encoding="ISO-8859-1"?> <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms"> <xhtml:head> <xhtml:title>4.8.1.a getInstanceDocument() method (non-normative)</xhtml:title> <xhtml:link rel="stylesheet" href="../../../driverPages/forms/TestSuite11.css" type="text/css"/> <xforms:model id="my_model1"> <xforms:instance id="my_data1"> <car> <color>blue</color> </car> </xforms:instance> </xforms:model> </xhtml:head> <xhtml:body onload="f();"> <xforms:group> <xforms:label class="title">4.8.1.a getInstanceDocument() method (non-normative)</xforms:label> </xforms:group> <xforms:group> <xforms:label> This test case uses Javascript to execute the getInstanceDocument() method. You may have seen a message box with the value "blue". </xforms:label> </xforms:group> <xhtml:script type="text/javascript"> function f() { var model = document.getElementById('my_model1'); var inst1 = model.getInstanceDocument('my_data1'); var my_color = inst1.getElementsByTagName('color')[0]; alert(my_color.getTextContent()); } </xhtml:script> </xhtml:body> </xhtml:html> This is, for sure, just the minimal set of methods required for this test but I needed less than two hours to add them... ;-) XSLTForms is easy to extend ! :-) Best regards, -Alain |
From: Mark S. <m_s...@ma...> - 2009-09-23 08:56:45
|
Hi Alain, That is great, except that I grabbed the latest version (from trunk/ build, revision 223) and tried you modified version of the form without success. I am still getting an error raised by var inst1 = model.getInstanceDocument('my_data1'); What have I missed? All the best Mark On 22 Sep 2009, at 21:26, COUTHURES Alain wrote: > Hi Mark, >> I have just been experimenting with XSLTForms as distributed as >> part of the latest eXist build. Can you tell me if there is any >> support, or plan to support getInstanceDocument, or any >> alternative mechanism for providing access to XForms instance >> documents and Javascript? >> > Because of your question about getInstanceDocument support, I > decided to have a closer look at W3C XForms Test #4.8.1.a which is > non-normative : > > <?xml version="1.0" encoding="ISO-8859-1"?> > <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" > xmlns:ev="http://www.w3.org/2001/xml-events" > xmlns:xforms="http://www.w3.org/2002/xforms"> > <xhtml:head> > <xhtml:title>4.8.1.a getInstanceDocument() method (non- > normative)</xhtml:title> > <xhtml:link rel="stylesheet" href="../../../driverPages/forms/ > TestSuite11.css" type="text/css"/> > <xforms:model id="my_model1"> > <xforms:instance id="my_data1"> > <car> > <color>blue</color> > </car> > </xforms:instance> > </xforms:model> > </xhtml:head> > <xhtml:body> > <xforms:group> > <xforms:label class="title">4.8.1.a getInstanceDocument() > method (non-normative)</xforms:label> > </xforms:group> > <xforms:group> > <xforms:label> > This test case uses Javascript to execute the > getInstanceDocument() method. > You may have seen a message box with the value > "blue". > </xforms:label> > </xforms:group> > <xhtml:script type="text/javascript"> > var model = document.getElementById('my_model1'); > var inst1 = model.getInstanceDocument('my_data1'); > var my_color = inst1.getElementsByTagName('color')[0]; > alert(my_color.textContent); > </xhtml:script> > </xhtml:body> > </xhtml:html> > > Yes, it was already possible to manipulate instances managed by > XSLTForms directly with Javascript instructions but there were no > well-known function for that. So, I added, in the very latest SVN > version, the ones mentioned in this test (textContent attribute > having to be replaced by getTextContent()). I had to postpone the > specific Javascript calls so they are executed after the generated > init() function which is called from body onload. This is the > modified working test : > > <?xml version="1.0" encoding="ISO-8859-1"?> > <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" > xmlns:ev="http://www.w3.org/2001/xml-events" > xmlns:xforms="http://www.w3.org/2002/xforms"> > <xhtml:head> > <xhtml:title>4.8.1.a getInstanceDocument() method (non- > normative)</xhtml:title> > <xhtml:link rel="stylesheet" href="../../../driverPages/forms/ > TestSuite11.css" type="text/css"/> > <xforms:model id="my_model1"> > <xforms:instance id="my_data1"> > <car> > <color>blue</color> > </car> > </xforms:instance> > </xforms:model> > </xhtml:head> > <xhtml:body onload="f();"> > <xforms:group> > <xforms:label class="title">4.8.1.a getInstanceDocument() > method (non-normative)</xforms:label> > </xforms:group> > <xforms:group> > <xforms:label> > This test case uses Javascript to execute the > getInstanceDocument() method. > You may have seen a message box with the value > "blue". > </xforms:label> > </xforms:group> > <xhtml:script type="text/javascript"> > function f() { > var model = document.getElementById('my_model1'); > var inst1 = model.getInstanceDocument('my_data1'); > var my_color = inst1.getElementsByTagName('color')[0]; > alert(my_color.getTextContent()); > } > </xhtml:script> > </xhtml:body> > </xhtml:html> > > This is, for sure, just the minimal set of methods required for this > test but I needed less than two hours to add them... ;-) > > XSLTForms is easy to extend ! :-) > > Best regards, > > -Alain > > |
From: COUTHURES A. <ala...@ag...> - 2009-09-23 10:16:30
|
Hi Mark, With which browser did you test ? Didn't you forget to add the processiong instruction I didn't mention in the test form ? Cheers, -Alain > Hi Alain, > > That is great, except that I grabbed the latest version (from > trunk/build, revision 223) and tried you modified version of the form > without success. I am still getting an error raised by var inst1 = > model.getInstanceDocument('my_data1'); > > What have I missed? > > All the best > > Mark > |
From: Mark S. <m_s...@ma...> - 2009-09-23 11:40:51
|
Hi Alain, So, now you have the getInstanceDocument method, how can I modify an instance in Javascript? I have been using the Firefox plug-in's Javascript integration to replace nodesets within instances, as well as to set text values. My motivation for using Javascript to interact with XForms is that I a m using an OpenLayers map to allow users interact with instance data. All the best Mark On 22 Sep 2009, at 21:26, COUTHURES Alain wrote: > Hi Mark, >> I have just been experimenting with XSLTForms as distributed as >> part of the latest eXist build. Can you tell me if there is any >> support, or plan to support getInstanceDocument, or any >> alternative mechanism for providing access to XForms instance >> documents and Javascript? >> > Because of your question about getInstanceDocument support, I > decided to have a closer look at W3C XForms Test #4.8.1.a which is > non-normative : > > <?xml version="1.0" encoding="ISO-8859-1"?> > <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" > xmlns:ev="http://www.w3.org/2001/xml-events" > xmlns:xforms="http://www.w3.org/2002/xforms"> > <xhtml:head> > <xhtml:title>4.8.1.a getInstanceDocument() method (non- > normative)</xhtml:title> > <xhtml:link rel="stylesheet" href="../../../driverPages/forms/ > TestSuite11.css" type="text/css"/> > <xforms:model id="my_model1"> > <xforms:instance id="my_data1"> > <car> > <color>blue</color> > </car> > </xforms:instance> > </xforms:model> > </xhtml:head> > <xhtml:body> > <xforms:group> > <xforms:label class="title">4.8.1.a getInstanceDocument() > method (non-normative)</xforms:label> > </xforms:group> > <xforms:group> > <xforms:label> > This test case uses Javascript to execute the > getInstanceDocument() method. > You may have seen a message box with the value > "blue". > </xforms:label> > </xforms:group> > <xhtml:script type="text/javascript"> > var model = document.getElementById('my_model1'); > var inst1 = model.getInstanceDocument('my_data1'); > var my_color = inst1.getElementsByTagName('color')[0]; > alert(my_color.textContent); > </xhtml:script> > </xhtml:body> > </xhtml:html> > > Yes, it was already possible to manipulate instances managed by > XSLTForms directly with Javascript instructions but there were no > well-known function for that. So, I added, in the very latest SVN > version, the ones mentioned in this test (textContent attribute > having to be replaced by getTextContent()). I had to postpone the > specific Javascript calls so they are executed after the generated > init() function which is called from body onload. This is the > modified working test : > > <?xml version="1.0" encoding="ISO-8859-1"?> > <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" > xmlns:ev="http://www.w3.org/2001/xml-events" > xmlns:xforms="http://www.w3.org/2002/xforms"> > <xhtml:head> > <xhtml:title>4.8.1.a getInstanceDocument() method (non- > normative)</xhtml:title> > <xhtml:link rel="stylesheet" href="../../../driverPages/forms/ > TestSuite11.css" type="text/css"/> > <xforms:model id="my_model1"> > <xforms:instance id="my_data1"> > <car> > <color>blue</color> > </car> > </xforms:instance> > </xforms:model> > </xhtml:head> > <xhtml:body onload="f();"> > <xforms:group> > <xforms:label class="title">4.8.1.a getInstanceDocument() > method (non-normative)</xforms:label> > </xforms:group> > <xforms:group> > <xforms:label> > This test case uses Javascript to execute the > getInstanceDocument() method. > You may have seen a message box with the value > "blue". > </xforms:label> > </xforms:group> > <xhtml:script type="text/javascript"> > function f() { > var model = document.getElementById('my_model1'); > var inst1 = model.getInstanceDocument('my_data1'); > var my_color = inst1.getElementsByTagName('color')[0]; > alert(my_color.getTextContent()); > } > </xhtml:script> > </xhtml:body> > </xhtml:html> > > This is, for sure, just the minimal set of methods required for this > test but I needed less than two hours to add them... ;-) > > XSLTForms is easy to extend ! :-) > > Best regards, > > -Alain > > |
From: COUTHURES A. <ala...@ag...> - 2009-09-23 11:56:54
|
Hi Mark, Javascript interacting with XSLTForms is an important feature and I always try to be compatible with the Mozilla XForms extension. As you already know, the corresponding methods are not yet present in XSLTForms. Could you please list me the methods/attributes you need ? Are you in a hurry about them ? Cheers, -Alain Mark Seaborne a écrit : > Hi Alain, > > So, now you have the getInstanceDocument method, how can I modify an > instance in Javascript? > > I have been using the Firefox plug-in's Javascript integration to > replace nodesets within instances, as well as to set text values. > > My motivation for using Javascript to interact with XForms is that I a > m using an OpenLayers map to allow users interact with instance data. > > All the best > > Mark > |
From: Mark S. <m_s...@ma...> - 2009-10-01 07:02:46
|
Hi Alain, Well, rebuild, recalculate, revalidate and refresh methods on model would be really nice, obviously. Individual instances just needs to be accessible as a bog-standard XML document objects. It would be nice to see this functionality sooner rather than later if I am to be able to evaluate XSLTForms seriously for this project. The work that you and the guys working on eXist 1.4 have done has already helped me a great deal. All the best Mark On 23 Sep 2009, at 12:56, COUTHURES Alain wrote: > Hi Mark, > > Javascript interacting with XSLTForms is an important feature and I > always try to be compatible with the Mozilla XForms extension. > > As you already know, the corresponding methods are not yet present > in XSLTForms. Could you please list me the methods/attributes you > need ? > > Are you in a hurry about them ? > > Cheers, > > -Alain > > Mark Seaborne a écrit : >> Hi Alain, >> >> So, now you have the getInstanceDocument method, how can I modify >> an instance in Javascript? >> >> I have been using the Firefox plug-in's Javascript integration to >> replace nodesets within instances, as well as to set text values. >> >> My motivation for using Javascript to interact with XForms is that >> I a m using an OpenLayers map to allow users interact with instance >> data. >> >> All the best >> >> Mark >> > |
From: COUTHURES A. <ala...@ag...> - 2009-10-01 19:05:29
|
Hi Mark, > Well, rebuild, recalculate, revalidate and refresh methods on model > would be really nice, obviously. I just added these methods! > > Individual instances just needs to be accessible as a bog-standard XML > document objects. Here is an extract from the wiki developer documentation of XSLTForms : XNode Class * constructor function : initializes specific properties * *getElementsByTagName* method : gets an array of all elements with a given tag name for this XNode object * *getTextContent* method : gets the text context for this XNode object * *appendChild* method : appends a new child at this XNode object * *replaceChild* method : replaces a child of this XNode object * *insertBefore* method : inserts a child before another one of this XNode object * *removeChild* method : removes a child of this XNode object * *setAttributeNS* method : sets an attribute of this XNode object after creating it if necessary. "xsd:type" is interpreted to associate the corresponding type to this XNode object. * *getAttributeNS* method : gets the value of an attribute of this XNode object * *removeAttributeNS* method : removes an attribute of this XNode object * *cloneNode* method : clones this XNode object * *init* function : sets properties of this XNode object * *recycle* function : clears every properties of this XNode object and of its child XNode objects * *create* function : reuses a previously recycled XNode object or creates a new XNode object Cheers, -Alain |
From: Mark S. <m_s...@ma...> - 2009-10-02 07:21:38
|
Hi Alain, Cool - I will get the latest version and try it out. Thanks for responding so quickly - it is much appreciated. All the best Mark On 1 Oct 2009, at 20:04, COUTHURES Alain wrote: > Hi Mark, >> >> Well, rebuild, recalculate, revalidate and refresh methods on model >> would be really nice, obviously. > I just added these methods! >> >> Individual instances just needs to be accessible as a bog-standard >> XML document objects. > Here is an extract from the wiki developer documentation of > XSLTForms : > XNode Class > > constructor function : initializes specific properties > getElementsByTagName method : gets an array of all elements with a > given tag name for this XNode object > getTextContent method : gets the text context for this XNode object > appendChild method : appends a new child at this XNode object > replaceChild method : replaces a child of this XNode object > insertBefore method : inserts a child before another one of this > XNode object > removeChild method : removes a child of this XNode object > setAttributeNS method : sets an attribute of this XNode object after > creating it if necessary. "xsd:type" is interpreted to associate the > corresponding type to this XNode object. > getAttributeNS method : gets the value of an attribute of this XNode > object > removeAttributeNS method : removes an attribute of this XNode object > cloneNode method : clones this XNode object > init function : sets properties of this XNode object > recycle function : clears every properties of this XNode object and > of its child XNode objects > create function : reuses a previously recycled XNode object or > creates a new XNode object > Cheers, > > -Alain |
From: Mark S. <m_s...@ma...> - 2009-10-06 13:55:33
|
Hi Alain, Just had time to begin experimenting with the new methods you added. I have tried: <?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xf="http://www.w3.org/2002/xforms"> <head> <title>4.8.1.a getInstanceDocument() method (non-normative)</ title> <xf:model id="my_model1"> <xf:instance id="my_data1"> <car xmlns=""> <color>navy blue</color> <new-color>pink</new-color> </car> </xf:instance> </xf:model> </head> <body onload="f();"> <div id="xformControl"> <span> <input type="checkbox" onclick="$('console').style.display = this.checked? 'block' : 'none';" checked="checked"/> Debug </span> </div> <xf:group> <xf:label class="title">4.8.1.a getInstanceDocument() method (non-normative)</xf:label> </xf:group> <xf:group> <xf:label> This test case uses Javascript to execute the getInstanceDocument() method. You may have seen a message box with the value "<xf:output value="color"/>". </xf:label> <xf:input ref="color"> <xf:label>Colour</xf:label> </xf:input> </xf:group> <script type="text/javascript"> function f() { try { var model = document.getElementById('my_model1'); var inst1 = model.getInstanceDocument('my_data1'); var my_color = inst1.getElementsByTagName('color')[0]; var new_color = inst1.getElementsByTagName('new-color')[0]; var old_node = my_color.firstChild var new_node = new_color.firstChild; alert(my_color.getTextContent()); my_color.removeChild(old_node); my_color.appendChild(new_node); alert(my_color.getTextContent()); model.rebuild(); model.recalculate(); model.revalidate(); model.refresh(); } catch(DOMException) { alert('DOMException'); } } </script> <div id="console" style="display: block"/> </body> </html> which attempts to replace one text value with another for the color element. The values I get in the alerts suggest that removeChild and appendChild work, but the input bound to color continues to display the old value. I also notice from the debug that the events raised by rebuild, recalculate, revalidate and refresh don't look right. I get: Dispatching event xforms-recalculate on <SPAN class="xforms-model" id="my_model1"/> 0 -> Dispatching event xforms-revalidate on <SPAN class="xforms-model" id="my_model1"/> 2 -> Dispatching event xforms-refresh on <SPAN class="xforms-model" id="my_model1"/> 0 -> Dispatching event xforms-revalidate on <SPAN class="xforms-model" id="my_model1"/> 1 -> Dispatching event xforms-refresh on <SPAN class="xforms-model" id="my_model1"/> 0 -> Dispatching event xforms-refresh on <SPAN class="xforms-model" id="my_model1"/> I am using build 241. Here's hoping that I am just doing something wrong :-) All the best Mark On 1 Oct 2009, at 20:04, COUTHURES Alain wrote: > Hi Mark, >> >> Well, rebuild, recalculate, revalidate and refresh methods on model >> would be really nice, obviously. > I just added these methods! >> >> Individual instances just needs to be accessible as a bog-standard >> XML document objects. > Here is an extract from the wiki developer documentation of > XSLTForms : > XNode Class > > constructor function : initializes specific properties > getElementsByTagName method : gets an array of all elements with a > given tag name for this XNode object > getTextContent method : gets the text context for this XNode object > appendChild method : appends a new child at this XNode object > replaceChild method : replaces a child of this XNode object > insertBefore method : inserts a child before another one of this > XNode object > removeChild method : removes a child of this XNode object > setAttributeNS method : sets an attribute of this XNode object after > creating it if necessary. "xsd:type" is interpreted to associate the > corresponding type to this XNode object. > getAttributeNS method : gets the value of an attribute of this XNode > object > removeAttributeNS method : removes an attribute of this XNode object > cloneNode method : clones this XNode object > init function : sets properties of this XNode object > recycle function : clears every properties of this XNode object and > of its child XNode objects > create function : reuses a previously recycled XNode object or > creates a new XNode object > Cheers, > > -Alain |
From: COUTHURES A. <ala...@ag...> - 2009-10-07 21:42:20
|
Hi Mark, I can propose to replace > model.rebuild(); > model.recalculate(); > model.revalidate(); > model.refresh(); with model.xfElement.setRebuilded(true); xforms.addChange(model.xfElement); xforms.refresh(); Those instructions are the ones performed at a reset just after resetting each instance. Is it what you wanted ? Cheers, -Alain |
From: COUTHURES A. <ala...@ag...> - 2009-10-10 09:24:28
|
Hello, XSLTForms Beta 2 release is now downloadable at http://sourceforge.net/projects/xsltforms/files/xsltforms/Beta%202/xsltforms-beta2.zip/download ! There are now much more passed W3C Tests (you can calculate the coverage % if you like but my point of view is that some tests are more important than others ;-) ). Tests have been performed with IE6, IE7, FF2, FF3, Opera 10, Safari and Chrome. I also added some server pages : one to activate the "save as" dialog, one to display an instance using XSLT (using show="new" with xf:submission). Debug display can be activated with a specific processing-instruction. Submitted internationalization messages.properties files have been integrated. Thank you for your feedbacks! -Alain |