public function getRdfString($instances)
    {
        $api = core_kernel_impl_ApiModelOO::singleton();
        $rdf = '';
        $xmls = [];
        foreach ($instances as $instance) {
            $xmls[] = $api->getResourceDescriptionXML($instance->getUri());
        }

        if (count($xmls) === 1) {
            $rdf = $xmls[0];
        } elseif (count($xmls) > 1) {

            $baseDom = new DomDocument();
            $baseDom->formatOutput = true;
            $baseDom->loadXML($xmls[0]);

            for ($i = 1, $iMax = count($xmls); $i < $iMax; $i++) {

                $xmlDoc = new SimpleXMLElement($xmls[$i]);
                foreach ($xmlDoc->getNamespaces() as $nsName => $nsUri) {
                    if (!$baseDom->documentElement->hasAttribute('xmlns:' . $nsName)) {
                        $baseDom->documentElement->setAttribute('xmlns:' . $nsName, $nsUri);
                    }
                }
                $newDom = new DOMDocument();
                $newDom->loadXML($xmls[$i]);
                foreach ($newDom->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'Description') as $desc) {
                    $newNode = $baseDom->importNode($desc, true);
                    $baseDom->documentElement->appendChild($newNode);
                }
            }

            $rdf = $baseDom->saveXML();
        }

        return $rdf;
    }
public function getRdfString($instances)
    {
        $api = core_kernel_impl_ApiModelOO::singleton();
        $rdf = '';
        $xmls = [];
        foreach ($instances as $instance) {
            $xmls[] = $api->getResourceDescriptionXML($instance->getUri());
        }

        if (count($xmls) === 1) {
            $rdf = $xmls[0];
        } elseif (count($xmls) > 1) {

            $baseDom = new DomDocument();
            $baseDom->formatOutput = true;
            $baseDom->loadXML($xmls[0]);

            for ($i = 1, $iMax = count($xmls); $i < $iMax; $i++) {

                $xmlDoc = new SimpleXMLElement($xmls[$i]);
                foreach ($xmlDoc->getNamespaces() as $nsName => $nsUri) {
                    if (!$baseDom->documentElement->hasAttribute('xmlns:' . $nsName)) {
                        $baseDom->documentElement->setAttribute('xmlns:' . $nsName, $nsUri);
                    }
                }
                $newDom = new DOMDocument();
                $newDom->loadXML($xmls[$i]);
                foreach ($newDom->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'Description') as $desc) {
                    $newNode = $baseDom->importNode($desc, true);
                    $baseDom->documentElement->appendChild($newNode);
                }
            }

            $rdf = $baseDom->saveXML();
        }

        return $rdf;
    }
public function getRdfString ( $ instances ) { $ api = core_kernel_impl_ApiModelOO :: singleton ( ) ; $ rdf = '' ; $ xmls = [ ] ; foreach ( $ instances as $ instance ) { $ xmls [ ] = $ api -> getResourceDescriptionXML ( $ instance -> getUri ( ) ) ; } if ( count ( $ xmls ) === 1 ) { $ rdf = $ xmls [ 0 ] ; } elseif ( count ( $ xmls ) > 1 ) { $ baseDom = new DomDocument ( ) ; $ baseDom -> formatOutput = true ; $ baseDom -> loadXML ( $ xmls [ 0 ] ) ; for ( $ i = 1 , $ iMax = count ( $ xmls ) ; $ i < $ iMax ; $ i ++ ) { $ xmlDoc = new SimpleXMLElement ( $ xmls [ $ i ] ) ; foreach ( $ xmlDoc -> getNamespaces ( ) as $ nsName => $ nsUri ) { if ( ! $ baseDom -> documentElement -> hasAttribute ( 'xmlns:' . $ nsName ) ) { $ baseDom -> documentElement -> setAttribute ( 'xmlns:' . $ nsName , $ nsUri ) ; } } $ newDom = new DOMDocument ( ) ; $ newDom -> loadXML ( $ xmls [ $ i ] ) ; foreach ( $ newDom -> getElementsByTagNameNS ( 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' , 'Description' ) as $ desc ) { $ newNode = $ baseDom -> importNode ( $ desc , true ) ; $ baseDom -> documentElement -> appendChild ( $ newNode ) ; } } $ rdf = $ baseDom -> saveXML ( ) ; } return $ rdf ; }
Exports an array of instances into an rdf string.

@param array $instances
@return string
Exports an array of instances into an rdf string .