Reference - Data types - xml


App: charts - Page: bars/languages
PHP
HTML
bars/languages.pad
Result
{chart 'hbar',
label='language',
value='speakers',
title='Speakers in millions',
width=640,
height=340
}

<languages>
<row language="English" speakers="1515"/>
<row language="Mandarin Chinese" speakers="1140"/>
<row language="Hindi" speakers="609"/>
<row language="Spanish" speakers="560"/>
<row language="Standard Arabic" speakers="332"/>
<row language="French" speakers="312"/>
<row language="Bengali" speakers="278"/>
<row language="Portuguese" speakers="264"/>
</languages>
{/chart}


App: charts - Page: index
PHP
HTML
index.pad
Result
<main class="page home">

<section class="hero">
<div class="hero-text">
<span class="kicker">PAD · {ignore}{chart}{/ignore}</span>
<h1>Every chart,<br><span class="shine">drawn on the server.</span></h1>
<p class="lead">One tag turns rows of JSON, YAML, CSV or PHP into an accessible SVG chart -
lines, areas, streams, bars, funnels, pyramids, waterfalls, pies, waffles, marimekkos,
parliaments, venns, gauges, radars, roses, bullets, histograms, violins, scatters, heatmaps,
candlesticks, spirals, sankeys, chords, networks, treemaps, packs, org charts and gantt
charts. No JavaScript, so it prints, caches and shows up in an e-mail.</p>
<ul class="stats">
<li><b>46</b> kinds</li>
<li><b>{$exampleCount}</b> examples</li>
<li><b>0</b> lines of JavaScript</li>
</ul>
</div>
<a class="hero-card" href="?sankey/energy" aria-label="Open the energy sankey">
{page 'sankey/energy'}
</a>
</section>

{families}
<section class="family" id="{$family}">
<header class="family-head">
<h2>{$label}</h2>
<span class="family-line">{$tagline}</span>
</header>
<div class="cards">
{examples}
<a class="card" href="?{$page}">
<span class="card-chart">{page $page}</span>
<span class="card-body">
<span class="card-title">{$title}</span>
<span class="card-text">{$text}</span>
</span>
</a>
{/examples}
</div>
</section>
{/families}

</main>


App: manual - Page: callback/before
PHP
HTML
callback/before.pad
Result
<table border=1>

<tr>
<th>Name</th>
<th>Salary</th>
<th>Bonus</th>
<th>Total</th>
</tr>

{staff callback='before.php', before}

{first}
<tr>
<td>Totals</td>
<td>{$salaryTotal | %.2f}</td>
<td>{$bonusTotal | %.2f}</td>
<td>{$totalTotal | %.2f}</td>
</tr>
{/first}

<tr align="right" bgcolor="{switch 'yellow', 'pink'}">
<td align="left">{$name | capitalize}</td>
<td>{$salary | %.2f}</td>
<td>{$bonus | %.2f}</td>
<td>{$total | %.2f}</td>
</tr>

{/staff}

</table>


App: manual - Page: callback/demand
PHP
HTML
callback/demand.pad
Result
<table border=1>

<tr>
<th>Name</th>
<th>Salary</th>
<th>Bonus</th>
<th>Total</th>
</tr>

{staff callback='demand.php'}

<tr align="right"
bgcolor="{switch 'yellow', 'pink'}">
<td align="left">{$name | capitalize}</td>
<td>{$salary | %.2f}</td>
<td>{$bonus | %.2f}</td>
<td>{$total | %.2f}</td>
</tr>

{/staff}

<tr>
<td>Totals</td>
<td>{$salaryTotal | %.2f}</td>
<td>{$bonusTotal | %.2f}</td>
<td>{$totalTotal | %.2f}</td>
</tr>

</table>


App: manual - Page: data/2


App: manual - Page: data/3


App: manual - Page: fragments/options/options_1
PHP
HTML
fragments/options/options_1.pad
Result
<p>{staff words}{$name} {/staff}</p>


App: manual - Page: fragments/options/options_2
PHP
HTML
fragments/options/options_2.pad
Result
<p>{staff wrap='em'}{$name} {/staff}</p>


App: manual - Page: lvl_occ/12
PHP
HTML
lvl_occ/12.pad
Result
{data 'myXml', 'level_demo.xml'}

<table border='1'>
{myXml}
<tr>
{column}
<td>{$column}</td>
{/column}
</tr>
{/myXml}
</table>


