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 "Sablotron 1.0.3 - command-line"
18 : *
19 : * @author Viktor Mašíček <viktor@masicek.net>
20 : */
21 : class Sablotron103cmdProcessorDriver 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('sabcmd --version 2> /dev/null | grep \'sabcmd 1.0.3\' | 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]\Sablotron\1.0.3\sabcmd.exe" "file:///[XSLT]" "file:///[INPUT]" "file:///[OUTPUT]" 2> "[ERROR]"';
75 2 : break;
76 :
77 0 : case self::OS_LINUX:
78 0 : $commandTemplate = 'sabcmd [XSLT] [INPUT] [OUTPUT] 2> [ERROR]';
79 0 : break;
80 0 : }
81 :
82 2 : return $commandTemplate;
83 : }
84 :
85 :
86 : /**
87 : * Full name of processor (with version)
88 : *
89 : * @return string
90 : */
91 : public function getFullName()
92 : {
93 3 : return 'Sablotron 1.0.3 - command-line';
94 : }
95 :
96 :
97 : /**
98 : * Return name of processor kernel.
99 : * Available kernels are const of this class with prefix "KERNEL_"
100 : *
101 : * Examples:
102 : * Saxon 6.5.5 -> Saxon
103 : * xsltproc -> libxslt
104 : *
105 : * @return string
106 : */
107 : public function getKernel()
108 : {
109 1 : return self::KERNEL_SABLOTRON;
110 : }
111 :
112 :
113 : }
|