Datasource sorting on Intersection Operator order
This is an open discussion with 9 replies, filed under General.
Search
First of all I am not sure if you really want to use the Intersection Operator and not the Union Operator. An intersection ID=10+2+1
would come up empty because there are no entries having all three IDs.
Secondly yeah, you can't sort by that in a DS but you can in the XSLT using EXSLT's str:tokenize
: First tokenize your parameter by the delimiter, then loop over it and apply your template in each iteration.
<xsl:for-each select="str:tokenize($param,',')"> <xsl:apply-templates select="/data/ds/entry[@id = current()/token])" /> </xsl:for-each>
Thanks Nils. You're right, ofcourse, regaarding the Intersection Operator. The Union Operator is what is needed. However: I did not quickly notice it since, in contrast to what you were saying, my DS did actually return the entries I was looking for :/
However, the Union Operator is what I need and the same challenge remains: ordering by Union Operator value order.
Thanks for the XSL Tokenize() tip: I'll look into it. The 'problem' is, however, that I do not have the $param
available.
Where does it come from then?
Excuses. Maybe I did not explain my current situation properly.
I simply have a DS setup which should fetch a couple of hardcoded entries (hence the Union Operator fixed values: 6,5,313
).
This DS simply outputs my entries, but sorted by System ID ASC (or whatever from the default Sort By options). The issue is: I cannot find a way to sort them as per my preference 6,5,313
.
There is no $param
since I hardcode the values.
Oh… I just figured out that I could use an DS output parameter using System ID to create a list of those ID's and use that with your Tokenize() method. The only thing is that this DS output param returns a node-set, not a string ("1,2,3"
) so it needs some more work (intermediate template?)
No, that makes it even simpler. tokenize
would simply create a temporary nodeset for you; that becomes unnecessary if your data already comes in nodeset form. I can show you the XSLT if you have some XML for me :-)
Nice chance to try out Xpathr ;)
I can't find that hardcoded filter in there... If it's indeed not appearing anywhere in the XML you could hardcode it into the XSLT as well: str:tokenize("1,2,3")
Yes, that seems to be the whole confusion ;) These hardcoded values are in the DS editor. Why do you expect them to be in my XML?
Anyway, I worked around it (for my case). Thanks for introducing me (again) to tokenize()
The only thing is that this DS output param returns a node-set, not a string
You sounded like it would... :-) Glad you could fix it.
Create an account or sign in to comment.
When I use the "Intersection Operator" in a DS filter (say select System ID with
10+2+1
as a value) I'd love to be able to use that as a sorting preference.I'd like the result be something like:
At the moment it seems not possible since the Sort By option does not allow for it.
Am I overlooking something or is this not possible at the moment?