DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:strata:examples

Strata Practical Examples

Page purpose and status

This page provides practical examples for the Strata plugin. It is a working draft document.

Basic queries

The examples in this section are based on the following three pages existing:

:data:cities:madrid

====== Madrid ======
<data city>
----------
metro_area: Madrid metropolitan area
country: Spain
population: 3141991
mayor: Manuela Carmena
----------
</data>

:data:cities:london

====== London ======
<data city>
----------
metro_area: Greater London
country: UK
population: 8673713
----------
</data>

:data:cities:berlin

====== Berlin ======
<data city>
----------
metro_area: Berlin-Brandenburg Metropolitan Region
country: Germany
population: 3670622
----------
</data>

City name (with link to article) and population

List all cities and their population in a table.

Columns:

  1. Name. Hyperlink to page on which the city data is defined.
  2. Population. Text field. Displays population.

Strata code

<table>
fields {
    -- Each field becomes a column in the displayed table
    ?name: Name
    ?pop: Population
}
-- The result set will contain one row for each city data object found by the query 
-- The first column contains a link to the page on which that data object code is found
?name is a: city
?name Population: ?pop
</table>

Fields

Columns are defined inside fields:

  1. ?name: Name assigns the caption Name to the ?name field. ?name is a: city defines ?name as a city data object. In this example, the city data objects exist on each city's page. Strata assigns a link to that page to ?name. Now, ?name can be used to link other fields to this result row.
  2. ?pop:Population defines the id and description of the second column. ?name Population: ?pop tells Strata to populate the second column with the value of the Population field in the city data object.

Expected output

NamePopulation
Berlin3670622
London8673713
Madrid3141991

Cities with fewer than 5 million inhabitants

<table>
fields {
    ?name: Name
    ?pop: Population
}
?name is a: city
?name Population: ?pop
?pop < 500000
</table>

ui block: User Interface

Tables: field filtering

The UI block affects the way in which the results are presented to the user:

  • Cosmetic affects
  • Field filtering: filter one or more columns of a table using dropdowns or free-text filtering

Strata code

<table>
fields {
    ?name: Name
    ?pop: Population
}
?name is a: city
?name Population: ?pop
ui {
  -- Adding * allows multiple values
  filter*: select, text
}
</table>

Expected output

Behaviour

  • All non-blank filters must match the row under consideration, or it will not be displayed
  • Numbers are treated as text by the table filters
  • When specifying filter type, it is possible to specify one of:
    • filter: takes a single filter type shared by all columns
    • filter*: takes one filter type per column; comma-separated; number of arguments must match number of columns

Interaction with other plugins

FIXME

Examples FAQ

Why don't numeric operators seem to affect query results?

Numeric operators require that any field value resemble only an integer or a float. For example, Strata will numerically compare 56 or 387.2874, but will treat 5,320,000 as a string.

Strata uses the comma , to separate multiple values on a single line. So if we wanted to store multiple numbers be definitely couldn't use the human-readable separates. For example, value 3,455, 6,777 is completely ambiguous.

In any case, the Decimal Mark Standard suggests that representations of larger numbers should not use commas to group digits into threes for readability .

In summary, when storing numbers in Strata, use only 0-9 and your locale-specific decimal separator . or ,.

What do the ---- in the data examples do?

No functional effect. They are comments intended to make the data section stand out on a real-world page with lots of content.

plugin/strata/examples.txt · Last modified: 2017-06-08 06:42 by FosseWay