App: manual - Page: miscellaneous/level_and_occurrence_variables


App: manual - Page: pages/application_options
PHP
HTML
pages/application_options.pad
Result
{meta title='Options of your own'}

<p>A file in the application's <code>_options/</code> directory makes its name an option
of every tag - written bare, <code>{staff words}</code>, or with a value,
<code>{staff wrap='em'}</code>. Where the file stands decides when it runs:</p>

<table border="1" cellpadding="8" cellspacing="0" style="border-collapse: collapse;">
<tr><th>file</th><th>runs</th><th><code>$padContent</code> is</th></tr>
<tr><td><code>_options/name.php</code></td><td>before the tag renders</td><td>the template between the tags</td></tr>
<tr><td><code>_options/end/name.php</code></td><td>after the tag rendered</td><td>the result - every occurrence, joined</td></tr>
</table>

<p>&nbsp;</p>

<p>The handler changes <code>$padContent</code>, and the option's value is in
<code>$padGetName</code> - TRUE when the option is written bare. An end option sees the
fields filled in, so it can count, mark or tidy what the tag produced. Here
<code>fragments/options/_options/end/words.php</code> appends a word count:</p>

{ignore}
<code><?php // _options/end/words.php

$padContent .= '(' . str_word_count ( strip_tags ( $padContent ) ) . ' words)';

?></code>
{/ignore}

{example 'fragments/options/options_1'}

<p>With a value - <code>_options/end/wrap.php</code> puts the result in the element it is
given:</p>

{ignore}
<code><?php // _options/end/wrap.php

$padContent = "<$padGetName>" . trim ( $padContent ) . "</$padGetName>";

?></code>
{/ignore}

{example 'fragments/options/options_2'}

<p>An option may have both files: the first works on the template, the second on what it
became. The end options run before the built-in <code>toContent</code>, <code>toData</code>
and <code>tidy</code> - those store or tidy what the end option made - and before the closing
tag's pipe. Like tags and callbacks they are looked up from the page's directory up to the
application root.</p>


App: manual - Page: pages/callback
PHP
HTML
pages/callback.pad
Result
{block}
<p>
It's possible to put a PHP file in the directory '_callbacks' that is called back at the processing of a pad tag.<br>
- With option 'before' the callback happens for every occurrence before the processing of the ocurrences.<br>
- Without 'before' the callback happens during the processing of the occurrences, as each one is processed.

</p>
{/block}

{example 'callback/before', php='_callbacks/before.php', skipClose}
{example 'callback/demand', php='_callbacks/demand.php', skipOpen}


App: manual - Page: pages/examples_used_in_this_manual
PHP
HTML
pages/examples_used_in_this_manual.pad
Result
{block}
<p>This manual will use the {tag 'pad'} tag for general PAD features.
<p>Below the internal PHP code for the {tag 'pad'} tag. That is not so much ))</p>
<p>{example 'miscellaneous/true', skipHeader, skipPad, skipResult}</p>
<p>As the {tag 'pad'} tag does not do anything itself, it must be given content & data.
<br>(if there is no data assigned to it then it will have default 1 data occurence)
{/block}

{page 'miscellaneous/pad'}

{page 'staff/index'}


App: manual - Page: pages/level_and_occurrence_variables
PHP
HTML
pages/level_and_occurrence_variables.pad
Result
{block}
$xxx variables are set once at the beginning of a level<br>
%xxx variables are set on every occurence inside a level<br>
{/block}

{page 'miscellaneous/level_and_occurrence_variables'}


App: manual - Page: pages/levels_and_occurrences
PHP
HTML
pages/levels_and_occurrences.pad
Result
<p>
{block}
PAD is data driven, the PAD data concepts are named Level and Occurence
<br><br>
Below example: <br>
- Is two levels deep <br>
- The level 'row' has 3 occurences<br>
- The level 'column' has 5 occurences<br><br>
{/block}
{example 'lvl_occ/1', skipNames, center}
</p>

{block}
If not specifield for a PAD tag then default it has 1 occurence.
<br><br><hr><br>
Just for fun, below the above example implemented in a few different ways.
<br>
Hopefully all this magic will be explained in this manual.
{/block}

<p>
{sequence '2..12', name='xxx'}
{example 'lvl_occ/{$xxx}', skipNames{notFirst},skipOpen,skipHeader{/notFirst}{notLast},skipClose{/notLast}}
{/sequence}
</p>