コード例 #1
0
function loadRecordHTML($recHMLFilename, $styleFilename)
{
    global $recID, $outputFilename;
    $recHmlDoc = new DOMDocument();
    $recHmlDoc->load($recHMLFilename);
    $recHmlDoc->xinclude();
    if (!$styleFilename) {
        return $recHmlDoc->saveHTMLFile($outputFilename);
    }
    $xslDoc = DOMDocument::load($styleFilename);
    $xslProc = new XSLTProcessor();
    $xslProc->importStylesheet($xslDoc);
    // set up common parameters for stylesheets.
    //	$xslProc->setParameter('','hbaseURL',HEURIST_BASE_URL);
    //	$xslProc->setParameter('','dbName',HEURIST_DBNAME);
    //	$xslProc->setParameter('','dbID',HEURIST_DBID);
    $xslProc->setParameter('', 'standalone', '1');
    $xslProc->transformToURI($recHmlDoc, $outputFilename);
}
コード例 #2
0
 /**
  * Apply a process (xslt stylesheet) on an input (xml file) and save output.
  *
  * @param string $input Path of input file.
  * @param string $stylesheet Path of the stylesheet.
  * @param string $output Path of the output file. If none, a temp file will
  * be used.
  * @param array $parameters Parameters array.
  * @return string|null Path to the output file if ok, null else.
  */
 private function _processXsltViaPhp($input, $stylesheet, $output = '', $parameters = array())
 {
     if (empty($output)) {
         $output = tempnam(sys_get_temp_dir(), 'omk_');
     }
     try {
         $domXml = $this->_domXmlLoad($input);
         $domXsl = $this->_domXmlLoad($stylesheet);
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
     $proc = new XSLTProcessor();
     $proc->importStyleSheet($domXsl);
     $proc->setParameter('', $parameters);
     $result = $proc->transformToURI($domXml, $output);
     @chmod($output, 0640);
     // There is no specific message for error with this processor.
     if ($result === false) {
         $message = __('An error occurs during the xsl transformation of the file "%s" with the sheet "%s".', $input, $stylesheet);
         throw new OaiPmhStaticRepository_Exception($message);
     }
     return $output;
 }
コード例 #3
0
 /**
  * Genearte expression providers
  * 
  * @param Object $serviceInfo   ServiceInfo Object
  * @param String $serviceOutDir Path of output-files for current service
  * @param String $serviceXslDir Path of xsl-files for generating providers
  * @param String $configFile    config file name
  *
  * @return void
  */
 public function generateExpressionProvider($serviceInfo, $serviceOutDir, $serviceXslDir, $configFile)
 {
     //DSExpression Provider Generation.
     if ($serviceInfo['queryProviderVersion'] == 2) {
         $xsl_path = $serviceXslDir . "/EDMXToDSExpressionProvider.xsl";
         $xslDoc = new DOMDocument();
         if (file_exists($xsl_path)) {
             if (!$xslDoc->load($xsl_path)) {
                 die("Error while loading xls file for Expression Provider.");
             }
         } else {
             die("Error: xls file for DSExpression provider generatior not found");
         }
         $proc = new XSLTProcessor();
         $proc->importStylesheet($xslDoc);
         $proc->setParameter('', 'serviceName', $this->options['serviceName']);
         $metadataDoc = new DOMDocument();
         $expressionProviderPath = $serviceOutDir . "/" . $this->options['serviceName'] . "DSExpressionProvider.php";
         if (file_exists($configFile)) {
             if (!$metadataDoc->load($configFile)) {
                 die("Error while loading service.config.xml file for " . "DSExpression provider.");
             }
         } else {
             die("Error: service.config.xml file is not found for " . "DSExpression Provider.");
         }
         $file = fopen($expressionProviderPath, "w");
         chmod($expressionProviderPath, 0777);
         $proc->transformToURI($metadataDoc, $expressionProviderPath);
         unset($xslDoc);
         unset($proc);
         unset($metadataDoc);
         system("PHP -l {$expressionProviderPath}  1> " . $serviceOutDir . "/msg.tmp 2>&1", $temp);
         unlink($serviceOutDir . "/msg.tmp");
         if ($temp == 0 or $temp == 127) {
             echo "\nDSExpressionProvider class has generated Successfully.";
         } else {
             //Throw exception
             $this->showUsage("Error in generation of  ExpressionProvider class ... \nPlease " . "check the syntax of file:" . $expressionProviderPath);
         }
     }
 }
$xsl = <<<EOB
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:php="http://php.net/xsl">
<xsl:output method="html" encoding="utf-8" indent="yes"/>
 <xsl:template match="allusers">
  <html><body>
    <h2>Users</h2>
    <table>
    <xsl:for-each select="user">
      <tr><td>
        <xsl:value-of
             select="php:function('ucfirst',string(uid))"/>
      </td></tr>
    </xsl:for-each>
    </table>
  </body></html>
 </xsl:template>
</xsl:stylesheet>
EOB;
$xmldoc = new DOMDocument('1.0', 'utf-8');
$xmldoc->loadXML($xml);
$xsldoc = new DOMDocument('1.0', 'utf-8');
$xsldoc->loadXML($xsl);
$proc = new XSLTProcessor();
$proc->registerPHPFunctions();
$proc->importStyleSheet($xsldoc);
$uri = 'php://output';
echo $proc->transformToURI($xsldoc, $uri, 'stringValue');
コード例 #5
0
 /**
  * Generate the proxy class
  *
  */
 public function generateProxy()
 {
     $this->_validateAndBuidOptions();
     // replace a PHP.ini requirement with a sensible alternative
     $xsl_path = dirname(__FILE__);
     $xslDoc = new DOMDocument();
     $xslDoc->load($xsl_path . '/' . 'Common/WCFDataServices2PHPProxy.xsl');
     $proc = new XSLTProcessor();
     $proc->importStylesheet($xslDoc);
     $proc->setParameter('', 'DefaultServiceURI', $this->_options['/uri_withoutSlash']);
     $this->_metadataDoc = new DOMDocument();
     if (!empty($this->_options['/metadata'])) {
         $this->_metadataDoc->load($this->_options['/metadata']);
     } else {
         $metadata = $this->_getMetaDataOverCurl();
         $this->_metadataDoc->loadXML($metadata);
     }
     return $proc->transformToURI($this->_metadataDoc, $this->_options['/out_dir'] . '/' . $this->_getFileName());
 }
コード例 #6
0
 public function transmitCCD($data = array())
 {
     $appTable = new ApplicationTable();
     $ccda_combination = $data['ccda_combination'];
     $recipients = $data['recipients'];
     $xml_type = $data['xml_type'];
     $rec_arr = explode(";", $recipients);
     $d_Address = '';
     foreach ($rec_arr as $recipient) {
         $config_err = "Direct messaging is currently unavailable." . " EC:";
         if ($GLOBALS['phimail_enable'] == false) {
             return "{$config_err} 1";
         }
         $fp = \Application\Plugin\Phimail::phimail_connect($err);
         if ($fp === false) {
             return "{$config_err} {$err}";
         }
         $phimail_username = $GLOBALS['phimail_username'];
         $phimail_password = $GLOBALS['phimail_password'];
         $ret = \Application\Plugin\Phimail::phimail_write_expect_OK($fp, "AUTH {$phimail_username} {$phimail_password}\n");
         if ($ret !== TRUE) {
             return "{$config_err} 4";
         }
         $ret = \Application\Plugin\Phimail::phimail_write_expect_OK($fp, "TO {$recipient}\n");
         if ($ret !== TRUE) {
             //return("Delivery is not allowed to the specified Direct Address.") ;
             $d_Address .= ' ' . $recipient;
             continue;
         }
         $ret = fgets($fp, 1024);
         //ignore extra server data
         if ($requested_by == "patient") {
             $text_out = "Delivery of the attached clinical document was requested by the patient";
         } else {
             if (strpos($ccda_combination, '|') !== false) {
                 $text_out = "Clinical documents are attached.";
             } else {
                 $text_out = "A clinical document is attached";
             }
         }
         $text_len = strlen($text_out);
         \Application\Plugin\Phimail::phimail_write($fp, "TEXT {$text_len}\n");
         $ret = @fgets($fp, 256);
         if ($ret != "BEGIN\n") {
             \Application\Plugin\Phimail::phimail_close($fp);
             //return("$config_err 5");
             $d_Address .= ' ' . $recipient;
             continue;
         }
         $ret = \Application\Plugin\Phimail::phimail_write_expect_OK($fp, $text_out);
         if ($ret !== TRUE) {
             //return("$config_err 6");
             $d_Address .= $recipient;
             continue;
         }
         $elec_sent = array();
         $arr = explode('|', $ccda_combination);
         foreach ($arr as $value) {
             $query = "SELECT id FROM  ccda WHERE pid = ? ORDER BY id DESC LIMIT 1";
             $result = $appTable->zQuery($query, array($value));
             foreach ($result as $val) {
                 $ccda_id = $val['id'];
             }
             $refs = $appTable->zQuery("select t.id as trans_id from ccda c inner join transactions t on (t.pid = c.pid and t.date = c.updated_date) where c.pid = ? and c.emr_transfer = 1 and t.title = 'LBTref'", array($value));
             if ($refs->count() == 0) {
                 $trans = $appTable->zQuery("select id from transactions where pid = ? and title = 'LBTref' order by id desc limit 1", array($value));
                 $trans_cur = $trans->current();
                 $trans_id = $trans_cur['id'] ? $trans_cur['id'] : 0;
             } else {
                 foreach ($refs as $r) {
                     $trans_id = $r['trans_id'];
                 }
             }
             $elec_sent[] = array('pid' => $value, 'map_id' => $trans_id);
             $ccda = $this->getFile($ccda_id);
             $xml = simplexml_load_string($ccda);
             $xsl = new \DOMDocument();
             $xsl->load(dirname(__FILE__) . '/../../../../../public/xsl/ccda.xsl');
             $proc = new \XSLTProcessor();
             $proc->importStyleSheet($xsl);
             // attach the xsl rules
             $outputFile = sys_get_temp_dir() . '/out_' . time() . '.html';
             $proc->transformToURI($xml, $outputFile);
             $htmlContent = file_get_contents($outputFile);
             if ($xml_type == 'html') {
                 $ccda_file = htmlspecialchars_decode($htmlContent);
             } elseif ($xml_type == 'pdf') {
                 $dompdf = new DOMPDF();
                 $dompdf->load_html($htmlContent);
                 $dompdf->render();
                 //$dompdf->stream();
                 $ccda_file = $dompdf->output();
             } elseif ($xml_type == 'xml') {
                 $ccda_file = $ccda;
             }
             //get patient name in Last_First format (used for CCDA filename)
             $sql = "SELECT pid, id, lname, fname, mname, providerID, DATE_FORMAT(DOB,'%m/%d/%Y') as DOB_TS FROM patient_data WHERE pid = ?";
             $result = $appTable->zQuery($sql, array($value));
             foreach ($result as $val) {
                 $patientData[0] = $val;
             }
             if (empty($patientData[0]['lname'])) {
                 $att_filename = "";
                 $patientName2 = "";
             } else {
                 //spaces are the argument delimiter for the phiMail API calls and must be removed
                 $extension = $xml_type == 'CCDA' ? 'xml' : strtolower($xml_type);
                 $att_filename = " " . str_replace(" ", "_", $xml_type . "_" . $patientData[0]['lname'] . "_" . $patientData[0]['fname']) . "." . $extension;
                 $patientName2 = $patientData[0]['fname'] . " " . $patientData[0]['lname'];
             }
             if (strtolower($xml_type) == 'xml') {
                 $ccda = simplexml_load_string($ccda_file);
                 $ccda_out = $ccda->saveXml();
                 $ccda_len = strlen($ccda_out);
                 \Application\Plugin\Phimail::phimail_write($fp, "ADD " . ($xml_type == "CCR" ? $xml_type . ' ' : "CDA ") . $ccda_len . $att_filename . "\n");
             } else {
                 if (strtolower($xml_type) == 'html' || strtolower($xml_type) == 'pdf') {
                     $ccda_out = $ccda_file;
                     $message_length = strlen($ccda_out);
                     $add_type = strtolower($xml_type) == 'html' ? 'TEXT' : 'RAW';
                     \Application\Plugin\Phimail::phimail_write($fp, "ADD " . $add_type . " " . $message_length . "" . $att_filename . "\n");
                 }
             }
             $ret = fgets($fp, 256);
             if ($ret != "BEGIN\n") {
                 \Application\Plugin\Phimail::phimail_close($fp);
                 //return("$config_err 7");
                 $d_Address .= ' ' . $recipient;
                 continue;
             }
             $ret = \Application\Plugin\Phimail::phimail_write_expect_OK($fp, $ccda_out);
         }
         if ($ret !== TRUE) {
             //              return("$config_err 8");
             $d_Address .= ' ' . $recipient;
             continue;
         }
         \Application\Plugin\Phimail::phimail_write($fp, "SEND\n");
         $ret = fgets($fp, 256);
         //"INSERT INTO `amc_misc_data` (`amc_id`,`pid`,`map_category`,`map_id`,`date_created`) VALUES(?,?,?,?,NOW())"
         \Application\Plugin\Phimail::phimail_close($fp);
     }
     if ($d_Address == '') {
         foreach ($elec_sent as $elec) {
             $appTable->zQuery("INSERT into amc_misc_data(amc_id,pid,map_category,map_id,date_created,date_completed) values('send_sum_amc',?,'transactions',?,NOW(),NOW())", array($elec['pid'], $elec['map_id']));
             $appTable->zQuery("INSERT into amc_misc_data(amc_id,pid,map_category,map_id,date_created,date_completed) values('send_sum_elec_amc',?,'transactions',?,NOW(),NOW())", array($elec['pid'], $elec['map_id']));
         }
         return "Successfully Sent";
     } else {
         return "Delivery is not allowed to:" . $d_Address;
     }
 }
コード例 #7
0
<?php

$xslt = 'cours_audio.xsl';
if ($_GET['in'] != null) {
    $input = $_GET['in'];
} else {
    $input = 'cours_audio.xml';
}
if ($_GET['out'] != null) {
    $output = $_GET['out'];
} else {
    $output = 'cours_audio.html';
}
// Chargement du document XML
$xml = new DOMDocument();
$xml->load('xslt/' . $input);
// Chargement de la feuille de style
$xsl = new DOMDocument();
$xsl->load('xslt/' . $xslt);
// Création du processeur XSLT
$proc = new XSLTProcessor();
//Affectation de la feuille de style
$proc->importStyleSheet($xsl);
// Transformation du document XML selon la feuille XSL
$proc->transformToURI($xml, "./" . $output);
if ($proc != FALSE) {
    echo "transformation réussie.";
}
コード例 #8
0
ファイル: setter-menu.php プロジェクト: hynekmusil/hr-help
if (!isset($pageProperties->onentry) and $pageProperties->operation == 'change') {
    exit;
}
$xslt = new XSLTProcessor();
$xslDoc->load("../page/setter-pageController.xsl");
$xslt->importStylesheet($xslDoc);
$xslt->setParameter("", "onentry", json_encode($pageProperties->onentry));
$xslt->setParameter("", "newStateId", $pageProperties->uri);
$xmlDoc->load($baseDir . "data/controller-page.scxml");
if (strpos($pageProperties->operation, "insert") === 0) {
    $xpath = new DOMXpath($xmlDoc);
    $elements = $xpath->query("//*[@id='{$stateId}']");
    if (!is_null($elements->item(0))) {
        foreach ($pageProperties->onentry as $fields) {
            foreach ($fields as $field) {
                foreach ($field as $data) {
                    if (!is_file($baseDir . $data)) {
                        createArticle($baseDir . $data);
                    }
                }
            }
        }
        $xslt->setParameter("", "stateId", $elements->item(0)->parentNode->getAttribute("id"));
        $xslt->setParameter("", "operation", "append");
    }
} else {
    $xslt->setParameter("", "operation", $pageProperties->operation);
    $xslt->setParameter("", "stateId", $stateId);
}
$result = $xslt->transformToURI($xmlDoc, $baseDir . "data/controller-page.scxml");
コード例 #9
0
<?php

$file = '/etc/passwd' . chr(0) . 'asdf';
$doc = new DOMDocument();
$proc = new XSLTProcessor();
var_dump($proc->setProfiling($file));
var_dump($proc->transformToURI($doc, $file));
コード例 #10
0
<?php

// Load XSL template
$xsl = new DOMDocument();
$xsl->load(__DIR__ . '/stylesheet.xsl');
// Create new XSLTProcessor
$xslt = new XSLTProcessor();
// Load stylesheet
$xslt->importStylesheet($xsl);
// Load XML input file
$xml = new DOMDocument();
$xsl->load(__DIR__ . '/address-book.xml');
// Transform to string
$results = $xslt->transformToXML($xml);
// Transform to a file
$results = $xslt->transformToURI($xml, 'results.txt');
// Transform to DOM object
$results = $xslt->transformToDoc($xml);
コード例 #11
0
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * @category    Application
 * @author      Edouard Simon <*****@*****.**>
 * @copyright   Copyright (c) 2014, OPUS 4 development team
 * @license     http://www.gnu.org/licenses/gpl.html General Public License
 * @version     $Id$
 */
/**
 * This script takes a doctype XML-definition as input and spills out the 
 * PHP instructions for use in the corresponding .phtml file.
 * It requires the file doctype.xslt to be in the same directory as this script.
 */
if ($argc == 2) {
    $filename = realpath($argv[1]);
    if (!is_file($filename)) {
        echo "Could not find file {$argv[1]} ({$filename})";
        exit;
    }
} else {
    echo "No file supplied";
    exit;
}
$xml = new DOMDocument();
$xml->load($filename);
$xslt = new DomDocument();
$xslt->load(dirname(__FILE__) . "/doctype.xslt");
$proc = new XSLTProcessor();
$proc->importStyleSheet($xslt);
$proc->transformToURI($xml, 'php://output');
コード例 #12
0
ファイル: PHPDataSvcUtil.php プロジェクト: zzzaaa/odataphp
 /**
  * Generate the proxy class
  *
  */
 public function generateProxy()
 {
     $this->_validateAndBuidOptions();
     $xsl_path = get_cfg_var('ODataphp_path');
     if (strlen($xsl_path) == 0) {
         throw new Exception(self::$_messages['ServicePath_Not_Set']);
     }
     $xsl_path = $xsl_path . "/" . "Common/WCFDataServices2PHPProxy.xsl";
     $xslDoc = new DOMDocument();
     $xslDoc->load($xsl_path);
     $proc = new XSLTProcessor();
     $proc->importStylesheet($xslDoc);
     $proc->setParameter('', 'DefaultServiceURI', $this->_options['/uri_withoutSlash']);
     $this->_metadataDoc = new DOMDocument();
     if (!empty($this->_options['/metadata'])) {
         $this->_metadataDoc->load($this->_options['/metadata']);
     } else {
         $metadata = $this->_getMetaDataOverCurl();
         $this->_metadataDoc->loadXML($metadata);
     }
     $proc->transformToURI($this->_metadataDoc, $this->_options['/out_dir'] . "/" . $this->_getFileName());
 }
コード例 #13
0
 /**
  * Converts the currently opened document to XHTML.
  *
  * This function does not modify the original document, but
  * modifications on the document will reflect on the result of
  * the conversion.
  *
  * You may want to call setXSLTransformation() and/or
  * setXSLOption() before calling this function to optimize the
  * result of the conversion for particular purposes.
  *
  * @param filename Filename of the resulting XHTML document.
  *
  * @return @c true if the document was successfully converted,
  *         @c false otherwise.
  *
  * @sa setXSLTransformation(), setXSLOption()
  */
 public function convertToXHTML($filename)
 {
     if ($this->filename == '') {
         trigger_error('No document was loaded for conversion to XHTML');
         return false;
     }
     $xslDocument = new DOMDocument();
     if ($xslDocument->load(LIBOPENDOCUMENT_PATH . "/xsl/{$this->xslTransformation}/document2xhtml.xsl") === false) {
         trigger_error('Could not open the selected XSL transformation');
         return false;
     }
     $xsltProcessor = new XSLTProcessor();
     if ($xsltProcessor->hasExsltSupport() == false) {
         trigger_error('EXSLT support in PHP is required for converting OpenDocument files');
         return false;
     }
     if ($this->package == false) {
         $sourceDocument = $this->metaDocument;
     } else {
         if ($this->xslOptions['export-objects'] == 'true') {
             $this->exportObjects(dirname($filename));
         }
         $preprocessXSLDocument = new DOMDocument();
         if (copy(LIBOPENDOCUMENT_PATH . "/xsl/package2document.xsl", "{$this->tmpdir}/package2document.xsl") === false || $preprocessXSLDocument->load("{$this->tmpdir}/package2document.xsl") === false) {
             trigger_error('Could not open the XSL transformation for pre-processing');
             return false;
         }
         $xsltProcessor->importStyleSheet($preprocessXSLDocument);
         $contentDocument = new DOMDocument();
         if ($contentDocument->load("{$this->tmpdir}/content.xml") == false) {
             trigger_error('Could not load content XML document');
             return false;
         }
         $xsltProcessor->setParameter('', 'mimetype', file_get_contents("{$this->tmpdir}/mimetype"));
         $sourceDocument = $xsltProcessor->transformToDoc($contentDocument);
         if ($sourceDocument === false) {
             trigger_error('Could not open source document');
             return false;
         }
         unlink("{$this->tmpdir}/package2document.xsl");
     }
     if (file_exists(LIBOPENDOCUMENT_PATH . "/xsl/{$this->xslTransformation}/document2xhtml.php") == true) {
         include_once LIBOPENDOCUMENT_PATH . "/xsl/{$this->xslTransformation}/document2xhtml.php";
         OpenDocument2XHTML::init($this->xslOptions);
         $xsltProcessor->registerPHPFunctions();
     }
     $xsltProcessor->importStyleSheet($xslDocument);
     foreach ($this->xslOptions as $key => $value) {
         $xsltProcessor->setParameter('', $key, $value);
     }
     if ($xsltProcessor->transformToURI($sourceDocument, $filename) == false) {
         trigger_error('XSL transformation failed to run');
         return false;
     }
     return true;
 }
コード例 #14
0
 /**
  * Apply a process (xslt stylesheet) on an input (xml file) and save output.
  *
  * @param string $input Path of input file.
  * @param string $stylesheet Path of the stylesheet.
  * @param string $output Path of the output file. If none, a temp file will
  * be used.
  * @param array $parameters Parameters array.
  * @return string|null Path to the output file if ok, null else.
  */
 private function _processXsltViaPhp($input, $stylesheet, $output = '', $parameters = array())
 {
     if (empty($output)) {
         $output = tempnam(sys_get_temp_dir(), 'omk_');
     }
     try {
         $domXml = $this->_domXmlLoad($input);
         $domXsl = $this->_domXmlLoad($stylesheet);
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
     $proc = new XSLTProcessor();
     // Php functions are needed, because php doesn't use XSLT 2.0
     // and because we need to check existence of a file.
     if (get_plugin_ini('XmlImport', 'xml_import_allow_php_in_xsl') == 'TRUE') {
         $proc->registerPHPFunctions();
     }
     $proc->importStyleSheet($domXsl);
     $proc->setParameter('', $parameters);
     $result = $proc->transformToURI($domXml, $output);
     @chmod($output, 0640);
     return $result === FALSE ? NULL : $output;
 }
コード例 #15
0
ファイル: publish.php プロジェクト: hynekmusil/hr-help
            $addNewDir = false;
        }
    } else {
        $addNewDir = true;
    }
    if ($addNewDir == true) {
        $baseOutputDir .= "../";
        $newDir .= "/" . $uriArr[$i];
        if (!is_dir($newDir)) {
            mkdir($newDir);
        }
    }
}
$config = array("indent" => false, "output-xhtml" => true, "wrap" => 200);
$tidy = new tidy();
$tidy->parseString($html, $config, "utf8");
$tidy->cleanRepair();
$xmlDoc = new DOMDocument("1.0", "UTF-8");
$xmlDoc->loadXML(str_replace("&nbsp;", "&#160;", $tidy->body()->value));
$xslt = new XSLTProcessor();
$xslDoc = new DOMDocument();
$xslDoc->load("filter.xsl");
$xslt->importStylesheet($xslDoc);
$xslt->setParameter("", "title", $title);
$xslt->setParameter("", "baseOutputDir", $baseOutputDir);
$xslt->transformToURI($xmlDoc, $newDir . $newFile);
function endsWith($aFullStr, $aEndStr)
{
    $fullStrEnd = substr($aFullStr, strlen($aFullStr) - strlen($aEndStr));
    return $fullStrEnd == $aEndStr;
}
コード例 #16
0
ファイル: Abstract.php プロジェクト: namesco/Docblox
  /**
   * Uses an existing XSLProcessor (thus template) to transfor the given $xml to a file at location $destination_file.
   *
   * @param DOMDocument   $xml
   * @param XSLTProcessor $proc
   * @param string        $destination_file
   *
   * @return void
   */
  protected function transformTemplateToFile(DOMDocument $xml, XSLTProcessor $proc, $destination_file)
  {
    $files_path = $this->getTargetFilesPath();
    $root       = $this->getRelativeRoot($destination_file);
    $proc->setParameter('', 'search_template', ($this->getSearchObject() !== false) ? $this->getSearchObject()->getXslTemplateName() : 'none');

    // root differs, since most cached files rely on the root we will have to repopulate
    if ($proc->getParameter('', 'root') !== substr($root ? $root : './', 0, -1))
    {
      $proc->setParameter('', 'root', substr($root ? $root : './', 0, -1));
      if (file_exists($this->getThemePath().'/preprocess'))
      {
        $dirs = new DirectoryIterator($this->getThemePath().'/preprocess');

        /** @var DirectoryIterator $file */
        foreach($dirs as $file)
        {
          if (!$file->isFile())
          {
            continue;
          }

          $this->log('  Preprocessing '.$file->getFilename() . ' as XSLT parameter $'.$file->getBasename('.xsl'));
          $xsl2 = new DOMDocument();
          $xsl2->load($this->getThemePath() . '/preprocess/' . $file->getFilename());

          $proc2 = new XSLTProcessor();
          $proc2->importStyleSheet($xsl2);
          $proc2->setParameter('', 'root', substr($root ? $root : './', 0, -1));

          $proc->setParameter('', $file->getBasename('.xsl'), str_replace('\'', '&quot;', $proc2->transformToXml($xml)));
        }
      }
    }

    $proc->transformToURI($xml, 'file://' . $files_path . '/' . $destination_file);
  }
