phpbench / tabular
Generate complex tables from simple configuration
Installs: 14 451
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 1
Forks: 1
Open Issues: 3
Requires
- php: ~5.4|^7.0
- justinrainbow/json-schema: ~1.4.0
- phpbench/dom: ~0.1
- seld/jsonlint: ~1.0
This package is auto-updated.
Last update: 2020-10-31 11:27:50 UTC
README
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).
Tabular is better than spreadsheets.
Documentation
See the official documentation.
Example
The central concept is the definition file:
{ "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 version="1.0"?> <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):
┌────────────────────────────────┬───────┐
│ title │ price │
├────────────────────────────────┼───────┤
│ War and Peace │ 5 │
│ One Hundered Years of Soliture │ 7 │
│ │ 12 │
└────────────────────────────────┴───────┘