public static function embedAssets($originalXml)
    {
        $basedir = dirname($originalXml) . DIRECTORY_SEPARATOR;

        $xmlDocument = new XmlDocument();
        $xmlDocument->load($originalXml, true);

        //get images and object to base64 their src/data
        $images = $xmlDocument->getDocumentComponent()->getComponentsByClassName('img');
        $objects = $xmlDocument->getDocumentComponent()->getComponentsByClassName('object');

        /** @var $image \qtism\data\content\xhtml\Img */
        foreach ($images as $image) {
            $source = $image->getSrc();
            static::validateSource($basedir, $source);
            $image->setSrc(self::secureEncode($basedir, $source));
        }

        /** @var $object \qtism\data\content\xhtml\Object */
        foreach ($objects as $object) {
            $data = $object->getData();
            static::validateSource($basedir, $data);
            $object->setData(self::secureEncode($basedir, $data));
        }

        // save the document to a tempfile
        $newXml = tempnam(sys_get_temp_dir(), 'sharedStimulus_') . '.xml';
        $xmlDocument->save($newXml);
        return $newXml;
    }