plugin:strata:examples
This is an old revision of the document!
Table of Contents
Strata Practical Examples
This page provides practical examples for the Strata plugin.
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: 3,141,991 mayor: Manuela Carmena ---------- </data>
:data:cities:london
====== London ====== <data city> ---------- metro_area: Greater London country: UK population: 8,673,713 ---------- </data>
:data:cities:berlin
====== Berlin ====== <data city> ---------- metro_area: Berlin-Brandenburg Metropolitan Region country: Germany population: 3,670,622 ---------- </data>
City name (with link to article) and population
Goal
List all cities and their population in a table.
Columns:
- Name. Hyperlink to page on which the city data is defined.
- 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
:
- ?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. ?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
Name | Population |
---|---|
Berlin | 3,670,622 |
London | 8,673,713 |
Madrid | 3,141,991 |
Cities with fewer than 5 million inhabitants
Applying < operator doesn't seem to filter out London - why?
<table> fields { ?name: Name ?pop: Population } ?name is a: city ?name Population: ?pop ?pop < 500000 </table>
Examples FAQ
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.1494131378.txt.gz · Last modified: 2017-05-07 06:29 by FosseWay