function TransformSchema($schema, $xsl, $schematype = 'string')
{
// Fail if XSLT extension is not available
if (!function_exists('xslt_create')) {
return FALSE;
}
$xsl_file = dirname(__FILE__) . '/xsl/' . $xsl . '.xsl';
// look for xsl
if (!is_readable($xsl_file)) {
return FALSE;
}
switch ($schematype) {
case 'file':
if (!is_readable($schema)) {
return FALSE;
}
$schema = _file_get_contents($schema);
break;
case 'string':
default:
if (!is_string($schema)) {
return FALSE;
}
}
$arguments = array('/_xml' => $schema, '/_xsl' => _file_get_contents($xsl_file));
// create an XSLT processor
$xh = xslt_create();
// set error handler
xslt_set_error_handler($xh, array(&$this, 'xslt_error_handler'));
// process the schema
$result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
xslt_free($xh);
return $result;
}