ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilXMLResultSetParser.php
Go to the documentation of this file.
1 <?php
2 
3 
4 
5  /*
6  +-----------------------------------------------------------------------------+
7  | ILIAS open source |
8  +-----------------------------------------------------------------------------+
9  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
10  | |
11  | This program is free software; you can redistribute it and/or |
12  | modify it under the terms of the GNU General Public License |
13  | as published by the Free Software Foundation; either version 2 |
14  | of the License, or (at your option) any later version. |
15  | |
16  | This program is distributed in the hope that it will be useful, |
17  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
18  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19  | GNU General Public License for more details. |
20  | |
21  | You should have received a copy of the GNU General Public License |
22  | along with this program; if not, write to the Free Software |
23  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
24  +-----------------------------------------------------------------------------+
25  */
26 
27 
37 include_once './Services/Xml/classes/class.ilSaxParser.php';
38 include_once './webservice/soap/classes/class.ilXMLResultSet.php';
39 
41 {
42  public $xmlResultSet;
43 
49  public function __construct($a_xml_data = '')
50  {
51  parent::__construct();
52  $this->setXMLContent($a_xml_data);
53  }
54 
60  public function getXMLResultSet()
61  {
62  return $this->xmlResultSet;
63  }
64 
71  public function setHandlers($a_xml_parser)
72  {
73  xml_set_object($a_xml_parser, $this);
74  xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
75  xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
76  }
77 
78 
86  public function handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
87  {
88  switch ($a_name) {
89  case 'result':
90  $this->xmlResultSet = new ilXMLResultSet();
91  break;
92 
93  case 'colspecs':
94  break;
95 
96  case 'colspec':
97  $this->xmlResultSet->addColumn($a_attribs["name"]);
98  break;
99  case 'row':
100  $this->currentRow = new ilXMLResultSetRow();
101  $this->xmlResultSet->addRow($this->currentRow);
102  $this->currentColumnIndex = 0;
103  break;
104  case 'column':
105  break;
106  }
107  }
108 
115  public function handlerEndTag($a_xml_parser, $a_name)
116  {
117  switch ($a_name) {
118  case 'column':
119  $this->currentRow->setValue($this->currentColumnIndex, $this->cdata);
120  $this->currentColumnIndex++;
121  break;
122  }
123  $this->cdata = '';
124  }
125 
132  public function handlerCharacterData($a_xml_parser, $a_data)
133  {
134  if ($a_data != "\n") {
135  // Replace multiple tabs with one space
136  $a_data = preg_replace("/\t+/", " ", $a_data);
137 
138  $this->cdata .= trim($a_data);
139  }
140  }
141 }
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...
setHandlers($a_xml_parser)
set event handlers
handlerEndTag($a_xml_parser, $a_name)
handler for end of element
handlerCharacterData($a_xml_parser, $a_data)
handler for character data
__construct($a_xml_data='')
Constructor.
handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element
setXMLContent($a_xml_content)