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\TestsRunner;
11 :
12 : // @codeCoverageIgnoreStart
13 : require_once __DIR__ . '/AProcessorDriver.php';
14 : // @codeCoverageIgnoreEnd
15 :
16 : /**
17 : * Driver for "xsltproc 1.1.26"
18 : *
19 : * @author Viktor Mašíček <viktor@masicek.net>
20 : */
21 : class Xsltproc1126ProcessorDriver extends AProcessorDriver
22 : {
23 :
24 :
25 : /**
26 : * Return flag, if the driver is available.
27 : *
28 : * @return bool
29 : */
30 : public function isAvailable()
31 : {
32 4 : switch (PHP_OS)
33 : {
34 4 : case self::OS_WIN:
35 4 : return TRUE;
36 : break;
37 :
38 0 : case self::OS_LINUX:
39 0 : exec('xsltproc --version 2> /dev/null | grep \'libxslt 10126\' | wc -l', $output);
40 0 : if ($output[0] == '0')
41 0 : {
42 0 : return FALSE;
43 : }
44 : else
45 : {
46 0 : return TRUE;
47 : }
48 : break;
49 :
50 0 : default:
51 0 : return FALSE;
52 : break;
53 0 : }
54 : }
55 :
56 :
57 : /**
58 : * Return template of command
59 : *
60 : * Templates substitutions:
61 : * [XSLT] = path of XSLT template for transformation
62 : * [INPUT] = path of input XML file
63 : * [OUTPUT] = path of generated output XML file
64 : * [ERROR] = path of file for eventual generated error message
65 : * [LIBS] = path of directory containing XSLT processors (libraries, command-line program etc.)
66 : *
67 : * @return string
68 : */
69 : public function getCommandTemplate()
70 : {
71 2 : switch (PHP_OS)
72 : {
73 2 : case self::OS_WIN:
74 2 : $commandTemplate = '"[PROCESSORS]\libxslt\1.1.26\xsltproc\xsltproc.exe" -o "[OUTPUT]" "[XSLT]" "[INPUT]" 2> "[ERROR]"';
75 2 : break;
76 :
77 0 : case self::OS_LINUX:
78 : // we assume installing xsltproc 1.1.26
79 0 : $commandTemplate = 'xsltproc -o [OUTPUT] [XSLT] [INPUT] 2> [ERROR]';
80 0 : break;
81 0 : }
82 :
83 2 : return $commandTemplate;
84 : }
85 :
86 :
87 : /**
88 : * Full name of processor (with version)
89 : *
90 : * @return string
91 : */
92 : public function getFullName()
93 : {
94 3 : return 'xsltproc 1.1.26';
95 : }
96 :
97 :
98 : /**
99 : * Return name of processor kernel.
100 : * Available kernels are const of this class with prefix "KERNEL_"
101 : *
102 : * Examples:
103 : * Saxon 6.5.5 -> Saxon
104 : * xsltproc -> libxslt
105 : *
106 : * @return string
107 : */
108 : public function getKernel()
109 : {
110 1 : return self::KERNEL_LIBXSLT;
111 : }
112 :
113 :
114 : }
|