Re: [Xsltforms-support] getInstanceDocument
Brought to you by:
alain-couthures
|
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
>
>
|