Using xxforms:sort to sort by dereferenced data.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Using xxforms:sort to sort by dereferenced data.

Jeremy Nix
I'm trying to using the xxforms:sort method to sort by an attribute or
element that is not apart of the underlying itemset.  I instead, use an
attribute of each item in the itemset to lookup what I am interested in
sorting by.  So, for example, instead of doing something like this...

<xforms:itemset nodeset="xxforms:sort(instance('samples-instance')/file,
@name, 'text', 'ascending')">

I'm doing something like this...

<xforms:itemset nodeset="xxforms:sort(instance('samples-instance')/file,
instance('sample-instance')/files[@thename=context()/@name]/@sortby,
'text', 'ascending')">

When I try this, it is giving me the following error: "An empty sequence
is not allowed as the second argument of xxforms:sort()".  Is what I'm
attempting to do even supported?  I've attached a simple example to
illustrate what I'm trying to do.  My guess is that either the sorting
must be done by an attribute/element that is a child of each item in the
nodeset, or that my context is somehow mixed up.

Thanks for any help that you can give.
--
------------------------------------------------------------------------
Jeremy Nix
Senior Application Developer
Cincinnati Children's Hospital Medical Center


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

sort_test.xhtml (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Using xxforms:sort to sort by dereferenced data.

Alessandro  Vernet
Administrator
Jeremy,

Interesting question. You can't use context() in this case. Quoting
from the spec: "This function returns the in-scope evaluation context
node of the nearest ancestor element of the node containing the XPath
expression that invokes this function". And you can override this by
setting the context explicitly with the 'context' attribute. In your
case you don't want the context of the xforms:repeat, but the current
node you're iterating on with the xxforms:sort. Using 'for' saves you
in this case. Changing the second argument as follows does the trick:

for $current-id in @id return
instance('inst')/Colors/Color[@id=$current-id]/text()

I also attached your updated example for reference.

Alex

On Mon, May 10, 2010 at 11:21 AM, Jeremy Nix <[hidden email]> wrote:

> I'm trying to using the xxforms:sort method to sort by an attribute or
> element that is not apart of the underlying itemset.  I instead, use an
> attribute of each item in the itemset to lookup what I am interested in
> sorting by.  So, for example, instead of doing something like this...
>
> <xforms:itemset nodeset="xxforms:sort(instance('samples-instance')/file,
> @name, 'text', 'ascending')">
>
> I'm doing something like this...
>
> <xforms:itemset nodeset="xxforms:sort(instance('samples-instance')/file,
> instance('sample-instance')/files[@thename=context()/@name]/@sortby, 'text',
> 'ascending')">
>
> When I try this, it is giving me the following error: "An empty sequence is
> not allowed as the second argument of xxforms:sort()".  Is what I'm
> attempting to do even supported?  I've attached a simple example to
> illustrate what I'm trying to do.  My guess is that either the sorting must
> be done by an attribute/element that is a child of each item in the nodeset,
> or that my context is somehow mixed up.
>
> Thanks for any help that you can give.
> --
> ------------------------------------------------------------------------
> Jeremy Nix
> Senior Application Developer
> Cincinnati Children's Hospital Medical Center
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing
> list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
Orbeon Forms - Web forms, open-source, for the Enterprise -
http://www.orbeon.com/
My Twitter: http://twitter.com/avernet


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

2010-05-10-jeremy-sort.xhtml (2K) Download Attachment
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet