Tabular
, (*1)
, (*2)
Tabular is a library for transforming a source XML document into a tabular XML
document using a given configuration. The resulting tabular XML document can
then transformed or used to easily render tables (for example in HTML or in
the console)., (*3)
Tabular is better than spreadsheets., (*4)
Documentation
See the official documentation., (*5)
Example
The central concept is the definition file:, (*6)
{
"rows": [
{
"cells": [
{
"name": "title",
"expr": "string(./title)"
},
{
"name": "price",
"expr": "number(./price)"
}
],
"with_query": "//book"
},
{
"cells": [
{
"name": "price",
"expr": "sum(//price)"
}
]
}
]
}
````
The above definition will generate a table representation in XML with a row
for each `<book/>` element in the given XML file and provide an additional row
showing the sum of all the `<price/>` elements of the `<book/>` element.
So given the following XML file:
```xml
<store>
<book>
<title>War and Peace</title>
<price>5.00</price>
</book>
<book>
<title>One Hundered Years of Soliture</title>
<price>7</price>
</book>
</store>
````
The generated table might look like this (as rendered by the [Tabular
CLI](https://github.com/phpbench/tabular-cli)):
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโ
โ title โ price โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโค
โ War and Peace โ 5 โ
โ One Hundered Years of Soliture โ 7 โ
โ โ 12 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโ
```, (*7)