ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilXMLResultSetWriter.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once "./Services/Xml/classes/class.ilXmlWriter.php";
6
14{
16
18 {
19 parent::ilXmlWriter();
20 $this->xmlResultSet = $xmlResultSet;
21 }
22
23
24 function start()
25 {
26 if(!is_object($this->xmlResultSet))
27 {
28 return false;
29 }
30
31 $this->__buildHeader();
32
33 $this->__buildColSpecs();
34
35 $this->__buildRows();
36
37 $this->__buildFooter();
38
39 return true;
40 }
41
42 function getXML()
43 {
44 return $this->xmlDumpMem(FALSE);
45 }
46
47
48 // PRIVATE
49 function __appendRow(& $xmlResultSetRow)
50 {
51 $this->xmlStartTag('row',null);
52
53 foreach ($xmlResultSetRow->getColumns() as $value)
54 {
55 $this->xmlElement('column',null,$value);
56
57 }
58
59 $this->xmlEndTag('row');
60
61 }
62
63
64 function __buildHeader()
65 {
66 $this->xmlSetDtdDef("<!DOCTYPE result PUBLIC \"-//ILIAS//DTD XMLResultSet//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_xml_resultset_3_7.dtd\">");
67 $this->xmlHeader();
68
69 $this->xmlStartTag("result");
70
71 return true;
72 }
73
74 function __buildColSpecs() {
75 $this->xmlStartTag("colspecs");
76
77 foreach ($this->xmlResultSet->getColSpecs() as $colSpec) {
78 $attr = array ("idx" => $colSpec->getIndex(), "name" => $colSpec->getName());
79
80 $this->xmlElement("colspec", $attr, null);
81 }
82
83 $this->xmlEndTag("colspecs");
84 }
85
86 function __buildRows () {
87 $this->xmlStartTag("rows");
88
89 foreach($this->xmlResultSet->getRows() as $row)
90 {
91 $this->__appendRow($row);
92 }
93
94 $this->xmlEndTag("rows");
95 }
96
97 function __buildFooter()
98 {
99 $this->xmlEndTag('result');
100 }
101
102
103
104}
105
106
107?>
XML Writer for XMLResultSet.
XML writer class.
xmlEndTag($tag)
Writes an endtag.
xmlDumpMem($format=TRUE)
Returns xml document from memory.
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
xmlHeader()
Writes xml header @access public.
xmlSetDtdDef($dtdDef)
Sets dtd definition.
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)