JSON API call from XForms

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

JSON API call from XForms

Alain COUTHURES
Hello,

I have recently added JSON API support in XSLTForms
(http://www.agencexml.com/xsltforms) because of the cross domain
restriction.

The GET method with a query string allows to activate methods of such
APIs. For cross domain workaround, an extra parameter, usually named
"callback", will wrap the JSON results in a Javascript function call:
adding a script element with the corresponding src attribute will call
the callback function with the JSON structure.

Just to see how it might work, I added a test in XSLTForms whether the
submission is a cross domain one or not. If it is, as a default mode, it
considers it's a JSON API call and automatically adds the callback
parameter with the name of the function which will be able to convert a
JSON structure into an XML instance. Serialization is set to "none" in
this case.

Here is a link to a demo:
http://www.agencexml.com/jsoncallback/wikipediasearch.xml

Just look at the source to see the XForms document.

The JSON to XML translation was not very easy to write because JSON
arrays might appear without any name and I decided to create elements
named "array" and "item" as a workaround. I also had to add a root
element, named "root" of course ;-)

Thank you for your feedbacks!

Best regards,

Alain Couthures
<agenceXML>
http://www.agencexml.com
Bordeaux, France

Reply | Threaded
Open this post in threaded view
|

Re: JSON API call from XForms

lorenzo de tomasi
I think that the input element with suggestions taken from a
controlled dictionary (or onthology), as the demo you have posted,
should be a new input element type for xForms. It can be very useful
in forms for the description of user generated contents, like tags on
Flickr.
What do you think? Can we suggest it for the next xForms version?

I have also noticed that xForms lacks of a round() function, to round
decimal numers to n decimal places.

On Fri, Feb 5, 2010 at 5:32 PM, COUTHURES Alain
<[hidden email]> wrote:
> Here is a link to a demo:
> http://www.agencexml.com/jsoncallback/wikipediasearch.xml

--
Salta la crisi! Investi in comunicazione <http://isotype.org/?lang=it>
--
Lorenzo De Tomasi
ISOTYPE.org | comunica la qualità
Coordinatore
Designer della comunicazione

^^^^^^^^^^
Rispetta il tuo ambiente, pensa prima di stampare questa e-mail. Grazie.
Please consider the environment before printing this email. Thank you.

Reply | Threaded
Open this post in threaded view
|

Re: JSON API call from XForms

Erik Bruchez
About functions: XPath 2.0 has a round() function. The working group
is working on integrating XPath 2.0 into XForms so that XForms can
benefit not only from the improved capabilities of XPath 2.0 as an
expression language but also from its much better function library.

-Erik

On Sat, Feb 6, 2010 at 1:16 AM, Lorenzo De Tomasi
<[hidden email]> wrote:

> I think that the input element with suggestions taken from a
> controlled dictionary (or onthology), as the demo you have posted,
> should be a new input element type for xForms. It can be very useful
> in forms for the description of user generated contents, like tags on
> Flickr.
> What do you think? Can we suggest it for the next xForms version?
>
> I have also noticed that xForms lacks of a round() function, to round
> decimal numers to n decimal places.
>
> On Fri, Feb 5, 2010 at 5:32 PM, COUTHURES Alain
> <[hidden email]> wrote:
>> Here is a link to a demo:
>> http://www.agencexml.com/jsoncallback/wikipediasearch.xml
>
> --
> Salta la crisi! Investi in comunicazione <http://isotype.org/?lang=it>
> --
> Lorenzo De Tomasi
> ISOTYPE.org | comunica la qualità
> Coordinatore
> Designer della comunicazione
>
> ^^^^^^^^^^
> Rispetta il tuo ambiente, pensa prima di stampare questa e-mail. Grazie.
> Please consider the environment before printing this email. Thank you.
>
>