protected function getTemplateQtiVariables()
 {
     $nsMarkup = 'html5';
     $variables = parent::getTemplateQtiVariables();
     $variables['libraries'] = $this->libraries;
     $variables['serializedProperties'] = $this->serializePciProperties($this->properties, self::NS_NAME);
     $variables['entryPoint'] = $this->entryPoint;
     $variables['typeIdentifier'] = $this->typeIdentifier;
     $variables['markup'] = preg_replace('/<(\\/)?([^!])/', '<$1' . $nsMarkup . ':$2', $variables['markup']);
     $this->getRelatedItem()->addNamespace($nsMarkup, $nsMarkup);
     return $variables;
 }
 /**
  * Parse and load xinclude located in custom element markup
  * 
  * @param CustomInteraction $customElement
  * @return array
  * @throws XIncludeException when the file in href cannot be resolved
  * @throws ParsingException when the markup cannot be loaded as xml document
  */
 private function parseCustomElementMarkup(CustomInteraction $customElement)
 {
     $xincludes = array();
     $xml = new DOMDocument();
     $xml->formatOutput = true;
     $loadSuccess = $xml->loadXML($customElement->getMarkup());
     $node = $xml->documentElement;
     if ($loadSuccess && !is_null($node)) {
         $parser = new ParserFactory($xml);
         $xincludesNodes = $parser->queryXPath(".//*[name(.)='include']");
         foreach ($xincludesNodes as $xincludeNode) {
             $href = $xincludeNode->getAttribute('href');
             $asset = $this->resolver->resolve($href);
             $filePath = $asset->getMediaSource()->download($asset->getMediaIdentifier());
             if (file_exists($filePath)) {
                 $fileContent = file_get_contents($filePath);
                 $xmlInclude = new DOMDocument();
                 $xmlInclude->formatOutput = true;
                 $xmlInclude->loadXML($fileContent);
                 foreach ($xmlInclude->documentElement->childNodes as $node) {
                     $importNode = $xml->importNode($node, true);
                     $xincludeNode->parentNode->insertBefore($importNode, $xincludeNode);
                 }
             } else {
                 throw new XIncludeException('The file referenced by href does not exist : ' . $href, $xincludeNode);
             }
             $xincludeNode->parentNode->removeChild($xincludeNode);
             $xincludes[] = $href;
         }
     } else {
         throw new ParsingException('cannot parse pci markup');
     }
     $customElement->setMarkup($xml->saveXML());
     return $xincludes;
 }