Search code examples
orbeon

Orbeon Forms: Split Text into Control Fields


We are pasting the following text into a Plain Text Area control:

{ "FIELD1":VALUE1, "FIELD2":VALUE2, "FIELD3":VALUE3, "FIELD4":VALUE4 }

Then we need to unpack this data into separate fields within the form.

How can we achieve this?

Many thanks in advance.

PeteA


Solution

  • If the user-entered value is in JSON format, you can also use the xxf:json-to-xml() function, which makes this both easier and more robust.

    See the function in action

    For reference:

    • The two fields to the right of the text area use the expressions xxf:json-to-xml($json)/json/author and xxf:json-to-xml($json)/json/date.
    • The source for this form is available here.