File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88use SimpleSAML \XML \Assert \Assert ;
99use SimpleSAML \XML \Constants as C ;
1010use SimpleSAML \XMLSchema \Type \Interface \ValueTypeInterface ;
11+ use SimpleSAML \XMLSchema \Type \QNameValue ;
1112use SimpleSAML \XMLSchema \Type \StringValue ;
1213
1314use function array_keys ;
@@ -111,6 +112,20 @@ public function toXML(Dom\Element $parent): Dom\Element
111112 strval ($ this ->getAttrValue ()),
112113 );
113114
115+ // An xsi:type attribute (but really any attribute) that contains a QNameValue must also have
116+ // a namespace-declaration for the prefix within the scope of the element
117+ $ qName = $ this ->getAttrValue ();
118+ if ($ qName instanceof QNameValue) {
119+ $ qNamePrefix = $ qName ->getNamespacePrefix ();
120+ if ($ qNamePrefix !== null && !$ parent ->lookupPrefix ($ qNamePrefix ->getValue ())) {
121+ $ parent ->setAttributeNS (
122+ C::NS_XMLNS ,
123+ 'xmlns: ' . $ qNamePrefix ->getValue (),
124+ $ qName ->getNamespaceURI ()->getValue (),
125+ );
126+ }
127+ }
128+
114129 return $ parent ;
115130 }
116131
You can’t perform that action at this time.
0 commit comments