コード例 #17
0
    public function indexAction()
    {
        global $assignedEntity;
        global $representedOrganization;
        $mirth_ip = $this->getEncounterccdadispatchTable()->getSettings('Carecoordination', 'hie_mirth_ip');
        //$assignedEntity['streetAddressLine']    = '17 Daws Rd.';
        //$assignedEntity['city']                 = 'Blue Bell';
        //$assignedEntity['state']                = 'MA';
        //$assignedEntity['postalCode']           = '02368';
        //$assignedEntity['country']              = 'US';
        //$assignedEntity['telecom']              = '5555551234';
        $representedOrganization = $this->getEncounterccdadispatchTable()->getRepresentedOrganization();
        $request = $this->getRequest();
        $this->patient_id = $this->getRequest()->getQuery('pid');
        $this->encounter_id = $this->getRequest()->getQuery('encounter');
        $combination = $this->getRequest()->getQuery('combination');
        $this->sections = $this->getRequest()->getQuery('sections');
        $sent_by = $this->getRequest()->getQuery('sent_by');
        $send = $this->getRequest()->getQuery('send') ? $this->getRequest()->getQuery('send') : 0;
        $view = $this->getRequest()->getQuery('view') ? $this->getRequest()->getQuery('view') : 0;
        $emr_transfer = $this->getRequest()->getQuery('emr_transfer') ? $this->getRequest()->getQuery('emr_transfer') : 0;
        $this->recipients = $this->getRequest()->getQuery('recipient');
        $this->params = $this->getRequest()->getQuery('param');
        $this->referral_reason = $this->getRequest()->getQuery('referral_reason');
        $this->components = $this->getRequest()->getQuery('components') ? $this->getRequest()->getQuery('components') : $this->params('components');
        $downloadccda = $this->params('downloadccda');
        $this->latest_ccda = $this->getRequest()->getQuery('latest_ccda') ? $this->getRequest()->getQuery('latest_ccda') : $this->params('latest_ccda');
        if ($downloadccda == 'download_ccda') {
            $combination = $this->params('pids');
            $view = $this->params('view');
        }
        if ($sent_by != '') {
            $_SESSION['authId'] = $sent_by;
        }
        if (!$this->sections) {
            $components0 = $this->getEncounterccdadispatchTable()->getCCDAComponents(0);
            foreach ($components0 as $key => $value) {
                if ($str) {
                    $str .= '|';
                }
                $str .= $key;
            }
            $this->sections = $str;
        }
        if (!$this->components) {
            $components1 = $this->getEncounterccdadispatchTable()->getCCDAComponents(1);
            foreach ($components1 as $key => $value) {
                if ($str1) {
                    $str1 .= '|';
                }
                $str1 .= $key;
            }
            $this->components = $str1;
        }
        if ($combination != '') {
            $arr = explode('|', $combination);
            foreach ($arr as $row) {
                $arr = explode('_', $row);
                $this->patient_id = $arr[0];
                $this->encounter_id = $arr[1] > 0 ? $arr[1] : NULL;
                if ($this->latest_ccda) {
                    $this->encounter_id = $this->getEncounterccdadispatchTable()->getLatestEncounter($this->patient_id);
                }
                $this->create_data($this->patient_id, $this->encounter_id, $this->sections, $send, $this->components);
                $content = $this->socket_get("{$mirth_ip}", "6661", $this->data);
                if ($content == 'Authetication Failure') {
                    echo $this->listenerObject->z_xlt($content);
                    die;
                }
                $to_replace = '<?xml version="1.0" encoding="UTF-8"?>
		<?xml-stylesheet type="text/xsl" href="CDA.xsl"?>
		<ClinicalDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:schemaLocation="urn:hl7-org:v3 http://xreg2.nist.gov:8080/hitspValidation/schema/cdar2c32/infrastructure/cda/C32_CDA.xsd"
		xmlns="urn:hl7-org:v3"
		xmlns:mif="urn:hl7-org:v3/mif">
		<!--';
                $content = preg_replace('/<ClinicalDocument.*><!--/', $to_replace, trim($content));
                $this->getEncounterccdadispatchTable()->logCCDA($this->patient_id, $this->encounter_id, base64_encode($content), $this->createdtime, 0, $_SESSION['authId'], $view, $send, $emr_transfer);
                if (!$view) {
                    echo $this->listenerObject->z_xlt("Queued for Transfer");
                }
            }
            if ($view && !$downloadccda) {
                $xml = simplexml_load_string($content);
                $xsl = new \DOMDocument();
                $xsl->load(dirname(__FILE__) . '/../../../../../public/xsl/ccda.xsl');
                $proc = new \XSLTProcessor();
                $proc->importStyleSheet($xsl);
                // attach the xsl rules
                $outputFile = sys_get_temp_dir() . '/out_' . time() . '.html';
                $proc->transformToURI($xml, $outputFile);
                $htmlContent = file_get_contents($outputFile);
                echo $htmlContent;
            }
            if ($downloadccda) {
                $this->forward()->dispatch('encountermanager', array('action' => 'downloadall', 'pids' => $this->params('pids')));
            } else {
                die;
            }
        } else {
            $practice_filename = "CCDA_{$this->patient_id}.xml";
            $this->create_data($this->patient_id, $this->encounter_id, $this->sections, $send);
            $content = $this->socket_get("{$mirth_ip}", "6661", $this->data);
            $to_replace = '<?xml version="1.0" encoding="UTF-8"?>
            <?xml-stylesheet type="text/xsl" href="CDA.xsl"?>
            <ClinicalDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="urn:hl7-org:v3 http://xreg2.nist.gov:8080/hitspValidation/schema/cdar2c32/infrastructure/cda/C32_CDA.xsd"
            xmlns="urn:hl7-org:v3"
            xmlns:mif="urn:hl7-org:v3/mif">
            <!--';
            $content = preg_replace('/<ClinicalDocument.*><!--/', $to_replace, trim($content));
            $this->getEncounterccdadispatchTable()->logCCDA($this->patient_id, $this->encounter_id, base64_encode($content), $this->createdtime, 0, $_SESSION['authId'], $view, $send, $emr_transfer);
            echo $content;
            die;
        }
        try {
            ob_clean();
            header("Cache-Control: public");
            header("Content-Description: File Transfer");
            header("Content-Disposition: attachment; filename=" . $practice_filename);
            header("Content-Type: application/download");
            header("Content-Transfer-Encoding: binary");
            echo $content;
            exit;
        } catch (Exception $e) {
            die('SOAP Error');
        }
    }
