Skip to content

Commit a4b09c7

Browse files
committed
Append namespace-attribute when necessary
1 parent 6b5f5f6 commit a4b09c7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/TypedTextContentTrait.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ public function getContent(): ValueTypeInterface
7171
public function toXML(?DOMElement $parent = null): DOMElement
7272
{
7373
$e = $this->instantiateParentElement($parent);
74+
75+
if ($this->getTextContentType() === QNameValue::class) {
76+
if (!$e->lookupPrefix($this->getContent()->getNamespaceURI()->getValue())) {
77+
$e->setAttributeNS(
78+
'http://www.w3.org/2000/xmlns/',
79+
'xmlns:' . $this->getContent()->getNamespacePrefix()->getValue(),
80+
$this->getContent()->getNamespaceURI()->getValue(),
81+
);
82+
}
83+
}
84+
7485
$e->textContent = strval($this->getContent());
7586

7687
return $e;

0 commit comments

Comments
 (0)