blob: 7b6fb2106624c0e0b3707714a5754dcfd0e92f7a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* XML renderer.
*
* Based on the HTML renderer by Andrey Demenev.
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
*
* @category Text
* @package Text_Highlighter
* @author Stoyan Stefanov <ssttoo@gmail.com>
* @copyright 2006 Stoyan Stefanov
* @license http://www.php.net/license/3_0.txt PHP License
* @version CVS: $Id$
* @link http://pear.php.net/package/Text_Highlighter
*/
/**
* @ignore
*/
require_once 'Text/Highlighter/Renderer.php';
require_once 'Text/Highlighter/Renderer/Array.php';
require_once 'XML/Serializer.php';
/**
* XML renderer, based on Andrey Demenev's HTML renderer.
*
* @author Stoyan Stefanov <ssttoo@gmail.com>
* @category Text
* @package Text_Highlighter
* @copyright 2006 Stoyan Stefanov
* @license http://www.php.net/license/3_0.txt PHP License
* @version Release: 0.5.0
* @link http://pear.php.net/package/Text_Highlighter
*/
class Text_Highlighter_Renderer_XML extends Text_Highlighter_Renderer_Array
{
/**
* Options for XML_Serializer
*
* @access private
* @var array
*/
var $_serializer_options = array();
/**
* Resets renderer state
*
* Descendents of Text_Highlighter call this method from the constructor,
* passing $options they get as parameter.
*
* @access protected
*/
function reset()
{
parent::reset();
if (isset($this->_options['xml_serializer'])) {
$this->_serializer_options = $this->_options['xml_serializer'];
}
}
/**
* Signals that no more tokens are available
*
* @abstract
* @access public
*/
function finalize()
{
// call parent's finalize(), then serialize array into XML
parent::finalize();
$output = parent::getOutput();
$serializer = new XML_Serializer($this->_serializer_options);
$result = $serializer->serialize($output);
if ($result === true) {
$this->_output = $serializer->getSerializedData();
}
}
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* c-hanging-comment-ender-p: nil
* End:
*/
?>
|