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(null, LIBXML_NOEMPTYTAG));
        
        return $xincludes;
    }
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(null, LIBXML_NOEMPTYTAG));
        
        return $xincludes;
    }
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 ( null , LIBXML_NOEMPTYTAG ) ) ; return $ xincludes ; }
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
Parse and load xinclude located in custom element markup