Author: nospam.bugzilla
Description:
Some articles contain tables of data, and some contain several tables of the same data sorted
different ways (see the list of Eurovision winners as an example). Wouldn't it be lovely to
have a system to store tables of data, and a syntax in wikitext to render an output table
using this underlying table of data, with the possibility for the user to dynamically reorder
the table by clicking on a sort button?
Say we had the following table of data, in a simple XML format, envelopped into some special
wikitext tags on the page:
<wikidata ID="ESCwinners"> <winner> <year>1956</year> <country code="CHE">Switzerland</country> <song>Refrain</song> <performer>Lys Assia</performer> </winner> <winner> <year>1957</year> <country code="NLD">Netherlands</country> <song>Net Als Toen</song> <performer>Corry Brokken</performer> </winner> <winner> <year>1958</year> <country code="FRA">France</country> <song>Dors, mon amour</song> <performer>André Claveau</performer> </winner> </wikidata>
And if you want to render this as a table you might put something like this in the wikitext,
with xpath expressions to describe which data we're actually pulling out for each column of
the table:
{| class="wikitable"
|- style="background:#efefef" datasource="wikidata[@ID='ESCwinners']"
! Year { sortbutton="winner/year" ascending } !! Country { sortbutton="winner/country" } !!
Song !! Performer
|- winner/year || {{winner/country/@code}} || [[winner/song]] || [[winner/performer]]
|}So the idea then is that the table is filled with as many rows as there are child nodes
returned by evaluating the xpath expression in the datasource tag.
|- style="background:#efefef" datasource="wikidata[@ID='ESCwinners']"
The table header row will contain useful things like sort buttons.
! Year { sortbutton="winner/year" ascending } !! Country { sortbutton="winner/country" } !!
Song !! PerformerWhen the text is rendered, the { sortbutton ... } tag will be replaced with an icon that the
user can click on to sort the table in ascending or descending order. The default sorting
for when the page is first rendered can be put in the tag of the page code.
Then the nodes/table rows are iterated over, and each new row of the table is filled with
data using the xpath expresisons in the row description code.
|- winner/year || {{winner/country/@code}} || [[winner/song]] || [[winner/performer]]And there you have it. Of course, just using unbridled XML and xpath provides tons of
possiblities right out of the box, but it might be a bit much for the average editor. So
perhaps a more resicted syntax for the XML data and the table description markup would be
just as good. (Maybe it would be better to limit the XML data to element-centric or attribute-
centric formatting to keep it simple, for ex.)
So... well, I'm a programmer. Can't promise a lot of my time, but if this idea has any appeal
I could make an effort.
Rgds,
Daniel
Version: unspecified
Severity: enhancement