Skip to content

Commit cf8d29d

Browse files
committed
Use XML Attribute-class to set namespace attribute
1 parent 9882e35 commit cf8d29d

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/XML/TypedTextContentTrait.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Dom;
88
use SimpleSAML\XML\Assert\Assert;
9+
use SimpleSAML\XML\Attribute as XMLAttribute;
910
use SimpleSAML\XML\Constants as C;
1011
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
1112
use SimpleSAML\XMLSchema\Exception\InvalidValueTypeException;
@@ -100,12 +101,14 @@ public function toXML(?Dom\Element $parent = null): Dom\Element
100101
$e = $this->instantiateParentElement($parent);
101102

102103
if ($this->getTextContentType() === QNameValue::class) {
103-
if (!$e->lookupPrefix($this->getContent()->getNamespaceURI()->getValue())) {
104-
$e->setAttributeNS(
104+
if (!$e->lookupPrefix($this->getContent()->getNamespacePrefix()->getValue())) {
105+
$namespace = new XMLAttribute(
105106
C::NS_XMLNS,
106-
'xmlns:' . $this->getContent()->getNamespacePrefix()->getValue(),
107-
$this->getContent()->getNamespaceURI()->getValue(),
107+
'xmlns',
108+
$this->getContent()->getNamespacePrefix()->getValue(),
109+
$this->getContent()->getNamespaceURI(),
108110
);
111+
$namespace->toXML($e);
109112
}
110113
}
111114

0 commit comments

Comments
 (0)