Пример #1
0
 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;
 }
Пример #2
0
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;
}
Пример #3
0
$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('&amp;', '&', $output);
$output = str_replace('&lt;', '<', $output);
$output = str_replace('&gt;', '>', $output);
$output = str_replace('&quot;', '"', $output);
$output = str_replace('<p>', ' ', $output);
$output = str_replace('</p>', ' ', $output);
echo $output;
?>
											</div>
										</TD>
									</TR>
								</TABLE>
Пример #4
0
    $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('&amp;', '&', $output);
$output = str_replace('&lt;', '<', $output);
$output = str_replace('&gt;', '>', $output);
$output = str_replace('&quot;', '"', $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.*');
?>
 
<hr>
Пример #5
0
    }
}
// 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('&amp;', '&', $output);
$output = str_replace('&lt;', '<', $output);
$output = str_replace('&gt;', '>', $output);
$output = str_replace('&quot;', '"', $output);
$output = str_replace('<p>', ' ', $output);
Пример #6
0
    $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();
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;
}
Пример #8
0
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;
}