duckscraper/map_form.txt

95 lines
1.7 KiB
Text
Raw Normal View History

2018-02-05 21:40:36 +00:00
```
apply {{mustache_name}} to {{pages}}
A = /html/head/text()
struct B
C default("n/a") = //table[@class="wikitable sortable"]/tr/td[4]/a/text()
D default("0") = //table[@class="wikitable sortable"]/tr/td[3]/text()
struct E
F = /html/head/inner_names/text()
G = /html/head/inner_probabilities/text()
end
H = /html/head/inner_names/text()
end
I = /html/head/inner_names/text()
end
==mustache_name
blah
==end
2018-02-05 21:40:36 +00:00
```
The above should result in the following:
2018-02-05 21:40:36 +00:00
```
A[]
B[] --- C
--- D
--- E[] --- F
--- G
--- H
--- I[]
2018-02-05 21:40:36 +00:00
```
For example, given these query results:
2018-02-05 21:40:36 +00:00
```
A[] = {a1, a2, a3}
C = c1
D[] = {d1, d2}
F[] = {f1, f2, f3}
G = g1
h = h1
i = i1
2018-02-05 21:40:36 +00:00
```
then the complete result in tree form shall be:
2018-02-05 21:40:36 +00:00
```
{
A => [a1, a2, a3],
B => [
{
C => c1,
D => d1,
E => [
{
F => f1,
G => g1
}, {
F => f2,
G => ""
}, {
F => f3,
G => ""
}
],
H => h1
}, {
C => "",
D => d2,
E => [
{
F => f1,
G => g1
}, {
F => f2,
G => ""
}, {
F => f3,
G => ""
}
],
H => ""
}
]
}
2018-02-05 21:40:36 +00:00
```
Please note that:
* arrays inside a struct turn the struct itself into an array, while its items become just single item values
* if a struct contains no arrays, then the struct shall not become an array - that is, a struct generates an array with as many elements as the largest element in the struct itself
* there are as many of any one struct as the size of the largest array inside it
* nested structs get duplicated in every outer struct they are part of; in the example above E has as many elements as there items in F (2, the largest between F and G), and the whole array of E is duplicated in every element of B