Just to add, one of the great features of XSLTForms is that it is possible
to call arbitrary JavaScript functions from XForms expressions.
Here is an updated version of your form, with a UUID function that I found
quickly on GitHub (
https://gist.githubusercontent.com/mlhaufe/2055524/raw/439bbf7914655c681d5d0ef62ae87a9ef6ca7560/uuid.js
):
<?xml-stylesheet href="xsltforms/build/xsltforms.xsl" type="text/xsl"?>
<!--?xsltforms-options debug="yes"?-->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:jr="
http://openrosa.org/javarosa" xmlns:dummy="dummy">
<head>
<title>Hello World in XForms</title>
<model xmlns="http://www.w3.org/2002/xforms">
<instance>
<test_form1 xmlns="">
<today/>
<gender/>
<age/>
<meta>
<instanceID/>
</meta>
</test_form1>
</instance>
<bind jr:preload="date" jr:preloadParams="today"
nodeset="/test_form1/today" type="date"/>
<bind nodeset="/test_form1/gender" type="select1"/>
<bind nodeset="/test_form1/age" type="int"/>
<bind calculate="concat('uuid:', uuid())"
nodeset="/test_form1/meta/instanceID" readonly="true()"
type="string"/>
</model>
</head>
<body xmlns:xf="http://www.w3.org/2002/xforms">
<xf:select1 ref="/test_form1/gender">
<xf:label>Respondent's gender</xf:label>
<xf:item>
<xf:label>Male</xf:label>
<xf:value>male</xf:value>
</xf:item>
<xf:item>
<xf:label>Female</xf:label>
<xf:value>female</xf:value>
</xf:item>
</xf:select1>
<xf:input ref="/test_form1/age">
<xf:label>Respondent's age</xf:label>
</xf:input>
<script type="text/javascript">
<![CDATA[
//
https://gist.githubusercontent.com/mlhaufe/2055524/raw/439bbf7914655c681d5d0ef62ae87a9ef6ca7560/uuid.js
// Uses Version 4
// <
https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_.28random.29
>
// RFC 4122
var uuid = (function(){
var re = /[xy]/g;
function fn(c){
var r = Math.random()*16|0,
v = (c == 'x') ? r : (r&0x3|0x8);
return v.toString(16);
}
return function(){
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(re,fn);
}
})();
]]>
</script>
</body>
</html>
--
Tim A. Thompson
Discovery Metadata Librarian
Yale University Library
On Mon, Dec 18, 2017 at 4:43 PM, pedro winstley via Xsltforms-support <
[email protected]> wrote:
> HI Alain
>
> Thank you for your helpful reply. I have also been in touch with the
> XSLForms development team about the "select1" issue as a nodeset type, and
> the appropriate action is to correct that application. I will see what can
> be done with them. I will cover the default namespace for instances there
> too.
>
> The uuid() function would be helpful. This is included as an
> application-specific function in Orbeon, under their xxf: namespace afaik,
> and it would be a common convenience function between XSLTForms, Orbeon and
> the ODK XSLForms.
>
> I think that the XSLForms ( https://github.com/XLSForm/pyxform )
> approach could be very helpful to introduce teams gently into XForms. The
> graphical interface in PurcForms (https://github.com/dkayiwa/purcforms)
> is another helpful tool that can serve a similar purpose.
>
> Many thanks for your amazing work
>
> Peter
>
>
> On 18 December 2017 at 21:31, Alain Couthures <
> [email protected]> wrote:
>
>> Hi Peter,
>>
>> Adding support for uuid() in XSLTForms was not difficult, it will be
>> committed as soon as possible.
>>
>> Yet, "select1" is not a valid type: as a workaround, it can be defined as
>> a synonym for "string"...
>>
>> Then, there is still a namespace issue in the generated form: xmlns=""
>> has to be added to the root element of the instance.
>>
>> Finally, "form-data-post" is not yet implemented in XSLTForms but it
>> would be possible...
>>
>> What do you think?
>>
>> Alain
>>
>>
>> Le 18/12/2017 à 16:17, pedro winstley via Xsltforms-support a écrit :
>>
>> Dear colleagues
>>
>> I realise that we can use the XLSForms ( http://xlsform.org/ ) editor to
>> create XForms that will work with XSLTForms (there is going to be acronym
>> hell here), but the XSLForms automatically creates a bind for a uuid
>> element and uses a function "uuid()". How can this best be implemented in
>> XSLTForms so that I can bring in an XLSForm XForm without any editing?
>>
>> I show an illustration of XLSForms output below
>>
>> Many thanks
>>
>> Peter
>>
>> <?xml version="1.0"?>
>> <h:html xmlns="http://www.w3.org/2002/xforms" xmlns:ev="
>> http://www.w3.org/2001/xml-events" xmlns:h="http://www.w3.org/1999/xhtml"
>> xmlns:jr="http://openrosa.org/javarosa" xmlns:orx="http://openrosa.org
>> /xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>> <h:head>
>> <h:title>test_form1</h:title>
>> <model>
>> <submission action="http://xformstest.org/cgi-bin/echoinstance.sh"
>> method="form-data-post"/>
>> <instance>
>> <test_form1 id="test_form1">
>> <today/>
>> <gender/>
>> <age/>
>> <meta>
>> <instanceID/>
>> </meta>
>> </test_form1>
>> </instance>
>> <bind jr:preload="date" jr:preloadParams="today"
>> nodeset="/test_form1/today" type="date"/>
>> <bind nodeset="/test_form1/gender" type="select1"/>
>> <bind nodeset="/test_form1/age" type="int"/>
>> <bind calculate="concat('uuid:', uuid())"
>> nodeset="/test_form1/meta/instanceID" readonly="true()" type="string"/>
>> </model>
>> </h:head>
>> <h:body>
>> <select1 ref="/test_form1/gender">
>> <label>Respondent's gender</label>
>> <item>
>> <label>Male</label>
>> <value>male</value>
>> </item>
>> <item>
>> <label>Female</label>
>> <value>female</value>
>> </item>
>> </select1>
>> <input ref="/test_form1/age">
>> <label>Respondent's age</label>
>> </input>
>> </h:body>
>> </h:html>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>>
>>
>>
>> _______________________________________________
>> Xsltforms-support mailing
>> [email protected]https://lists.sourceforge.net/lists/listinfo/xsltforms-support
>>
>>
>>
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Xsltforms-support mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/xsltforms-support
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Xsltforms-support mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xsltforms-support