function xml_xsl($xmlContent, $xslFile, $debug) { if ($xmlContent == '') { die("falta o XML"); } if ($xslFile == '') { die("falta XSL para transformar\n" . $xmlContent); } if (!file_exists($xslFile)) { die($xslFile . " not found."); } $xslt = new XSLTransformer(); $xslt->xml = $this->insertProcessingInstruction(trim($xmlContent)); if ($debug == "XML") { die($xslt->xml); } $xslt->setXsl($xslFile); if ($debug == "XSL") { die($xslt->xsl . '<!--' . $xslFile . '-->'); } $xslt->transform(); //$r = utf8_decode($xslt->getOutput()); $r = $xslt->getOutput(); return $r . $hidden; }
function _cacheMiss(&$cache, $id) { $allCodelistItems =& Registry::get('all' . $this->getListName() . 'CodelistItems', true, null); if ($allCodelistItems === null) { // Add a locale load to the debug notes. $notes =& Registry::get('system.debug.notes'); $locale = $cache->cacheId; if ($locale == null) { $locale = AppLocale::getLocale(); } $filename = $this->getFilename($locale); $notes[] = array('debug.notes.codelistItemListLoad', array('filename' => $filename)); // Reload locale registry file $xmlDao = new XMLDAO(); $listName = $this->getListName(); // i.e., 'List30' import('lib.pkp.classes.codelist.ONIXParserDOMHandler'); $handler = new ONIXParserDOMHandler($listName); import('lib.pkp.classes.xslt.XSLTransformer'); import('lib.pkp.classes.file.FileManager'); import('classes.file.TemporaryFileManager'); $temporaryFileManager = new TemporaryFileManager(); $fileManager = new FileManager(); // Ensure that the temporary file dir exists $tmpDir = $temporaryFileManager->getBasePath(); if (!file_exists($tmpDir)) { mkdir($tmpDir); } $tmpName = tempnam($tmpDir, 'ONX'); $xslTransformer = new XSLTransformer(); $xslTransformer->setParameters(array('listName' => $listName)); $xslTransformer->setRegisterPHPFunctions(true); $xslFile = 'lib/pkp/xml/onixFilter.xsl'; $filteredXml = $xslTransformer->transform($filename, XSL_TRANSFORMER_DOCTYPE_FILE, $xslFile, XSL_TRANSFORMER_DOCTYPE_FILE, XSL_TRANSFORMER_DOCTYPE_STRING); if (!$filteredXml) { assert(false); } $data = null; if (is_writeable($tmpName)) { $fp = fopen($tmpName, 'wb'); fwrite($fp, $filteredXml); fclose($fp); $data = $xmlDao->parseWithHandler($tmpName, $handler); $fileManager->deleteFile($tmpName); } else { fatalError('misconfigured directory permissions on: ' . $tmpDir); } // Build array with ($charKey => array(stuff)) if (isset($data[$listName])) { foreach ($data[$listName] as $code => $codelistData) { $allCodelistItems[$code] = $codelistData; } } if (is_array($allCodelistItems)) { asort($allCodelistItems); } $cache->setEntireCache($allCodelistItems); } return null; }
/** * Create and return a representation node. Extend the parent class * with publication format specific data. * @param $doc DOMDocument * @param $representation Representation * @return DOMElement */ function createRepresentationNode($doc, $representation) { $representationNode = parent::createRepresentationNode($doc, $representation); $representationNode->setAttribute('approved', $representation->getIsApproved() ? 'true' : 'false'); $representationNode->setAttribute('available', $representation->getIsAvailable() ? 'true' : 'false'); $representationNode->setAttribute('physical_format', $representation->getPhysicalFormat() ? 'true' : 'false'); // If all nexessary press settings exist, export ONIX metadata $context = $this->getDeployment()->getContext(); if ($context->getSetting('publisher') && $context->getSetting('location') && $context->getSetting('codeType') && $context->getSetting('codeValue')) { $submission = $this->getDeployment()->getSubmission(); $filterDao = DAORegistry::getDAO('FilterDAO'); $nativeExportFilters = $filterDao->getObjectsByGroup('monograph=>onix30-xml'); assert(count($nativeExportFilters) == 1); // Assert only a single serialization filter $exportFilter = array_shift($nativeExportFilters); $exportFilter->setDeployment(new Onix30ExportDeployment(Request::getContext(), Request::getUser())); $onixDoc = $exportFilter->execute($submission); if ($onixDoc) { // we do this to ensure validation. // assemble just the Product node we want. $publicationFormatDOMElement = $exportFilter->createProductNode($doc, $submission, $representation); if ($publicationFormatDOMElement instanceof DOMElement) { import('lib.pkp.classes.xslt.XSLTransformer'); $xslTransformer = new XSLTransformer(); $xslFile = 'plugins/importexport/native/onixProduct2NativeXml.xsl'; $productXml = $publicationFormatDOMElement->ownerDocument->saveXML($publicationFormatDOMElement); $filteredXml = $xslTransformer->transform($productXml, XSL_TRANSFORMER_DOCTYPE_STRING, $xslFile, XSL_TRANSFORMER_DOCTYPE_FILE, XSL_TRANSFORMER_DOCTYPE_STRING); $representationFragment = $doc->createDocumentFragment(); $representationFragment->appendXML($filteredXml); $representationNode->appendChild($representationFragment); } } } return $representationNode; }
/** * @copydoc Form::display */ function display($request = null, $template = null) { import('lib.pkp.classes.xslt.XSLTransformer'); $templateMgr = TemplateManager::getManager($request); $templateMgr->assign(array('localeOptions' => $this->supportedLocales, 'localesComplete' => $this->localesComplete, 'clientCharsetOptions' => $this->supportedClientCharsets, 'connectionCharsetOptions' => $this->supportedConnectionCharsets, 'databaseCharsetOptions' => $this->supportedDatabaseCharsets, 'allowFileUploads' => get_cfg_var('file_uploads') ? __('common.yes') : __('common.no'), 'maxFileUploadSize' => get_cfg_var('upload_max_filesize'), 'databaseDriverOptions' => $this->checkDBDrivers(), 'supportsMBString' => PKPString::hasMBString() ? __('common.yes') : __('common.no'), 'phpIsSupportedVersion' => version_compare(PHP_REQUIRED_VERSION, PHP_VERSION) != 1, 'xslEnabled' => XSLTransformer::checkSupport(), 'xslRequired' => REQUIRES_XSL, 'phpRequiredVersion' => PHP_REQUIRED_VERSION, 'phpVersion' => PHP_VERSION)); parent::display(); }
function xml_xsl($xml, $xsl, $debug = "") { $hidden = ''; $xslBaseUri = $this->xslBaseUri; if ($xml == '') { die("falta o XML"); } if ($xsl == '') { die("falta XSL para transformar\n"); } if ($debug == "XML") { die($xml); } if ($debug == "XSL") { die($xsl . '<!--' . $xslBaseUri . $xsl . '-->'); } if (!file_exists($xsl)) { die($xsl . " not found."); } $transform = new XSLTransformer(); if (strpos(' ' . $xml, '/') == 1 || strpos(' ' . $xml, 'http://') == 1 || strpos(' ' . $xml, 'ftp://') == 1) { } else { $xml = $this->insertProcessingInstruction(trim($xml)); } if ($xslBaseUri) { $transform->setXslBaseUri("file://" . $xslBaseUri); } if ($transform->setXml($xml) == false) { die($transform->getErrorMessage()); } if ($transform->setXsl($xsl) == false) { die($transform->getErrorMessage()); } if ($transform->transform() == false) { $r = $transform->getErrorMessage(); } else { //transform sempre retorna UTF-8 $r = $transform->getOutput(); //$r = utf8_decode($r); /* if (!$this->isUTF8($r)){ //necessario fazer utf8_decode $r = html_entity_decode($r); $r = utf8_decode($r); $r = preg_replace("/UTF-8/i",$this->find($r,' encoding="','"'),$r); } */ } //die("XML.php xml é iso?", strpos(strtolower($xml),'iso-8859-1')); //debug("XML.php r é iso?", strpos(strtolower($r),'iso-8859-1')); return $r . $hidden; }
function transform($xml, $xsl, $debug = false) { $xslt = new XSLTransformer(); $xslt->setXml($xml); $xslt->setXsl($xsl); $xslt->transform(); $error = $xslt->getError(); if ($error) { $xslt->destroy(); die($error); } $tranformation = utf8_decode($xslt->getOutput()); if ($debug) { die($tranformation); } $xslt->destroy(); return $tranformation; }
/** * Display the form. */ function display() { $templateMgr = TemplateManager::getManager($this->_request); $templateMgr->assign('localeOptions', $this->supportedLocales); $templateMgr->assign('localesComplete', $this->localesComplete); $templateMgr->assign('clientCharsetOptions', $this->supportedClientCharsets); $templateMgr->assign('connectionCharsetOptions', $this->supportedConnectionCharsets); $templateMgr->assign('databaseCharsetOptions', $this->supportedDatabaseCharsets); $templateMgr->assign('allowFileUploads', get_cfg_var('file_uploads') ? __('common.yes') : __('common.no')); $templateMgr->assign('maxFileUploadSize', get_cfg_var('upload_max_filesize')); $templateMgr->assign('databaseDriverOptions', $this->checkDBDrivers()); $templateMgr->assign('supportsMBString', PKPString::hasMBString() ? __('common.yes') : __('common.no')); $templateMgr->assign('phpIsSupportedVersion', version_compare(PHP_REQUIRED_VERSION, PHP_VERSION) != 1); import('lib.pkp.classes.xslt.XSLTransformer'); $templateMgr->assign('xslEnabled', XSLTransformer::checkSupport()); $templateMgr->assign('xslRequired', REQUIRES_XSL); $templateMgr->assign('phpRequiredVersion', PHP_REQUIRED_VERSION); $templateMgr->assign('phpVersion', PHP_VERSION); parent::display(); }
/** * Fetch configuration and check whether XSLT is properly supported. * @return boolean True iff XSLT support is present. */ static function checkSupport() { self::$externalCommand = Config::getVar('cli', 'xslt_command'); self::$externalParameterSnippet = Config::getVar('cli', 'xslt_parameter_option'); // Determine the appropriate XSLT processor for the system if (self::$externalCommand) { // check the external command to check for %xsl and %xml parameter substitution if (strpos(self::$externalCommand, '%xsl') === false) { return false; } if (strpos(self::$externalCommand, '%xml') === false) { return false; } self::$processor = 'External'; } elseif (extension_loaded('xsl') && extension_loaded('dom')) { // XSL/DOM modules present self::$processor = 'PHP'; } else { // no XSLT support return false; } }
if (!$pid == '') { $OP = "rm -f {$db_tmp_tab}.* {$db_tmp_tab02}.* "; $result = exec($OP); } if ($_REQUEST["debug"] == "xml") { echo $output; exit; } // ******************************************************************** // ********** Aplica XSl no arquivo gerado pelo programa ************* // ******************************************************************** $xsl = $defFile["PATH"]["PATH_XSL"] . "/sciofi_artmonthyearstat.xsl"; if ($_REQUEST["debug"] == "xsl") { echo file_get_contents($xsl); } $transformer = new XSLTransformer(); $transformer->setXslBaseUri($defFile["PATH"]["PATH_XSL"]); $transformer->setXml($output); $transformer->setXslFile($xsl); $transformer->transform(); $output = $transformer->getOutput(); $output = str_replace('&', '&', $output); $output = str_replace('<', '<', $output); $output = str_replace('>', '>', $output); $output = str_replace('"', '"', $output); $output = str_replace('<p>', ' ', $output); $output = str_replace('</p>', ' ', $output); echo $output; exec('rm -f $db_tmp_tab.*'); exec('rm -f $db_tmp_tab02.*'); ?>
$fullTitle = $output; if ($transformer->transformedBy == "PHP") { //PHP $fullTitle = utf8_decode($fullTitle); } } // XML Final que contem os dados que precisamos do XML1 e XML2 $xmlFinal = '<?xml version="1.0" encoding="ISO-8859-1"?>'; $xmlFinal .= substr($xml2, strpos($xml2, "<root>"), strpos($xml2, "<ref_TITLE>") - strpos($xml2, "<root>")) . '<vars><refid>' . $_REQUEST['refid'] . '</refid><htdocs>' . $pathHtdocs . '</htdocs><service_log>' . $flagLog . '</service_log></vars>'; $xmlFinal .= " <ref_TITLE><![CDATA[" . $fullTitle . "]]></ref_TITLE>"; $xmlFinal .= substr($xml2, strpos($xml2, "<TITLE>")); if ($_REQUEST['debug2'] == 'on') { die($xmlFinal); } // Transformação Final, página de links de referencia $transformerFinal = new XSLTransformer(); $xslFinal = $pathHtdocs . "xsl/sci_reflinks.xsl"; //die("socket = true"); $transformerFinal->setXslBaseUri($pathHtdocs . "xsl"); $transformerFinal->setXml($xmlFinal); $transformerFinal->setXslFile($xslFinal); $transformerFinal->transform(); $output = $transformerFinal->getOutput(); if ($transformer->transformedBy == "PHP") { //PHP $output = utf8_decode($output); } if ($transformerFinal->getError()) { echo $transformerFinal->getError(); } $output = str_replace('&', '&', $output);
<div class="articleList"> <?php $serviceUrl = "http://trigramas.bireme.br/cgi-bin/mxlind/cgi=@areasgeo?pid=" . $pid; $xmlFile = file_get_contents($serviceUrl); $xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'; $xml .= '<root>'; $xml .= '<vars> <lang>' . $lang . '</lang> <applserver>' . $applServer . '</applserver> </vars>'; $xml .= str_replace('<?xml version="1.0" encoding="ISO-8859-1" ?>', '', $xmlFile); $xml .= '</root>'; if ($_REQUEST['debug'] == 'xml') { die($xml); } $transformer = new XSLTransformer(); if (getenv("ENV_SOCKET") == "true") { //socket $xslFile = strtoupper('datasus'); } else { //die($defFile["PATH_XSL"]."datasus.xsl"); $xslFile = file_get_contents($defFile["PATH_XSL"] . "datasus.xsl"); } $xsl = $xslFile; $transformer->setXslBaseUri($defFile["PATH_XSL"]); $transformer->setXML($xml); $transformer->setXSL($xsl); $transformer->transform(); $output = $transformer->getOutput(); $output = str_replace('&', '&', $output); $output = str_replace('<', '<', $output);
if ($_REQUEST['getXML'] == "true") { die($xml); } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> <!-- <link rel="stylesheet" href="/applications/scielo-org/css/public/style-<?php echo $lang; ?> .css" type="text/css" media="screen"/> --> </head> <body> <?php $xsl = dirname(__FILE__) . "/report.xsl"; $transformer = new XSLTransformer(); //die("socket = true"); $transformer->setXslBaseUri(dirname(__FILE__)); $transformer->setXml($xml); $transformer->setXslFile($xsl); $transformer->transform(); $output = $transformer->getOutput(); echo $output; $pgPrevious = $pg - 1; $pgNext = $pg + 1; $totalPages = (int) ceil(substr($xml, strpos($xml, "Isis_Total") + 24, 4) / $viewNum); $previous = str_replace("&pg=" . $pg, "", $_SERVER['REQUEST_URI']); $previous .= "&pg=" . $pgPrevious; $next = str_replace("&pg=" . $pg, "", $_SERVER['REQUEST_URI']); $next .= "&pg=" . $pgNext; if ($pg <= $totalPages) {
function destroy() { XSLTransformer::destroy(); }
function processTransformation($xml, $xsl) { global $def; $result = ""; $xslParams = array('xml-path' => $def['DATABASE_PATH'] . "xml/"); $transform = new XSLTransformer(); if ($def["LETTER_UNIT"] != "") { $transform->setXslBaseUri("file://" . $def["LETTER_UNIT"] . "/" . $def["SITE_PATH"]); } else { $transform->setXslBaseUri("file://" . $def["SITE_PATH"]); } if ($transform->setXml($xml) == false) { die($transform->getErrorMessage()); } if ($transform->setXsl($xsl) == false) { die($transform->getErrorMessage()); } $transform->setXslParameters($xslParams); if ($transform->transform() == false) { print $transform->getErrorMessage(); } else { $result = utf8_decode($transform->getOutput()); } return $result; }
<? $lang = isset($_REQUEST['lang'])?($_REQUEST['lang']):""; $pid = isset($_REQUEST['pid'])?($_REQUEST['pid']):""; $text = isset($_REQUEST['text'])?($_REQUEST['text']):""; require_once(dirname(__FILE__)."/../../classDefFile.php"); if(!class_exists("XSLTransformer")) { require_once(dirname(__FILE__)."/../../class.XSLTransformer.php"); } $transformer = new XSLTransformer(); $defFile = new DefFile(dirname(__FILE__)."/../../scielo.def"); $related_Service = $defFile->getKeyValue($serviceName); $related_Service = str_replace("PARAM_PID",$pid,$related_Service); $related_Service = str_replace("PARAM_TEXT",$text,$related_Service); $xmlh = ""; $xmlh = file_get_contents(str_replace(' ','%20',utf8_decode(urldecode($related_Service)))); $xmlh = str_replace("<","<",$xmlh); $xmlh = str_replace(">",">",$xmlh); $xmlh = str_replace("&","&",$xmlh); $xmlh = str_replace(""","\"",$xmlh); for($chr = 0; $chr < 32 ;$chr++) { $xmlh = str_replace(chr($chr),"",$xmlh); } $xmlh = str_replace(chr(146),"",$xmlh); $xml = '<?xml version="1.0" encoding="ISO-8859-1" ?>'."\n"; $xml .= '<root>';
<div class="articleList"> <?php $serviceUrl = "http://trigramas.bireme.br/cgi-bin/mxlind/cgi=@areasgeo?pid=" . $pid; $xmlFile = file_get_contents($serviceUrl); $xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'; $xml .= '<root>'; $xml .= '<vars> <lang>' . $lang . '</lang> <applserver>' . $applServer . '</applserver> </vars>'; $xml .= str_replace('<?xml version="1.0" encoding="ISO-8859-1" ?>', '', $xmlFile); $xml .= '</root>'; if ($_REQUEST['debug'] == 'xml') { die($xml); } $transformer = new XSLTransformer(); $transformer->setXslBaseUri($defFile["PATH_XSL"]); $transformer->setXml($xml); $transformer->setXslFile($defFile["PATH_XSL"] . "datasus.xsl"); $transformer->transform(); $output = $transformer->getOutput(); $output = str_replace('&', '&', $output); $output = str_replace('<', '<', $output); $output = str_replace('>', '>', $output); $output = str_replace('"', '"', $output); $output = str_replace('<p>', ' ', $output); $output = str_replace('</p>', ' ', $output); echo $output; ?> </div> </TD>
$url = "http://" . $_SERVER['HTTP_HOST'] . "/cgi-bin/wxis.exe/?IsisScript=ScieloXML/sci_issues.xis&def=scielo.def.php&sln={$lang}&script=sci_issues&pid={$pid}&lng={$lang}&nrm=iso"; $xml = file_get_contents($url); $cortado = strstr($xml, '<CURRENT PID="'); if ($cortado != "") { $posInicio = strpos($cortado, "\""); $posFim = strpos($cortado, "\"", $posInicio + 1); $pid = substr($cortado, $posInicio + 1, $posFim - $posInicio - 1); } } /* CHANGE: alterado em 20080314 para utilização do script sci_issuerss.xis (adiconado abstract ao XML) no lugar de sci_issuetoc.xis */ $url = "http://" . $_SERVER['HTTP_HOST'] . "/cgi-bin/wxis.exe/?IsisScript=ScieloXML/sci_issuerss.xis&def=scielo.def.php&sln=en&script=sci_issuetoc&pid={$pid}&lng={$lang}&nrm=iso"; $xml = file_get_contents($url); $xsl = dirname(__FILE__) . "/xsl/createRSS.xsl"; if (isset($debug)) { echo '<h1>XML</h1>'; echo '<textarea cols="120" rows="18">' . "\n"; echo $xml; echo '</textarea>'; echo '<h1>XSL</h1>'; echo '<textarea cols="120" rows="18">' . "\n"; echo $xsl; echo '</textarea>'; die; } $t = new XSLTransformer(); $t->setXml($xml); $t->setXslFile($xsl); $t->transform(); $result = $t->getOutput(); echo $result; ob_flush();
/** * Process the given XML with the configured XSL * @see Filter::process() * @param $xml DOMDocument|string * @return DOMDocument|string */ function &process(&$xml) { // Determine the input type if (is_string($xml)) { $xmlType = XSL_TRANSFORMER_DOCTYPE_STRING; } elseif (is_a($xml, 'DOMDocument')) { $xmlType = XSL_TRANSFORMER_DOCTYPE_DOM; } else { assert(false); } // Determine the result type based on // the input type if it has not been // set explicitly. if (is_null($this->getResultType())) { $this->setResultType($xmlType); } // Transform the input $xslTransformer = new XSLTransformer(); $result =& $xslTransformer->transform($xml, $xmlType, $this->getXsl(), $this->getXslType(), $this->getResultType()); return $result; }
function generatePayload($ws_client_url, $service, $service_name, $parameters, $xsl) { global $debug, $defFile; //die($service_name." - ".$service); switch ($service_name) { case "Identify": $response = listRecords($set = $parameters["set"], $from = $parameters["from"], $until = $parameters["until"], $control = $parameters["control"], $lang = "en", $nrm = "iso", $count = 30, $debug = false); break; case "ListMetadataFormats": $response = getAbstractArticle($set = $parameters["set"], $from = $parameters["from"], $until = $parameters["until"], $control = $parameters["control"], $lang = "en", $nrm = "iso", $count = 30, $debug = false); break; case "ListIdentifiers": $response = listRecords($set = $parameters["set"], $from = $parameters["from"], $until = $parameters["until"], $control = $parameters["control"], $lang = "en", $nrm = "iso", $count = 30, $debug = false); break; case "ListSets": $response = getTitles($lang = "en", $debug = false); break; case "ListRecords": $response = ListRecords($set = $parameters["set"], $from = $parameters["from"], $until = $parameters["until"], $control = $parameters["control"], $lang = "en", $nrm = "iso", $count = 30, $debug = false); break; case "GetRecord": $response = getAbstractArticle($pid = $parameters["pid"], $lang = "en", $ws = $parameters["ws_oai"], $debug = false); break; } // $result = ""; if (!$debug) { $transform = new XSLTransformer(); if (getenv("ENV_SOCKET") != "true") { //socket $xsl = file_get_contents($defFile["PATH_OAI"] . $xsl); } else { $xsl = str_replace('.XSL', '', strtoupper($xsl)); } $transform->setXslBaseUri($defFile["PATH_OAI"]); $transform->setXsl($xsl); $transform->setXml($response); $transform->transform(); if ($transform->getError()) { // Transformation error echo "XSL Transformation error\n"; echo $transform->getError(); $transform->destroy(); exit; } $result = $transform->getOutput(); $transform->destroy(); } return $result; }