1 : <?php
2 :
3 : /**
4 : * XSLT Benchmarking
5 : * @link https://github.com/masicek/XSLT-Benchmarking
6 : * @author Viktor Mašíček <viktor@masicek.net>
7 : * @license "New" BSD License
8 : */
9 :
10 : namespace XSLTBenchmarking\TestsGenerator;
11 :
12 : require_once LIBS . '/PhpPath/PhpPath.min.php';
13 : require_once ROOT . '/DriversContainer.php';
14 :
15 : use PhpPath\P;
16 :
17 : /**
18 : * Object for generating xml files by different xml generator.
19 : *
20 : * @author Viktor Mašíček <viktor@masicek.net>
21 : */
22 : class XmlGenerator extends \XSLTBenchmarking\DriversContainer
23 : {
24 :
25 :
26 : /**
27 : * Generate xml file
28 : *
29 : * @param string $outputPath The path of the output xml file
30 : * @param array $settings The list of settings specific by selected xml generator
31 : *
32 : * @return void
33 : */
34 : public function generate($outputPath, $templateDir, array $settings)
35 : {
36 0 : $omitXmlDeclaration = FALSE;
37 0 : if (isset($settings['omitXmlDeclaration']))
38 0 : {
39 0 : if ($settings['omitXmlDeclaration'] == 1)
40 0 : {
41 0 : $omitXmlDeclaration = TRUE;
42 0 : }
43 0 : unset($settings['omitXmlDeclaration']);
44 0 : }
45 :
46 0 : $this->driver->generate($outputPath, $templateDir, $settings);
47 :
48 : if ($omitXmlDeclaration)
49 0 : {
50 0 : $output = file_get_contents($outputPath);
51 0 : $output = preg_replace('/<\?xml[^?]+\?>/', '', $output);
52 0 : file_put_contents($outputPath, $output);
53 0 : }
54 0 : }
55 :
56 :
57 : }
|