ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 'classes/class.ilSaxParser.php';
38 include_once './webservice/soap/classes/class.ilXMLResultSet.php';
39 
41 {
43 
49  function ilXMLResultSetParser($a_xml_data = '')
50  {
52  $this->setXMLContent($a_xml_data);
53  }
54 
60  function getXMLResultSet()
61  {
62  return $this->xmlResultSet;
63  }
64 
71  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  function handlerBeginTag($a_xml_parser,$a_name,$a_attribs)
87  {
88  switch($a_name)
89  {
90  case 'result':
91  $this->xmlResultSet = new ilXMLResultSet();
92  break;
93 
94  case 'colspecs':
95  break;
96 
97  case 'colspec':
98  $this->xmlResultSet->addColumn ($a_attribs["name"]);
99  break;
100  case 'row':
101  $this->currentRow = new ilXMLResultSetRow();
102  $this->xmlResultSet->addRow ($this->currentRow);
103  $this->currentColumnIndex = 0;
104  break;
105  case 'column':
106  break;
107  }
108  }
109 
116  function handlerEndTag($a_xml_parser,$a_name)
117  {
118  switch($a_name)
119  {
120  case 'column':
121  $this->currentRow->setValue ($this->currentColumnIndex, $this->cdata);
122  $this->currentColumnIndex ++;
123  break;
124  }
125  $this->cdata = '';
126  }
127 
134  function handlerCharacterData($a_xml_parser,$a_data)
135  {
136  if($a_data != "\n")
137  {
138  // Replace multiple tabs with one space
139  $a_data = preg_replace("/\t+/"," ",$a_data);
140 
141  $this->cdata .= trim($a_data);
142  }
143 
144 
145  }
146 
147 }
148 ?>