3 * Script used to convert docbook source to human readable docs
6 * @copyright (c) 2007-2008 G. Giunta
9 if ($_SERVER['argc'] < 4)
10 die("Usage: php convert.php docbook.xml \path\\to\stylesheet.xsl output-dir|output_file\n");
12 echo "Starting xsl conversion process...\n";
14 $doc = $_SERVER['argv'][1];
15 $xss = $_SERVER['argv'][2];
17 if (!file_exists($doc))
18 die("KO: file $doc cannot be found\n");
19 if (!file_exists($xss))
20 die("KO: file $xss cannot be found\n");
22 // Load the XML source
23 $xml = new DOMDocument;
25 $xsl = new DOMDocument;
28 // Configure the transformer
29 $proc = new XSLTProcessor;
30 $proc->importStyleSheet($xsl); // attach the xsl rules
32 //if ($_SERVER['argc'] >= 4)
34 if (is_dir($_SERVER['argv'][3]))
37 if (!$proc->setParameter('', 'base.dir', $_SERVER['argv'][3]))
38 echo "setting param base.dir KO\n";
42 //echo "{$_SERVER['argv'][3]} is not a dir\n";
45 $out = $proc->transformToXML($xml);
46 if (!is_dir($_SERVER['argv'][3]))
47 file_put_contents($_SERVER['argv'][3], $out);