Project

Profile

Help

Bug #2055 » xsltExamples.php

O'Neil Delpratt, 2014-04-17 12:36

 
<?php
/* simple example to show transforming to string */
function exampleSimple1($proc, $xmlfile, $xslFile){
$proc->setSourceFile($xmlfile);
$proc->setStylesheetFile($xslFile);
$result = $proc->transformToString();
if($result != null) {
$result;
} else {
$errCount = $proc->getExceptionCount();
if($errCount > 0 ){
for ($i = 0; $i < $errCount; $i++) {
$errC = $proc->getErrorCode(intval($i));
$errMessage = $proc->getErrorMessage(intval($i));
if($errC != NULL) {
echo 'Error found: '. $errC.' :'.$errMessage;
}
$proc->exceptionClear();
}
}
}
$proc->clearParameters();
$proc->clearProperties();
return $result;
}
$data = array();
for ($i = 0; $i < $_REQUEST['i']; $i++) {
$usage = array();
$usage[] = memory_get_usage();
$proc = new SaxonProcessor();
$usage[] = memory_get_usage();

exampleSimple1($proc, 'input.xml', 'template.xsl');
$usage[] = memory_get_usage();
$proc->close();
$usage[] = memory_get_usage();
unset($proc);
$usage[] = memory_get_usage();
$data[$i] = $usage;
}

?>

<html><head>
</head>
<body>
<table>
<thead>
<tr>
<th>step ID</th>
<th>before Saxon INIT</th>
<th>after Saxon INIT</th>
<th>After transformation</th>
<th>After close()</th>
<th>After unset()</th>
<tr>
</thead>
<tbody>
<?php foreach ($data as $rowId => $row):?>
<tr>
<td><?=$rowId?></td>
<?php foreach ($row as $val):?>
<td><?=$val?></td>
<?php endforeach;?>
</tr>
<?php endforeach;?>
</tbody>
</table>
</body>
</html>

(1-1/2)