public function buildDomDocument($xsltFileName) { $xslt = new DomDocument(); if (file_exists($xsltFileName . '_custom.xslt')) { $xslt->load($xsltFileName . '_custom.xslt'); } else { $xslt->load($xsltFileName . '.xslt'); } return $xslt; }
function get_document($aNode) { //get the directory in which the documents are contained from the config.php file global $xml_dir, $html_dir, $xslt, $html_xslt; //create the xslt $xp = new XsltProcessor(); // create a DOM document and load the XSL stylesheet $xsl = new DomDocument(); $xsl->load($xslt); // import the XSL styelsheet into the XSLT process $xp->importStylesheet($xsl); //open the xml document $xml = new DomDocument(); $xml->loadXML($aNode); //transform if ($html = $xp->transformToXML($xml)) { $return = str_replace('<?xml version="1.0"?>' . "\n", "", $html); $return = str_replace('<!DOCTYPE div PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' . "\n", "", $return); $return = str_replace("\n", "", $return); $return = str_replace("\n ", "", $return); return str_replace("\t", "", $return); } else { trigger_error('XSL transformation failed.', E_USER_ERROR); } }
function pullStats($set) { $xp = new XsltProcessor(); // create a DOM document and load the XSL stylesheet $xsl = new DomDocument(); $xsl->load('stats.xslt'); // import the XSL styelsheet into the XSLT process $xp->importStylesheet($xsl); // create a DOM document and load the XML datat $xml_doc = new DomDocument(); $xml_doc->load('xmlcache/' . $set . '.xml'); // transform the XML into HTML using the XSL file if ($xml = $xp->transformToXML($xml_doc)) { $stats_xml = simplexml_load_string($xml); $temp_bottom = array(); $temp_top = array(); foreach ($stats_xml->top as $top) { array_push($temp_top, (string) $top); } foreach ($stats_xml->bottom as $bottom) { array_push($temp_bottom, (string) $bottom); } $temp_return = array('bottom' => $temp_bottom, 'top' => $temp_top, 'total' => (string) $stats_xml->total); return $temp_return; } }
public function render() { eval("\$this->content = \$this->parse{$this->requesttype}();"); $this->checkFor404(); if ($this->format === 'object') { $this->printObject($this); } else { ob_start(); $file = $this->root . '/lib/xml/pigment.xml'; echo '<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n"; if (is_file($file)) { include $file; } $xml = ob_get_contents(); ob_end_clean(); } if ($this->format === 'xml') { $type = $this->getHeader('xml'); header("Content-Type: {$type}"); echo $xml; } else { if ($this->format === 'default') { if ($this->requesttype === 'Content') { $type = $this->getHeader('xml'); $file = "{$this->root}/lib/xsl/{$this->version}.xsl"; if (!is_file($file)) { $file = "{$this->root}/lib/xsl/default.xsl"; } $xmldoc = DOMDocument::loadXML($xml); $xsldoc = new DomDocument(); $xsldoc->load($file); $proc = new XSLTProcessor(); $proc->registerPHPFunctions(); $proc->importStyleSheet($xsldoc); $output = $proc->transformToXML($xmldoc); $selector = '</html>'; if (strstr($output, $selector)) { $exp = explode($selector, $output); $uri = $_SERVER['REQUEST_URI']; $delim = strstr($uri, '?') ? '&' : '?'; $track = '<object type="text/html" width="1" height="1" data="' . $uri . $delim . 'log"></object>'; $output = implode($track . '</html>', $exp); } } else { $output = $this->content; } } } if (isset($output)) { if (isset($this->is404) && $this->is404 === true) { header(' ', true, 404); } else { header("Content-Type: {$this->header}"); } echo $output; if ($this->preferences['cache'] && !isset($this->querystring) && !isset($this->is404)) { $this->cache($output); } } }
function get_xml_droits() { if (!is_file(PATH_ROOT . 'inc/droits.xml')) { return array(); } $dom = new DomDocument("1.0", "UTF-8"); $dom->load(PATH_ROOT . 'inc/droits.xml'); $elements = $dom->getElementsByTagName('droits'); $arbre = $elements->item(0); $array_droit = array(); $sections = $arbre->childNodes; foreach ($sections as $section) { if ($section->nodeName == "section") { $nom_section = $section->attributes->getNamedItem("name")->nodeValue; $array_droit[$nom_section] = array(); $droits = $section->childNodes; foreach ($droits as $droit) { if ($droit->nodeName == "droit") { $infos_droit = $droit->childNodes; $nom_droit = $droit->getElementsByTagName("name")->item(0)->nodeValue; $type_droit = $droit->getElementsByTagName("type")->item(0)->nodeValue; $array_droit[$nom_section][$nom_droit] = array($type_droit); } } } } return $array_droit; }
protected function table($doName) { $doName = substr($doName, 1); $doName = $this->getFormObj()->getElement($doName)->m_Value; // get the dataobj file $metaFileInfo = $this->getFormObj()->GetMetaFileInfo(); if (!$metaFileInfo) { return ""; } //echo "meta file info:"; print_r($metaFileInfo); if ($doName && !strpos($doName, ".") && $metaFileInfo['package']) { // no package prefix as package.object, add it $doName = $metaFileInfo['package'] . "." . $doName; } $doFile = $metaFileInfo['modules_path'] . str_replace(".", "/", $doName) . '.xml'; // get the fields of the dataobj $xpathStr = "/BizDataObj/@Table"; if (!file_exists($doFile)) { return ""; } $doc = new DomDocument(); $ok = $doc->load($doFile); if (!$ok) { return ""; } $xpath = new DOMXPath($doc); $elems = $xpath->query($xpathStr); $tableAttr = $elems->item(0); $table = $tableAttr->value; return $table; }
public function TeiDisplay($file, array $options = array()) { if ($file->getExtension() != "xml") { return ""; } //queue_css_file('tei_display_public', 'screen', false, "plugins/TeiDisplay/views/public/css"); //echo "<h3>displaying ", $file->original_filename, "</h3><br/>"; $files = $file->getItem()->Files; foreach ($files as $f) { if ($f->getExtension() == "xsl") { $xsl_file = $f; } if ($f->getExtension() == "css") { $css_file = $f; } } //queue_css_url($css_file->getWebPath()); echo '<link rel="stylesheet" media="screen" href="' . $css_file->getWebPath() . '"/>'; //echo "transforming with ", $xsl_file->original_filename, "<br/>"; $xp = new XsltProcessor(); $xsl = new DomDocument(); //echo "loading ", "files/original/".$xsl_file->filename, "<br/>"; $xsl->load("files/original/" . $xsl_file->filename); $xp->importStylesheet($xsl); $xml_doc = new DomDocument(); //echo "loading ", "files/original/".$file->filename, "<br/>"; $xml_doc->load("files/original/" . $file->filename); try { if ($doc = $xp->transformToXML($xml_doc)) { return $doc; } } catch (Exception $e) { $this->view->error = $e->getMessage(); } }
/** * Read from file */ function load(&$ctx) { $dom = new DomDocument(); $dom->load($this->path); $dom->xinclude(); $this->xml = simplexml_import_dom($dom); }
function civicrm_diagnostic() { require_once '../civicrm.config.php'; require_once 'CRM/Core/Config.php'; $config =& new CRM_Core_Config(); $drupalPath = explode('/', $config->templateCompileDir); $pathArray = array(); foreach ($drupalPath as $path) { if ($path == 'files') { break; } $pathArray[] = $path; } $drupalPath = implode('/', $pathArray); $PHPVersion = phpversion(); $mysqlPath = $config->mysqlPath; $mysqlVersion = exec($mysqlPath . 'mysql --version'); $versionFile = "../xml/version.xml"; $dom = DomDocument::load($versionFile); $dom->xinclude(); $versionXML = simplexml_import_dom($dom); $civicrmVersion = $versionXML->version_no; $f = fopen($drupalPath . '/CHANGELOG.txt', 'r'); list(, $version) = explode(' ', fgets($f, 13)); fclose($f); $drupalVersion = $version; //echo "PHP Version : ".$PHPVersion."\n"; //echo "MySQL Version : ".$mysqlVersion."\n"; //echo "CiviCRM Version : ".$civicrmVersion."\n"; //echo "Drupal Version : ".$drupalVersion."\n"; return $returnString = "PHP Version:" . $PHPVersion . "<br>" . "MySQL Version:" . $mysqlVersion . "<br>" . "CiviCRM Version:" . $civicrmVersion . "<br>" . "Drupal Version:" . $drupalVersion . "<br>"; }
public function ovfImport($url, $xpath = false) { $this->url = $url; $dom = new DomDocument(); $loaded = $dom->load($url); if (!$loaded) { return $loaded; } $xpath = new DomXPath($dom); // register the namespace $xpath->registerNamespace('envl', 'http://schemas.dmtf.org/ovf/envelope/1'); $vs_nodes = $xpath->query('//envl:VirtualSystem'); // selects all name element $refs_nodes = $xpath->query('//envl:References'); // selects all name element $disk_nodes = $xpath->query('//envl:DiskSection'); // selects all name element $refs_nodes_0 = $refs_nodes->item(0); $disk_nodes_0 = $disk_nodes->item(0); $vs_nodes_0 = $vs_nodes->item(0); if ($refs_nodes_0 && $disk_nodes_0 && $vs_nodes_0) { $this->buildReferences($refs_nodes_0); $this->buildDiskSection($disk_nodes_0); $this->buildVirtualSystem($vs_nodes_0); return true; } else { return false; } }
public function __construct() { if (!defined("WebOrbServicesPath")) { $dom = new DomDocument(); $dom->load(WebOrb . "weborb-config.xml"); $servicePath = $dom->documentElement->getAttribute('servicePath'); define("WebOrbServicesPath", realpath(WebOrb . $servicePath) . DIRECTORY_SEPARATOR); } if (file_exists(WebOrbServicesPath . "Weborb/Examples/Security/datbase.db")) { if (!($this->link = sqlite_open(WebOrbServicesPath . "Weborb/Examples/Security/datbase.db", 0666, $sqliteerror))) { throw new Exception($sqliteerror); } } else { if (!($this->link = sqlite_open(WebOrbServicesPath . "Weborb/Examples/Security/datbase.db", 0666, $sqliteerror))) { throw new Exception($sqliteerror); } sqlite_query($this->link, "CREATE TABLE Security ( Id INT, UserName VARCHAR(20), Password VARCHAR(20), Role VARCHAR(20) )"); sqlite_query($this->link, "INSERT INTO Security (Id, UserName, Password, Role) VALUES ( 1, 'joe', 'flexrocks', 'examplesuser' )"); sqlite_query($this->link, "INSERT INTO Security (Id, UserName, Password, Role) VALUES ( 2, 'bob', 'weborb', 'administrator' )"); sqlite_query($this->link, "CREATE TABLE Products ( Id INT, Name VARCHAR(20), Price NUMERIC )"); sqlite_query($this->link, "INSERT INTO Products (Id, Name, Price) VALUES ( 1, 'Laptop', 499 )"); sqlite_query($this->link, "INSERT INTO Products (Id, Name, Price) VALUES ( 2, 'Mouse', 20 )"); sqlite_query($this->link, "INSERT INTO Products (Id, Name, Price) VALUES ( 3, 'Keyboard', 10 )"); } }
/** * Handle provided directory * * Optionally an existing result file can be provided * * If a valid file could be generated the file name is supposed to be * returned, otherwise return null. * * @param Project $project * @param string $existingResult * * @return string */ public function handle(Project $project, $existingResult = null) { if (!isset($project->analyzers['pdepend'])) { return; } $pdependResultFile = $project->dataDir . '/' . $project->analyzers['pdepend']; $document = new \DomDocument(); $document->load($pdependResultFile); $xPath = new \DomXPath($document); foreach ($xPath->query('//package') as $packageNode) { $packageCommits = 0; foreach ($xPath->query('./class', $packageNode) as $classNode) { $fileNode = $xPath->query('./file', $classNode)->item(0); $file = $fileNode->getAttribute('name'); $classCommits = $this->countGitChangesPerFileRange($project, $file, $classNode->getAttribute('start'), $classNode->getAttribute('end')); $packageCommits += $classCommits; $classNode->setAttribute('commits', $classCommits); foreach ($xPath->query('./method', $classNode) as $methodNode) { $methodCommits = $this->countGitChangesPerFileRange($project, $file, $methodNode->getAttribute('start'), $methodNode->getAttribute('end')); $methodNode->setAttribute('commits', $methodCommits); } } $packageNode->setAttribute('commits', $packageCommits); } $document->save($pdependResultFile); return null; }
protected function readDataBlock() { $v9a09b4dfda82e3e665e31092d1c3ec8d = DomDocument::load($this->file_path); $this->offset = 0; $this->complete = true; return $v9a09b4dfda82e3e665e31092d1c3ec8d; }
function search($query) { $this->url .= "&q=" . urlencode($query); $xml = new \DomDocument(); $xml->load($this->url); return $xml; }
function retrieve($caseType) { require_once 'CRM/Utils/String.php'; require_once 'CRM/Utils/Array.php'; // trim all spaces from $caseType $caseType = str_replace('_', ' ', $caseType); $caseType = CRM_Utils_String::munge(ucwords($caseType), '', 0); if (!CRM_Utils_Array::value($caseType, self::$_xml)) { if (!self::$_xml) { self::$_xml = array(); } // first check custom templates directory $fileName = null; $config = CRM_Core_Config::singleton(); if (isset($config->customTemplateDir) && $config->customTemplateDir) { // check if the file exists in the custom templates directory $fileName = implode(DIRECTORY_SEPARATOR, array($config->customTemplateDir, 'CRM', 'Case', 'xml', 'configuration', "{$caseType}.xml")); } if (!$fileName || !file_exists($fileName)) { // check if file exists locally $fileName = implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), 'xml', 'configuration', "{$caseType}.xml")); if (!file_exists($fileName)) { return false; } } // read xml file $dom = DomDocument::load($fileName); $dom->xinclude(); self::$_xml[$caseType] = simplexml_import_dom($dom); } return self::$_xml[$caseType]; }
function process($xml) { /* load xsl*/ $filter = true; //remember edit on js file if ($filter) { $xmlSession = $_SESSION["process"]; //$xmlSession = simplexml_load_string($xmlSession); $xml = new DOMDocument(); $xml->loadXML($xmlSession); $fileXSLPath = $GLOBALS["fileXSL_process"]; $xslDoc = new DomDocument(); $xslDoc->load($fileXSLPath); //combine xsl into xml $proc = new XSLTProcessor(); $proc->importStyleSheet($xslDoc); $xmlTrans = $proc->transformToXML($xml); $xmlTrans = simplexml_load_string($xmlTrans); $resultXml = $xmlTrans->saveXML(); processFile($xml); echo $resultXml; } else { echo $xml->saveXML(); //way 2 //echo $xml->asXML(); } }
public function recuperePodcast($url_flux, $nom_abonnement) { if (!empty($url_flux) && !empty($nom_abonnement)) { //On recupere le nom de l'abonnement $nom_abo = $nom_abonnement; //On recupère le flux RSS $flux = new DomDocument(); $flux->load($url_flux); $flux->preservedWhiteSpace = false; $i = 0; $pc = $flux->getElementsByTagName('item')->item($i); while (!is_null($pc)) { $titre = mysql_real_escape_string($pc->getElementsByTagName('title')->item(0)->nodeValue); $date = mysql_real_escape_string($pc->getElementsByTagName('pubDate')->item(0)->nodeValue); $desc = mysql_real_escape_string($pc->getElementsByTagName('description')->item(0)->nodeValue); $auteur = mysql_real_escape_string($pc->getElementsByTagName('author')->item(0)->nodeValue); $categ = mysql_real_escape_string($pc->getElementsByTagName('category')->item(0)->nodeValue); $url = mysql_real_escape_string($pc->getElementsByTagName('enclosure')->item(0)->getAttribute('url')); //Ajout base $sql = "INSERT INTO podcast(titre,auteur,date,description,url,id_genre,comments) VALUES('{$titre}','{$auteur}', '{$date}', '{$desc}', '{$url}', '{$categ}',' rien ')"; @mysql_query($sql) or die('Erreur requete SQL' . " " . mysql_error()); $id_podcast = mysql_insert_id(); $sql2 = "INSERT INTO abonnement(id_util,id_pod,url,nom_abo) VALUES('1','{$id_podcast}', '{$url_flux}', '{$nom_abo}')"; @mysql_query($sql2) or die('Erreur requete SQL' . " " . mysql_error()); $i = $i + 1; $pc = $flux->getElementsByTagName('item')->item($i); } } }
function getXMLSing($xmlHon,$priv_key){ //Carga Certificado $xml = new DomDocument(); $xml->loadXML($xmlHon); //Carga prosedimiento de proceso de cadena original $xsl = new DomDocument; $xsl->load("ostring.xsl"); $proc = new xsltprocessor(); $proc->importStyleSheet($xsl); $original =$proc->transformToXML($xml); //firma la cadena original //$fp = $cert[0]['certificates']['key']; //$priv_key = $f['key']; //die($f['key']); //fclose($fp); $pkeyid = openssl_get_privatekey($priv_key); openssl_sign($original, $signature, $pkeyid,OPENSSL_ALGO_MD5); openssl_free_key($pkeyid); //coloca el sello en xml $esqueletonew=$xmlHon; $esqueletonew=str_replace("#1#",base64_encode($signature),$esqueletonew); $xmlReturn[1]=$esqueletonew; $xmlReturn[2]=$original; $xmlReturn[3]=base64_encode($signature); return $xmlReturn; }
function parse() { //echo 'tesss'; $file = 'catalogue.xml'; $dom = new DomDocument(); $dom->load(TMP . 'uploads' . DS . $file); $root = $dom->documentElement; $root2 = $root; $k = 0; $project111_gifts = array(); $this->process_children($root, &$project111_gifts); //echo '<p>end of process childern</p>'; $project111_tree = array(); $i = 0; $this->make_tree($root, &$project111_tree, &$i); //echo '<div style="color: red">'; $project111_gifts_tree = array(); $j = 0; $page_root2 = $root2->getElementsByTagName('page')->item(0); $this->make_prod_struc($page_root2, &$project111_gifts_tree, &$j); //debug($k); //debug($project111_gifts); //debug($project111_tree); //debug($project111_gifts_tree); debug($i); debug($j); //$this->_save_marking($project111_gifts); //$this->_save_category($project111_tree); $this->_save_gift($project111_gifts, $project111_gifts_tree); }
function run($file) { require_once 'CRM/Core/DAO/CustomGroup.php'; require_once 'CRM/Core/DAO/CustomField.php'; require_once 'CRM/Core/DAO/OptionValue.php'; // read xml file $dom = DomDocument::load($file); $dom->xinclude(); $xml = simplexml_import_dom($dom); $idMap = array('custom_group' => array(), 'option_group' => array()); // first create option groups and values if any $this->optionGroups($xml, $idMap); $this->optionValues($xml, $idMap); $this->relationshipTypes($xml); $this->contributionTypes($xml); // now create custom groups $this->customGroups($xml, $idMap); $this->customFields($xml, $idMap); // now create profile groups $this->profileGroups($xml, $idMap); $this->profileFields($xml, $idMap); $this->profileJoins($xml, $idMap); //create DB Template String sample data $this->dbTemplateString($xml, $idMap); }
/** * Metainformation catalogue * -------------------------------------------------- * * Lib_XML for MicKa * * @link http://www.bnhelp.cz * @package Micka * @category Metadata * @version 20121206 * */ function applyTemplate($xmlSource, $xsltemplate) { $rs = FALSE; if (File_Exists(CSW_XSL . '/' . $xsltemplate)) { if (!extension_loaded("xsl")) { if (substr(PHP_OS, 0, 3) == "WIN") { dl("php_xsl.dll"); } else { dl("php_xsl.so"); } } $xp = new XsltProcessor(); $xml = new DomDocument(); $xsl = new DomDocument(); $xml->loadXML($xmlSource); $xsl->load(CSW_XSL . '/' . $xsltemplate); $xp->importStyleSheet($xsl); //$xp->setParameter("","lang",$lang); $xp->setParameter("", "user", $_SESSION['u']); $rs = $xp->transformToXml($xml); } if ($rs === FALSE) { setMickaLog('applyTemplate === FALSE', 'ERROR', 'micka_lib_xml.php'); } return $rs; }
function getImportantActs($xml_url, $xsl_filename, $n_nodes) { try { // read the xml from url $xmldoc = new DomDocument(); $xmldoc->load($xml_url); // read xslt file $xsldoc = new DomDocument(); $xsldoc->load($xsl_filename); $xsl = new XSLTProcessor(); $xsl->importStyleSheet($xsldoc); // trasforma XML secondo l'XSLT ed estrae il contenuto del div $transformed_xml = new SimpleXMLElement($xsl->transformToXML($xmldoc)); $nodes = $transformed_xml->children(); // write values to screen $cnt = 0; foreach ($nodes as $node) { $cnt++; $atto = OppAttoPeer::retrieveByPK($node['atto_id']); printf("\t%d. %s => %f\n", $cnt, $atto->getTitoloCompleto(), $node['totale']); if ($cnt >= $n_nodes) { break; } } } catch (Exception $e) { printf("Errore durante la scrittura del file: %s\n", $e->getMessage()); } }
function xslt_process($xsltproc, $xml_arg, $xsl_arg, $xslcontainer = null, $args = null, $params = null) { // Create instances of the DomDocument class $xml = new DomDocument(); $xsl = new DomDocument(); // Load the xml document and the xsl template $xml->load($xml_arg); $xsl->load($xsl_arg); // Load the xsl template $xsltproc->importStyleSheet($xsl); // Set parameters when defined if ($params) { foreach ($params as $param => $value) { $xsltproc->setParameter("", $param, $value); } } // Start the transformation $processed = $xsltproc->transformToXML($xml); // Put the result in a file when specified if ($xslcontainer) { return file_put_contents($xslcontainer, $processed); } else { return $processed; } }
/** * @param string $file * Path to input. * * @return SimpleXMLElement|bool */ public static function parse($file) { $dom = new DomDocument(); $dom->load($file); $dom->xinclude(); $xml = simplexml_import_dom($dom); return $xml; }
function xmltransform($xml, $xslt_f) { $xslt = new XSLTProcessor(); $xmldoc = DomDocument::loadXML($xml, LIBXML_COMPACT); $xsltdoc = DomDocument::load($xslt_f, LIBXML_COMPACT); $xslt->importStylesheet($xsltdoc); return $xslt->transformToXML($xmldoc); }
/** * Retorna um array com parâmetros extraidos de um arquivo xml do vimeo. * * @param string $id * @access public * @return array - Lista de parâmetros para exibição de vídeos vimeo. */ private function getClipInfo($id) { $clip = DomDocument::load('http://vimeo.com/api/clip/' . $id . '.xml'); if (!$clip) { return; } return array('clip_id' => $id, 'title' => $clip->getElementsByTagName("title")->item(0)->nodeValue, 'caption' => $clip->getElementsByTagName("caption")->item(0)->nodeValue, 'thumbnail_url' => $clip->getElementsByTagName("thumbnail_large")->item(0)->nodeValue, 'thumbnail_width' => 100, 'thumbnail_height' => 100, 'width' => $clip->getElementsByTagName("width")->item(0)->nodeValue, 'height' => $clip->getElementsByTagName("height")->item(0)->nodeValue, 'duration' => $clip->getElementsByTagName("duration")->item(0)->nodeValue, 'plays' => $clip->getElementsByTagName("stats_number_of_plays")->item(0)->nodeValue, 'user_name' => $clip->getElementsByTagName("user_name")->item(0)->nodeValue, 'user_url' => $clip->getElementsByTagName("user_url")->item(0)->nodeValue, 'last_updated' => time()); }
function render($controller_name, $layout_template = false) { parent::parse($controller_name, $layout_template); $xsl = new DomDocument(); $xsl->load($this->template); $proc = new xsltprocessor(); $proc->importStyleSheet($xsl); echo $proc->transformToXML($this->props_to_xml()); }
function pubmed_metadata($pmid, &$item) { global $debug; $ok = false; $url = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?' . 'retmode=xml' . '&db=pubmed' . '&id=' . $pmid; //echo $url; $xml = get($url); //echo $xml; if (preg_match('/<\\?xml /', $xml)) { $ok = true; if ($debug) { echo $xml; } $dom = new DOMDocument(); $dom->loadXML($xml); $xpath = new DOMXPath($dom); /* $nodeCollection = $xpath->query ("//crossref/error"); foreach($nodeCollection as $node) { $ok = false; } if ($ok) {*/ // Get JSON $xp = new XsltProcessor(); $xsl = new DomDocument(); $xsl->load('xsl/pubmed2JSON.xsl'); $xp->importStylesheet($xsl); $xml_doc = new DOMDocument(); $xml_doc->loadXML($xml); $json = $xp->transformToXML($xml_doc); //echo $json; $item = json_decode($json); // post process // Ensure metadata is OK (assumes a journal for now) if (!isset($item->issn)) { $issn = ''; if (isset($item->title)) { $issn = issn_from_journal_title($item->title); } if ($issn == '') { if (isset($item->eissn)) { $issn = $item->eissn; } } if ($issn != '') { $item->issn = $issn; } } if ($debug) { echo '<h3>Boo</h3>'; print_r($item); } } return $ok; }
/** * translate xml string * * @param string $xml_string * @param string $xsl_name * @param string $params * @param string $php_functions * @return void * @author Andy Bennett */ public static function translate_string($xml_string, $xsl_name, $params = array(), $php_functions = null) { $xsl_path = Kohana::find_file('xsl', $xsl_name, TRUE, 'xsl'); /* load the xml file and stylesheet as domdocuments */ $xsl = new DomDocument(); $xsl->load($xsl_path); $inputdom = new DomDocument(); $inputdom->loadXML($xml_string); return self::translate($inputdom, $xsl, $params, $php_functions); }
public function testExportDemo() { $fname = "../../docs/export-demo.xml"; $version = WikiExporter::schemaVersion(); $dom = new DomDocument(); $dom->load($fname); // Ensure, the demo is for the current version $this->assertEquals($dom->documentElement->getAttribute('version'), $version, 'export-demo.xml should have the current version'); $this->assertTrue($dom->schemaValidate("../../docs/export-" . $version . ".xsd"), "schemaValidate has found an error"); }