コード例 #18
0
 /**
  * Apply a xslt stylesheet on a xml file.
  *
  * @param string $xml_file
  *   Path of xml file.
  * @param string $xsl_file
  *   Path of the xslt file.
  * @param string $output
  *   Path of the output file. If none, a temp file will be used.
  * @param array $parameters
  *   Parameters array.
  *
  * @return string|null
  *   Path to the output file if ok, null else.
  */
 private function _apply_xslt_and_save($xml_file, $xsl_file, $output = '', $parameters = array())
 {
     if (empty($output)) {
         $output = tempnam(sys_get_temp_dir(), 'xmlimport_');
     }
     $processor = basename(get_option('xml_import_xslt_processor'));
     switch ($processor) {
         // Saxon-B on Debian/Ubuntu/Mint.
         case 'saxonb-xslt':
             // Saxon on RedHat/Fedora/Centos/Mandriva.
         // Saxon on RedHat/Fedora/Centos/Mandriva.
         case 'saxon':
             $command = array($processor, '-ext:on', '-versionmsg:off', '-s:' . escapeshellarg($xml_file), '-xsl:' . escapeshellarg($xsl_file), '-o:' . escapeshellarg($output));
             foreach ($parameters as $name => $parameter) {
                 $command[] = escapeshellarg($name . '=' . $parameter);
             }
             $command = implode(' ', $command);
             $result = (int) shell_exec($command . ' 2>&- || echo 1');
             @chmod(escapeshellarg($output), 0644);
             // In Shell, 0 is a correct result.
             return $result == 1 ? NULL : $output;
             // Php default.
         // Php default.
         default:
             try {
                 $DomXml = $this->_domXmlLoad($xml_file);
                 $DomXsl = $this->_domXmlLoad($xsl_file);
             } catch (Exception $e) {
                 throw new Exception($e->getMessage());
             }
             $proc = new XSLTProcessor();
             // Php functions are needed, because php doesn't use XSLT 2.0
             // and because we need to check existence of a file.
             if (get_plugin_ini('XmlImport', 'xml_import_allow_php_in_xsl') == 'TRUE') {
                 $proc->registerPHPFunctions();
             }
             $proc->importStyleSheet($DomXsl);
             $proc->setParameter('', $parameters);
             $result = $proc->transformToURI($DomXml, $output);
             @chmod(escapeshellarg($output), 0644);
             return $result === FALSE ? NULL : $output;
     }
 }
