|
<?php
|
|
function extractArguments() {
|
|
global $_GET, $argv;
|
|
|
|
$params = array();
|
|
if(is_array($_GET) && !empty($_GET)) {
|
|
$params = $_GET;
|
|
}
|
|
elseif(isset($argv) && !empty($argv)) {
|
|
foreach($argv as $v) {
|
|
$tmp = explode('=', $v);
|
|
if(count($tmp) == 2) {
|
|
$params[$tmp[0]] = $tmp[1];
|
|
}
|
|
}
|
|
}
|
|
return $params;
|
|
}
|
|
|
|
$params = extractArguments();
|
|
if(isset($params['xml']) && isset($params['xsl'])){
|
|
|
|
$xmlfile = $params['xml'];
|
|
$xslFile = $params['xsl'];
|
|
$saxonProc = new Saxon\SaxonProcessor();
|
|
$xsltProc = $saxonProc->newXsltProcessor();
|
|
//$xsltProc->setProperty("dtd","false");
|
|
$version = $saxonProc->version();
|
|
echo 'Saxon Processor version: '.$version;
|
|
echo '<br/>';
|
|
$xsltProc->setSourceFromFile($xmlfile);
|
|
echo 'xml error'.$xsltProc->getExceptionCount()."\n";
|
|
$xsltProc->compileFromFile($xslFile);
|
|
echo 'xsl error'.$xsltProc->getExceptionCount()."\n";
|
|
$result = $xsltProc->transformToString();
|
|
$nbError = $xsltProc->getExceptionCount();
|
|
echo 'transform error'.$nbError."\n";
|
|
if($nbError > 0){
|
|
echo 'message' . $xsltProc->getErrorMessage(0)."\n";
|
|
}
|
|
if($result != null) {
|
|
//file_put_contents("out/".$params["xml"],$result);
|
|
echo 'exampleSimple1:';
|
|
echo 'Output:'.$result;
|
|
} else {
|
|
echo "Result is null\n";
|
|
}
|
|
/*$class_methods = get_class_methods($xsltProc);
|
|
foreach($class_methods as $method_name){
|
|
echo "$method_name\n";
|
|
}
|
|
*/
|
|
$xsltProc->clearParameters();
|
|
$xsltProc->clearProperties();
|
|
}
|
|
else {
|
|
echo "Veuillez fournir xml=xml/nom_de_xml_d_entree.xml et xsl=xsl/nom_de_la_xsl.xsl";
|
|
}
|
|
?>
|