3 * Script used to convert docbook source to human readable docs
5 * @copyright (c) 2007-2013 G. Giunta
8 if ($_SERVER['argc'] < 4)
9 die("Usage: php convert.php docbook.xml \path\\to\stylesheet.xsl output-dir|output_file\n");
11 echo "Starting xsl conversion process...\n";
13 $doc = $_SERVER['argv'][1];
14 $xss = $_SERVER['argv'][2];
16 if (!file_exists($doc))
17 die("KO: file $doc cannot be found\n");
18 if (!file_exists($xss))
19 die("KO: file $xss cannot be found\n");
21 // Load the XML source
22 $xml = new DOMDocument;
24 $xsl = new DOMDocument;
27 // Configure the transformer
28 $proc = new XSLTProcessor;
29 $proc->importStyleSheet($xsl); // attach the xsl rules
31 //if ($_SERVER['argc'] >= 4)
33 if (is_dir($_SERVER['argv'][3]))
36 if (!$proc->setParameter('', 'base.dir', $_SERVER['argv'][3]))
37 echo "setting param base.dir KO\n";
41 //echo "{$_SERVER['argv'][3]} is not a dir\n";
44 $out = $proc->transformToXML($xml);
45 if (!is_dir($_SERVER['argv'][3]))
46 file_put_contents($_SERVER['argv'][3], $out);