phpbench/tabular

This package is abandoned and no longer maintained. No replacement package was suggested.

Generate complex tables from simple configuration

0.4.1 2015-12-27 10:59 UTC

This package is auto-updated.

Last update: 2020-10-31 11:27:50 UTC


README

tabularlogo-2

Build Status StyleCI

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    │
└────────────────────────────────┴───────┘