0

I'm using XSLTforms on exist-db server and I'm trying to sort the instance. Here is an example of the model:

<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>
    <xf:model>
        <xf:instance xmlns="" id="default">
            <data>
                <x>
                    <a>B</a>
                    <a>C</a>
                    <a>A</a>
                </x>
            </data>
        </xf:instance>
    </xf:model>
</head>

Is it possible to sort somehow the elements in xf:repeat in order to get such a result:

  • A
  • B
  • C

I've tried using this examples, but unfortunately they don't work when I copy them in my project:

https://github.com/AlainCouthures/xsltforms/blob/master/testsuite/xforms-examples/03-output/sorting/sort.xhtml

https://github.com/AlainCouthures/xsltforms/blob/master/testsuite/xforms-examples/13-javascript/xslt-sort.xhtml

I'm new to xforms and I can't figure out why these examples don't work, so I would be very grateful if someone could give me a working example or point me to the right way to sort data in xsltforms.

Thank you in advance!

nassoo
  • 59
  • 1
  • 7

1 Answers1

2

Unfortunately, there is nothing about sorting data in XForms specifications and these examples, using XSLT as a workaround, are actually not fully supported by XSLTForms at the JSON API level.

To run this with XSLTForms, you should replace:

instanceElement.parentNode.rebuild();
instanceElement.parentNode.recalculate();
instanceElement.parentNode.revalidate();
instanceElement.parentNode.refresh();

by:

XsltForms_globals.addChange(instanceElement.parentNode.id);
XsltForms_xmlevents.dispatch(instanceElement.parentNode, "xforms-rebuild");
XsltForms_globals.refresh();
Alain Couthures
  • 1,488
  • 9
  • 5