Sorting data

This page was automatically translated. Stay tuned for a human translation…​

The speedata Publisher offers an easy way to sort data. If this method is not sufficient, the sorting must be performed by an external program such as XSLT.

Assuming that the data file (data.xml) looks like this:

<data>
  <item value="one"/>
  <item value="two"/>
  <item value="three"/>
</data>

Can now be sorted with <SortSequence>. The original data is not changed.

<Layout
  xmlns="urn:speedata.de:2009/publisher/en"
  xmlns:sd="urn:speedata:2009/publisher/functions/en">

  <Record element="data">
    <SetVariable variable="unsorted" select="*"/>
    <SetVariable variable="sorted">
      <SortSequence select="$unsorted" criterion="value"/>
    </SetVariable>
    <PlaceObject>
      <Textblock>
        <ForAll select="$sorted">
          <Paragraph><Value select="@value"/></Paragraph>
        </ForAll>
      </Textblock>
    </PlaceObject>
  </Record>
</Layout>

In addition to the command <SortSequence> there is also the possibility to sort and group by <MakeIndex>. This command is described in the chapter Sorting of keyword indexes.