EOB;
$xsl = <<<EOB
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:php="http://php.net/xsl">
<xsl:output method="html" encoding="utf-8" indent="yes"/>
 <xsl:template match="allusers">
  <html><body>
    <h2>Users</h2>
    <table>
    <xsl:for-each select="user">
      <tr><td>
        <xsl:value-of
             select="php:function('ucfirst',string(uid))"/>
      </td></tr>
    </xsl:for-each>
    </table>
  </body></html>
 </xsl:template>
</xsl:stylesheet>
EOB;
$xmldoc = new DOMDocument('1.0', 'utf-8');
$xmldoc->loadXML($xml);
$xsldoc = new DOMDocument('1.0', 'utf-8');
$xsldoc->loadXML($xsl);
$proc = new XSLTProcessor();
$proc->registerPHPFunctions();
$proc->importStyleSheet($xsldoc);
echo $proc->transformToURI(null, null);
コード例 #20
0
function saveTransformOutput($recHMLFilename, $styleFilename, $outputFilename = null)
{
    global $outputURI;
    $recHmlDoc = new DOMDocument();
    if (preg_match("/http/", $recHMLFilename)) {
        $suc = $recHmlDoc->loadXML(loadRemoteFile($recHMLFilename));
    } else {
        $suc = $recHmlDoc->load($recHMLFilename);
    }
    if (!$suc) {
        returnXMLErrorMsgPage("Unable to load file {$recHMLFilename}");
    }
    $recHmlDoc->xinclude();
    //todo write code here to squash xincludes down to some limit.
    if (!$styleFilename) {
        if (!$outputFilename) {
            returnXMLErrorMsgPage("No transform filename or outputFilename provided for {$recHMLFilename}");
        }
        if (is_logged_in()) {
            $cntByte = $recHmlDoc->saveHTMLFile($outputFilename);
        }
        if ($cntByte > 0) {
            returnXMLSuccessMsgPage("Successfully wrote {$cntByte} bytes of untransformed file {$recHMLFilename} to {$outputFilename}");
        } else {
            returnXMLErrorMsgPage("Unable to output untransformed file {$recHMLFilename} to {$outputFilename}");
        }
    } else {
        $xslDoc = new DOMDocument();
        if (preg_match("/http/", $styleFilename)) {
            $suc = $xslDoc->loadXML(loadRemoteFile($styleFilename));
        } else {
            $suc = $xslDoc->load($styleFilename);
        }
        if (!$suc) {
            returnXMLErrorMsgPage("Unable to load XSLT transform file {$styleFilename}");
        }
    }
    $xslProc = new XSLTProcessor();
    $xslProc->importStylesheet($xslDoc);
    // set up common parameters for stylesheets.
    $xslProc->setParameter('', 'hbaseURL', HEURIST_BASE_URL);
    $xslProc->setParameter('', 'dbName', HEURIST_DBNAME);
    $xslProc->setParameter('', 'dbID', HEURIST_DBID);
    $xslProc->setParameter('', 'transform', $styleFilename);
    $xslProc->setParameter('', 'standalone', '1');
    if ($outputFilename && is_logged_in()) {
        $cntByte = $xslProc->transformToURI($recHmlDoc, $outputFilename);
        if ($cntByte > 0) {
            returnXMLSuccessMsgPage("Successfully wrote {$cntByte} bytes of {$recHMLFilename} transformed by  {$styleFilename} to {$outputFilename}" . ($outputURI ? " <a href=\"{$outputURI}\" target=\"_blank\">{$outputURI}</a>" : "Unable to determine URI for {$outputFilename} because is does not match website path!"));
        } else {
            returnXMLErrorMsgPage("Unable to  transform and/or output file {$recHMLFilename} transformed by  {$styleFilename} to {$outputFilename}");
        }
    } else {
        $doc = $xslProc->transformToDoc($recHmlDoc);
        //		echo $xslProc->transformToXML($recHmlDoc);
        echo $doc->saveHTML();
    }
}
コード例 #21
0
         // create xslt processor
         $proc = new XSLTProcessor();
         $proc->importStyleSheet($xsl);
         // set parameters
         $proc->setParameter('', 'readonly', $_SESSION['readonly']);
         // perform transformation and store
         // results to file. note that i could
         // not find a way to store the results
         // into a local variable. one option was
         // to use sb_output(), but this does not
         // work in our case - the results are
         // echoed straight out. we need to capture
         // the result and echo it within a
         // particular section of the html page.
         $rand_file = "/tmp/" . uniqid(true);
         $proc->transformToURI($xml, $rand_file);
         $file = fopen($rand_file, "r");
         $generated_form_html = fread($file, filesize($rand_file));
         fclose($file);
         unlink($rand_file);
     }
 } else {
     // form_submitted has been set,
     //the page has been posted back.
     // collect and store all field values
     // check to see if the session has
     // expired
     if (!isset($_SESSION['obj_form'])) {
         echo "session expired ";
         echo "<META HTTP-EQUIV='Refresh' Content='0; URL=tng_login.php'>";
     } else {
コード例 #22
0
ファイル: ejXslt.php プロジェクト: kractos26/orfeo
error_reporting(7);
// Load the XML source
$xml = new DOMDocument();
$xml->load('usOrfeo.xml');
$xsl = new DOMDocument();
$xsl->load('jh.xsl');
// Configure the transformer
if (!$cOrden or !$cOrdenType) {
    $cOrden = "DEPE_CODI";
    $cOrdenDType = "number";
    $cOrdenType = "descending";
}
if ($cOrdenType == "descending") {
    $cOrdenType = "ascending";
} else {
    $cOrdenType = "descending";
}
$proc = new XSLTProcessor();
$proc->setParameter('', 'cOrdenDType', $cOrdenDType);
$proc->setParameter('', 'cOrdenType', $cOrdenType);
$proc->setParameter('', 'cOrden', $cOrden);
$proc->setParameter('', 'pos1', 0);
$proc->setParameter('', 'pos1', 1);
$proc->importStyleSheet($xsl);
$proc->setParameter('', 'varDependencia', '529');
$proc->setParameter('', 'paginaActual', $PHP_SELF);
$proc->transformToURI($xml, 'out.html');
include "out.html";
?>
 
</allusers>
EOB;
$xsl = <<<EOB
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:php="http://php.net/xsl">
<xsl:output method="html" encoding="utf-8" indent="yes"/>
 <xsl:template match="allusers">
  <html><body>
    <table>
    <xsl:for-each select="user">
      <tr><td>
        <xsl:value-of
             select="php:function('ucfirst',string(uid))"/>
      </td></tr>
    </xsl:for-each>
    </table>
  </body></html>
 </xsl:template>
</xsl:stylesheet>
EOB;
$xmldoc = new DOMDocument('1.0', 'utf-8');
$xmldoc->loadXML($xml);
$xsldoc = new DOMDocument('1.0', 'utf-8');
$xsldoc->loadXML($xsl);
$proc = new XSLTProcessor();
$proc->registerPHPFunctions();
$proc->importStyleSheet($xsldoc);
var_dump($proc->transformToURI($xsldoc, 'php://output'));
コード例 #24
0
$out = '';
socket_write($socket, $in, strlen($in));
$out = socket_read($socket, 2048) or die("Problemas");
//vamos añadiendo el lineas con bucle;
$flujo = fopen('marca.xml', 'w+');
//creamos el fichero.
fputs($flujo, $out);
//volcamos el contenido de cadena al fichero
fclose($flujo);
//cerramos el flujo
$doc = new DOMDocument();
$doc->load('marca.xml');
$is_valid_xml = $doc->schemaValidate('marca.xsd');
$xml = simplexml_load_file('marca.xml');
$xsl = new DOMDocument();
$xsl->load('marca.xsl');
// Configure the transformer
$proc = new XSLTProcessor();
$proc->importStyleSheet($xsl);
// attach the xsl rules
$proc->transformToURI($xml, 'file:///var/www/html/out.html');
echo file_get_contents('/var/www/html/out.html');
$con = mysql_connect("localhost", "root", "compaq");
mysql_select_db("zend2", $con) or die(mysql_error());
foreach ($xml->registro as $row) {
    $sql = "INSERT INTO `cat_marcas`(`id_marca`, `marca`) VALUES (" . $row->id_marca . ",'" . $row->marca . "')";
    $res = mysql_query($sql);
    if (!$res) {
        echo mysql_error();
    }
}
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:php="http://php.net/xsl">
<xsl:output method="html" encoding="utf-8" indent="yes"/>
 <xsl:template match="allusers">
  <html><body>
    <h2>Users</h2>
    <table>
    <xsl:for-each select="user">
      <tr><td>
        <xsl:value-of
             select="php:function('ucfirst',string(uid))"/>
      </td></tr>
    </xsl:for-each>
    </table>
  </body></html>
 </xsl:template>
</xsl:stylesheet>
EOB;
$xmldoc = new DOMDocument('1.0', 'utf-8');
$xmldoc->loadXML($xml);
$xsldoc = new DOMDocument('1.0', 'utf-8');
$xsldoc->loadXML($xsl);
$proc = new XSLTProcessor();
$proc->registerPHPFunctions();
$proc->importStyleSheet($xsldoc);
$wrong_parameter = false;
$uri = 'php://output';
echo $proc->transformToURI($wrong_parameter, $uri);
コード例 #26
0
 /**
  * Genearte expression providers
  * @param1 Object $serviceInfo ServiceInfo Object
  * @param2 String $serviceOutDir Path of output-files for current service
  * @param3 String $serviceXslDir Path of xsl-files for generating providers
  * @param4 String $configFile config file name
  *
  * @return void
  */
 public function generateExpressionProvider($serviceInfo, $serviceOutDir, $serviceXslDir, $configFile)
 {
     //DSExpression Provider Generation.
     if ($serviceInfo['queryProviderVersion'] == 2) {
         $xsl_path = $serviceXslDir . "/EDMXToDSExpressionProvider.xsl";
         $xslDoc = new DOMDocument();
         $xslDoc->load($xsl_path);
         $proc = new XSLTProcessor();
         $proc->importStylesheet($xslDoc);
         $proc->setParameter('', 'serviceName', $this->_options['serviceName']);
         $metadataDoc = new DOMDocument();
         $expressionProviderPath = $serviceOutDir . "/" . $this->_options['serviceName'] . "DSExpressionProvider.php";
         $metadataDoc->load($configFile);
         $proc->transformToURI($metadataDoc, $expressionProviderPath);
         unset($xslDoc);
         unset($proc);
         unset($metadataDoc);
         system("PHP -l {$expressionProviderPath}  1> " . $serviceOutDir . "/msg.tmp 2>&1", $temp);
         unlink($serviceOutDir . "/msg.tmp");
     }
 }