Hello,
I currently am trying to sort a list of objects inside an instance with the xxf:sort function to sort the list based off a date inside the objects. I have the following data (code) <xf:instance> <activityDataWrapper> <activityDataList> <createdOn>2019-07-30T10:24:55+10:00</createdOn> <id>63</id> <info> <documentationQueryInfo> <id>63</id> <request>My Request 1</request> <response>test</response> </documentationQueryInfo> <id>63</id> <requestor>joeladmin</requestor> <responder>john</responder> </info> <state>Responded</state> <type>DocumentQuery</type> </activityDataList> <activityDataList> <createdOn>2019-07-30T13:30:43+10:00</createdOn> <id>65</id> <info> <documentationQueryInfo> <id>65</id> <request>hello</request> <response>sdfsdfsfsdfsdf</response> </documentationQueryInfo> <id>65</id> <requestor>joeladmin</requestor> <responder>CodingUser</responder> </info> <state>Responded</state> <type>DocumentQuery</type> </activityDataList> <activityDataList> <createdOn>2019-07-30T13:05:09+10:00</createdOn> <id>64</id> <info> <documentationQueryInfo> <id>64</id> <request>temp</request> <response>cooli</response> </documentationQueryInfo> <id>64</id> <requestor>joeladmin</requestor> <responder>john</responder> </info> <state>Responded</state> <type>DocumentQuery</type> </activityDataList> </activityDataWrapper> </xf:instance> (code) I am trying to sort this list of activityDataList entries by the createdOn field which is a date. I am trying to use the following code to sort the list (code) <xf:action ev:event="xforms-ready"> <xf:itemset ref="xxf:sort(instance(), activityDataList/createdOn, 'dateTime', 'ascending')"/> </xf:action> (code) Following https://doc.orbeon.com/xforms/xpath/extension-functions/extension-xml#xxf-sort however I am not getting the desired result. The result I am looking for the the activityDataList to be sorted into Ascending order. Any Idea to get my desired result? Cheers, Joel. -- Sent from: http://discuss.orbeon.com/ -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1564464669198-0.post%40n4.nabble.com. |
This post was updated on .
So an Update on this...
I have managed to get this working on a different field, I am currently sorting on type with the following. <xf:insert context="instance()" origin="xxf:sort(instance()/activityDataList, type, 'text', 'ascending')"/> however I still cannot get the date working correctly with <xf:insert context="instance()" origin="xxf:sort(instance()/activityDataList, createdOn, 'dateTime', 'ascending')"/> What am I missing here? Cheers, Joel. -- Sent from: http://discuss.orbeon.com/ -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to orbeon+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1564546877307-0.post%40n4.nabble.com. |
Administrator
|
Hi Joel,
I tried the exact same expression you had :), and got the error: data-type on xsl:sort must be 'text' or 'number' But if the timezone is the same on all your dates, using `text` works. Also, the second argument is XPath but must be passed as a string. I will which the documentation, which incorrectly says this must return an `item()`. This gives us: <xf:action event="xforms-ready"> <xf:insert ref="instance()" origin=" xxf:sort( instance(), 'activityDataList/createdOn', 'text', 'ascending' )"/> </xf:action> You'll let me know if this works for you. ‑Alex ----- -- Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet -- Sent from: http://discuss.orbeon.com/ -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1564664403970-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Administrator
|
Hi Joel,
Actually, my bad, the code should be: <xf:insert ref="instance()" origin=" xf:element('activityDataWrapper', xxf:sort( instance()/activityDataList, createdOn, 'text', 'ascending' ) ) "/> You'll let me know if this works for you this time! And here is the source of a full example: view.xhtml <http://discuss.orbeon.com/file/t119778/view.xhtml> ‑Alex ----- -- Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet -- Sent from: http://discuss.orbeon.com/ -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1564935404325-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Thanks Alex! this worked!
-- Sent from: http://discuss.orbeon.com/ -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1565413262769-0.post%40n4.nabble.com. |
Administrator
|
Perfect Joel, it can be tricky that `xxf:sort()` right, and thank you for the
update. ‑Alex ----- -- Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet -- Sent from: http://discuss.orbeon.com/ -- You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1565472636136-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Free forum by Nabble | Edit this page |