ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilXMLResultSetWriter.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
29
31 {
33 $this->xmlResultSet = $xmlResultSet;
34 }
35
36 public function start(): bool
37 {
38 $this->buildHeader();
39 $this->buildColSpecs();
40 $this->buildRows();
41 $this->buildFooter();
42 return true;
43 }
44
45 private function buildHeader(): void
46 {
47 $this->xmlSetDtdDef("<!DOCTYPE result PUBLIC \"-//ILIAS//DTD XMLResultSet//EN\" \"" . ILIAS_HTTP_PATH . "/components/ILIAS/Export/xml/ilias_xml_resultset_3_7.dtd\">");
48 $this->xmlHeader();
49 $this->xmlStartTag("result");
50 }
51
52 private function buildColSpecs(): void
53 {
54 $this->xmlStartTag("colspecs");
55 foreach ($this->xmlResultSet->getColSpecs() as $colSpec) {
56 $attr = array("idx" => $colSpec->getIndex(), "name" => $colSpec->getName());
57
58 $this->xmlElement("colspec", $attr, null);
59 }
60 $this->xmlEndTag("colspecs");
61 }
62
63 private function buildRows(): void
64 {
65 $this->xmlStartTag("rows");
66 foreach ($this->xmlResultSet->getRows() as $row) {
67 $this->appendRow($row);
68 }
69 $this->xmlEndTag("rows");
70 }
71
72 private function appendRow(ilXMLResultSetRow $xmlResultSetRow): void
73 {
74 $this->xmlStartTag('row', null);
75 foreach ($xmlResultSetRow->getColumns() as $value) {
76 $this->xmlElement('column', null, $value);
77 }
78 $this->xmlEndTag('row');
79 }
80
81 private function buildFooter(): void
82 {
83 $this->xmlEndTag('result');
84 }
85
86 public function getXML(): string
87 {
88 return $this->xmlDumpMem(false);
89 }
90}
Row Class for XMLResultSet.
XML Writer for XMLResultSet.
appendRow(ilXMLResultSetRow $xmlResultSetRow)
__construct(ilXMLResultSet $xmlResultSet)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlHeader()
Writes xml header.
xmlEndTag(string $tag)
Writes an endtag.
xmlSetDtdDef(string $dtdDef)
Sets dtd definition.
xmlDumpMem(bool $format=true)
Returns xml document from memory.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc