76 {
77
78
79
80 if (!$this->namespace || $this->namespace !== $directive->id->getRootNamespace()) {
81 if ($this->namespace) {
82 $this->endElement();
83 }
84 $this->namespace = $directive->id->getRootNamespace();
85 $this->startElement('namespace');
86 $this->writeAttribute('id', $this->namespace);
87 $this->writeElement('name', $this->namespace);
88 }
89
90 $this->startElement('directive');
91 $this->writeAttribute('id', $directive->id->toString());
92
93 $this->writeElement('name', $directive->id->getDirective());
94
95 $this->startElement('aliases');
96 foreach ($directive->aliases as $alias) {
97 $this->writeElement('alias', $alias->toString());
98 }
99 $this->endElement();
100
101 $this->startElement('constraints');
102 if ($directive->version) {
103 $this->writeElement('version', $directive->version);
104 }
105 $this->startElement('type');
106 if ($directive->typeAllowsNull) {
107 $this->writeAttribute('allow-null', 'yes');
108 }
109 $this->text($directive->type);
110 $this->endElement();
111 if ($directive->allowed) {
112 $this->startElement('allowed');
113 foreach ($directive->allowed as $value =>
$x) {
114 $this->writeElement('value', $value);
115 }
116 $this->endElement();
117 }
118 $this->writeElement(
'default', $this->
export($directive->default));
119 $this->writeAttribute('xml:space', 'preserve');
120 if ($directive->external) {
121 $this->startElement('external');
122 foreach ($directive->external as $project) {
123 $this->writeElement('project', $project);
124 }
125 $this->endElement();
126 }
127 $this->endElement();
128
129 if ($directive->deprecatedVersion) {
130 $this->startElement('deprecated');
131 $this->writeElement('version', $directive->deprecatedVersion);
132 $this->writeElement('use', $directive->deprecatedUse->toString());
133 $this->endElement();
134 }
135
136 $this->startElement('description');
138 $this->endElement();
139
140 $this->endElement();
141 }