ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Xml.php
Go to the documentation of this file.
1<?php
3
4class Xml extends Exporter
5{
9 protected static function toStringDo($languages)
10 {
11 $xml = new \DOMDocument('1.0', 'UTF-8');
12 $xml->loadXML('<languages
13 xmlns="https://github.com/mlocati/cldr-to-gettext-plural-rules"
14 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
15 xsi:schemaLocation="https://github.com/mlocati/cldr-to-gettext-plural-rules http://mlocati.github.io/cldr-to-gettext-plural-rules/GettextLanguages.xsd"
16 />');
17 $xLanguages = $xml->firstChild;
18 foreach ($languages as $language) {
19 $xLanguage = $xml->createElement('language');
20 $xLanguage->setAttribute('id', $language->id);
21 $xLanguage->setAttribute('name', $language->name);
22 if (isset($language->supersededBy)) {
23 $xLanguage->setAttribute('supersededBy', $language->supersededBy);
24 }
25 if (isset($language->script)) {
26 $xLanguage->setAttribute('script', $language->script);
27 }
28 if (isset($language->territory)) {
29 $xLanguage->setAttribute('territory', $language->territory);
30 }
31 if (isset($language->baseLanguage)) {
32 $xLanguage->setAttribute('baseLanguage', $language->baseLanguage);
33 }
34 $xLanguage->setAttribute('formula', $language->formula);
35 foreach ($language->categories as $category) {
36 $xCategory = $xml->createElement('category');
37 $xCategory->setAttribute('id', $category->id);
38 $xCategory->setAttribute('examples', $category->examples);
39 $xLanguage->appendChild($xCategory);
40 }
41 $xLanguages->appendChild($xLanguage);
42 }
43 $xml->formatOutput = true;
44
45 return $xml->saveXML();
46 }
50 public static function getDescription()
51 {
52 return 'Build an XML file - schema available at http://mlocati.github.io/cldr-to-gettext-plural-rules/GettextLanguages.xsd';
53 }
54}
An exception for terminatinating execution or to throw for unit testing.
Base class for all the exporters.
Definition: Exporter.php:11
static toStringDo($languages)
Definition: Xml.php:9
$xml
Definition: metadata.php:240