ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilXMLResultSetWriter.php
Go to the documentation of this file.
1 <?php
2 
3 
4  /*
5  +-----------------------------------------------------------------------------+
6  | ILIAS open source |
7  +-----------------------------------------------------------------------------+
8  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
9  | |
10  | This program is free software; you can redistribute it and/or |
11  | modify it under the terms of the GNU General Public License |
12  | as published by the Free Software Foundation; either version 2 |
13  | of the License, or (at your option) any later version. |
14  | |
15  | This program is distributed in the hope that it will be useful, |
16  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18  | GNU General Public License for more details. |
19  | |
20  | You should have received a copy of the GNU General Public License |
21  | along with this program; if not, write to the Free Software |
22  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
23  +-----------------------------------------------------------------------------+
24  */
25 
26 
36 include_once "./classes/class.ilXmlWriter.php";
37 
39 {
41 
43  {
45  $this->xmlResultSet = $xmlResultSet;
46  }
47 
48 
49  function start()
50  {
51  if(!is_object($this->xmlResultSet))
52  {
53  return false;
54  }
55 
56  $this->__buildHeader();
57 
58  $this->__buildColSpecs();
59 
60  $this->__buildRows();
61 
62  $this->__buildFooter();
63 
64  return true;
65  }
66 
67  function getXML()
68  {
69  return $this->xmlDumpMem(FALSE);
70  }
71 
72 
73  // PRIVATE
74  function __appendRow(& $xmlResultSetRow)
75  {
76  $this->xmlStartTag('row',null);
77 
78  foreach ($xmlResultSetRow->getColumns() as $value)
79  {
80  $this->xmlElement('column',null,$value);
81 
82  }
83 
84  $this->xmlEndTag('row');
85 
86  }
87 
88 
89  function __buildHeader()
90  {
91  $this->xmlSetDtdDef("<!DOCTYPE result PUBLIC \"-//ILIAS//DTD XMLResultSet//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_xml_resultset_3_7.dtd\">");
92  $this->xmlHeader();
93 
94  $this->xmlStartTag("result");
95 
96  return true;
97  }
98 
99  function __buildColSpecs() {
100  $this->xmlStartTag("colspecs");
101 
102  foreach ($this->xmlResultSet->getColSpecs() as $colSpec) {
103  $attr = array ("idx" => $colSpec->getIndex(), "name" => $colSpec->getName());
104 
105  $this->xmlElement("colspec", $attr, null);
106  }
107 
108  $this->xmlEndTag("colspecs");
109  }
110 
111  function __buildRows () {
112  $this->xmlStartTag("rows");
113 
114  foreach($this->xmlResultSet->getRows() as $row)
115  {
116  $this->__appendRow($row);
117  }
118 
119  $this->xmlEndTag("rows");
120  }
121 
122  function __buildFooter()
123  {
124  $this->xmlEndTag('result');
125  }
126 
127 
128 
129 }
130 
131 
132 ?>