James M Snell wrote:
Complete example
<feed>
...
<i:ranking default="yes" order="descending">priority</i:ranking>
<i:ranking order="ascending">index</i:ranking>
<i:ranking
order="descending">http://www.example.com/ranking/foo</i:ranking>
<entry>
...
<id>C</id>
<i:rank scheme="priority">10</i:rank>
<i:rank scheme="index">3</i:rank>
<i:rank scheme="http://www.example.com/ranking/foo">30</i:rank>
</entry>
[…]
Thoughts?
It looks more and more like Microsoft's RSS simple list extension [1],
and I think they had the good approach (define sorts on the feed
metadata, based on extension element values at the entry level) but a
bad technical solution (use the extension element in a different
context: when in cf:sort, it has a non-namespaced data-type attribute
and its content is a "label" string, while in an entry it might not have
attributes and its value should be of type specified by the @data-type
attribute seen before).
Suggestions:
1. get rid of your i:rank, users will use any extension element instead
(no more registry and you can still define "standard" priority and index
extensions)
2. get rid of your @order attribute: users should be able to choose in
which order they want their entries: best-ranked to least-ranked "top to
bottom" or "bottom to top". Its the responsibility of the producer to
provide labels and values that will be well-understood by users (e.g.
not saying "stars" and ranking from 1 (best rank) down to 5: "stars"
implies "number of stars", so "sort by stars in ascending order" implies
"the highest the value, the better it is", which is not what's behind
1=best-rank…)
3. make content of i:raking a user understandable label
4. (optional) add a data-type attribute to i:ranking (maybe rename that
one to something related to sorting, not ranking)
5. use @namespace and @localname attributes on i:ranking to describe the
element in entries the sort applies to (using those attributes prevent
from using QNames in attribute values, which doesn't work great with
prefix changes)
<feed>
<ext:sort data-type="number" namespace="http://example.com/user-review"
localname="stars">User-reviews stars</ext:sort>
…
<entry>
<ur:stars xmlns:ur="http://example.com/user-review">1</ur:stars>
…
This, however, doesn't match "index" in the draft title any more.
What could be even better, though a lot less "simple" (and not feasible,
see below), would be to use XPath or XPointer (XPointer has the
advantage that you define namespace prefix bindings "inside" it , using
the xmlns() XPointer scheme). That way, you could use any
element/subelement and/or attribute as the value holder for the sort.
This would require however an XPath/XPointer engine, as well as storing
the XML DOM, or mapping XPath/XPointer to your internal feed
representation; this is not feasible.
[1]
http://msdn.microsoft.com/windowsvista/building/rss/simplefeedextensions/
--
Thomas Broyer