Skip to content

Commit

Permalink
Append namespace-attribute when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Jan 27, 2025
1 parent 6b5f5f6 commit a4b09c7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/TypedTextContentTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ public function getContent(): ValueTypeInterface
public function toXML(?DOMElement $parent = null): DOMElement
{
$e = $this->instantiateParentElement($parent);

if ($this->getTextContentType() === QNameValue::class) {
if (!$e->lookupPrefix($this->getContent()->getNamespaceURI()->getValue())) {
$e->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:' . $this->getContent()->getNamespacePrefix()->getValue(),
$this->getContent()->getNamespaceURI()->getValue(),
);
}
}

$e->textContent = strval($this->getContent());

return $e;
Expand Down

0 comments on commit a4b09c7

Please sign in to comment.