1 | <?php |
||
16 | class Parser extends IRProcessor |
||
17 | { |
||
18 | /** |
||
19 | * @var Normalizer |
||
20 | */ |
||
21 | protected $normalizer; |
||
22 | |||
23 | /** |
||
24 | * @param Normalizer $normalizer |
||
25 | * @return void |
||
26 | */ |
||
27 | public function __construct(Normalizer $normalizer) |
||
31 | |||
32 | /** |
||
33 | * Parse a template into an internal representation |
||
34 | * |
||
35 | * @param string $template Source template |
||
36 | * @return DOMDocument Internal representation |
||
37 | */ |
||
38 | public function parse($template) |
||
54 | |||
55 | /** |
||
56 | * Append an <output/> element to given node in the IR |
||
57 | * |
||
58 | * @param DOMElement $ir Parent node |
||
59 | * @param string $type Either 'avt', 'literal' or 'xpath' |
||
60 | * @param string $content Content to output |
||
61 | * @return void |
||
62 | */ |
||
63 | protected function appendOutput(DOMElement $ir, $type, $content) |
||
92 | |||
93 | /** |
||
94 | * Parse all the children of a given element |
||
95 | * |
||
96 | * @param DOMElement $ir Node in the internal representation that represents the parent node |
||
97 | * @param DOMElement $parent Parent node |
||
98 | * @return void |
||
99 | */ |
||
100 | protected function parseChildren(DOMElement $ir, DOMElement $parent) |
||
126 | |||
127 | /** |
||
128 | * Parse a given node into the internal representation |
||
129 | * |
||
130 | * @param DOMElement $ir Node in the internal representation that represents the node's parent |
||
131 | * @param DOMElement $node Node to parse |
||
132 | * @return void |
||
133 | */ |
||
134 | protected function parseNode(DOMElement $ir, DOMElement $node) |
||
177 | |||
178 | /** |
||
179 | * Parse an <xsl:apply-templates/> node into the internal representation |
||
180 | * |
||
181 | * @param DOMElement $ir Node in the internal representation that represents the node's parent |
||
182 | * @param DOMElement $node <xsl:apply-templates/> node |
||
183 | * @return void |
||
184 | */ |
||
185 | protected function parseXslApplyTemplates(DOMElement $ir, DOMElement $node) |
||
193 | |||
194 | /** |
||
195 | * Parse an <xsl:attribute/> node into the internal representation |
||
196 | * |
||
197 | * @param DOMElement $ir Node in the internal representation that represents the node's parent |
||
198 | * @param DOMElement $node <xsl:attribute/> node |
||
199 | * @return void |
||
200 | */ |
||
201 | protected function parseXslAttribute(DOMElement $ir, DOMElement $node) |
||
207 | |||
208 | /** |
||
209 | * Parse an <xsl:choose/> node and its <xsl:when/> and <xsl:otherwise/> children into the |
||
210 | * internal representation |
||
211 | * |
||
212 | * @param DOMElement $ir Node in the internal representation that represents the node's parent |
||
213 | * @param DOMElement $node <xsl:choose/> node |
||
214 | * @return void |
||
215 | */ |
||
216 | protected function parseXslChoose(DOMElement $ir, DOMElement $node) |
||
237 | |||
238 | /** |
||
239 | * Parse an <xsl:comment/> node into the internal representation |
||
240 | * |
||
241 | * @param DOMElement $ir Node in the internal representation that represents the node's parent |
||
242 | * @param DOMElement $node <xsl:comment/> node |
||
243 | * @return void |
||
244 | */ |
||
245 | protected function parseXslComment(DOMElement $ir, DOMElement $node) |
||
252 | |||
253 | /** |
||
254 | * Parse an <xsl:copy-of/> node into the internal representation |
||
255 | * |
||
256 | * NOTE: only attributes are supported |
||
257 | * |
||
258 | * @param DOMElement $ir Node in the internal representation that represents the node's parent |
||
259 | * @param DOMElement $node <xsl:copy-of/> node |
||
260 | * @return void |
||
261 | */ |
||
262 | protected function parseXslCopyOf(DOMElement $ir, DOMElement $node) |
||
294 | |||
295 | /** |
||
296 | * Parse an <xsl:element/> node into the internal representation |
||
297 | * |
||
298 | * @param DOMElement $ir Node in the internal representation that represents the node's parent |
||
299 | * @param DOMElement $node <xsl:element/> node |
||
300 | * @return void |
||
301 | */ |
||
302 | protected function parseXslElement(DOMElement $ir, DOMElement $node) |
||
317 | |||
318 | /** |
||
319 | * Parse an <xsl:if/> node into the internal representation |
||
320 | * |
||
321 | * @param DOMElement $ir Node in the internal representation that represents the node's parent |
||
322 | * @param DOMElement $node <xsl:if/> node |
||
323 | * @return void |
||
324 | */ |
||
325 | protected function parseXslIf(DOMElement $ir, DOMElement $node) |
||
335 | |||
336 | /** |
||
337 | * Parse an <xsl:text/> node into the internal representation |
||
338 | * |
||
339 | * @param DOMElement $ir Node in the internal representation that represents the node's parent |
||
340 | * @param DOMElement $node <xsl:text/> node |
||
341 | * @return void |
||
342 | */ |
||
343 | protected function parseXslText(DOMElement $ir, DOMElement $node) |
||
351 | |||
352 | /** |
||
353 | * Parse an <xsl:value-of/> node into the internal representation |
||
354 | * |
||
355 | * @param DOMElement $ir Node in the internal representation that represents the node's parent |
||
356 | * @param DOMElement $node <xsl:value-of/> node |
||
357 | * @return void |
||
358 | */ |
||
359 | protected function parseXslValueOf(DOMElement $ir, DOMElement $node) |
||
367 | } |