protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') { try { $dom = $component->getXml(); $node = $fragment->ownerDocument->importNode($dom->documentElement, true); $node = Utils::anonimizeElement($node); $node->setAttribute('xmlns', 'http://www.w3.org/1998/Math/MathML'); $fragment->appendChild($node); } catch (RuntimeException $e) { $msg = "An error occured while rendering the XML content of the 'MathML' external component."; throw new RenderingException($msg, RenderingException::UNKNOWN, $e); } }
/** * @see \qtism\runtime\rendering\markup\xhtml\ExternalQtiComponentRenderer::appendChildren() */ protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') { try { $dom = $component->getXml(); $node = $fragment->ownerDocument->importNode($dom->documentElement, true); $nodeNamespaceUri = $node->namespaceURI; $node = Utils::anonimizeElement($node); if ($this->mustNamespaceOutput() === true) { $node->setAttribute('xmlns', $nodeNamespaceUri); } $fragment->appendChild($node); } catch (RuntimeException $e) { $msg = "An error occured while rendering the XML content of the 'MathML' external component."; throw new RenderingException($msg, RenderingException::UNKNOWN, $e); } }
/** * * @param string $originalXmlString * @param string $expectedXmlString * @dataProvider anonimizeElementProvider */ public function testAnonimizeElement($originalXmlString, $expectedXmlString) { $elt = $this->createDOMElement($originalXmlString); $newElt = Utils::anonimizeElement($elt); $this->assertEquals($expectedXmlString, $newElt->ownerDocument->saveXML($newElt)); }