コード例 #1
0
ファイル: Xslt.php プロジェクト: volux/dom
 /**
  * @return \XSLTProcessor
  */
 protected function processor()
 {
     if (!$this->processor) {
         $this->processor = new \XSLTProcessor();
         if ('php' == $this->root()->attr('exclude-result-prefixes')) {
             $this->processor->registerPHPFunctions();
         }
         $this->processor->importStyleSheet($this);
     }
     return $this->processor;
 }
コード例 #2
0
ファイル: Feefo.php プロジェクト: dragonsword007008/magento2
 /**
  * get product reviews from feefo
  *
  * @return array
  */
 public function getProductsReview()
 {
     $check = true;
     $reviews = array();
     $feefoDir = BP . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR . 'Dotdigitalgroup' . DIRECTORY_SEPARATOR . 'Email' . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR . 'frontend' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'feefo';
     $logon = $this->helper->getFeefoLogon();
     $limit = $this->helper->getFeefoReviewsPerProduct();
     $products = $this->getQuoteProducts();
     foreach ($products as $sku => $name) {
         $url = "http://www.feefo.com/feefo/xmlfeed.jsp?logon=" . $logon . "&limit=" . $limit . "&vendorref=" . $sku . "&mode=productonly";
         $doc = new \DOMDocument();
         $xsl = new \XSLTProcessor();
         if ($check) {
             $doc->load($feefoDir . DIRECTORY_SEPARATOR . "feedback.xsl");
         } else {
             $doc->load($feefoDir . DIRECTORY_SEPARATOR . "feedback-no-th.xsl");
         }
         $xsl->importStyleSheet($doc);
         $doc->loadXML(file_get_contents($url));
         $productReview = $xsl->transformToXML($doc);
         if (strpos($productReview, '<td') !== false) {
             $reviews[$name] = $xsl->transformToXML($doc);
         }
         $check = false;
     }
     return $reviews;
 }
コード例 #3
0
 /**
  * get product reviews from feefo
  *
  * @return array
  */
 public function getProductsReview()
 {
     $check = true;
     $reviews = array();
     $feefo_dir = Mage::getModel('core/config_options')->getLibDir() . DS . 'connector' . DS . 'feefo';
     $helper = Mage::helper('ddg');
     $logon = $helper->getFeefoLogon();
     $limit = $helper->getFeefoReviewsPerProduct();
     $products = $this->getQuoteProducts();
     foreach ($products as $sku => $name) {
         $url = "http://www.feefo.com/feefo/xmlfeed.jsp?logon=" . $logon . "&limit=" . $limit . "&vendorref=" . $sku . "&mode=productonly";
         $doc = new DOMDocument();
         $xsl = new XSLTProcessor();
         if ($check) {
             $doc->load($feefo_dir . DS . "feedback.xsl");
         } else {
             $doc->load($feefo_dir . DS . "feedback-no-th.xsl");
         }
         $xsl->importStyleSheet($doc);
         $doc->load($url);
         $productReview = $xsl->transformToXML($doc);
         if (strpos($productReview, '<td')) {
             $reviews[$name] = $xsl->transformToXML($doc);
         }
         $check = false;
     }
     return $reviews;
 }
コード例 #4
0
ファイル: Record.php プロジェクト: bryandease/VuFind-Plus
 /**
  * Process parameters and display the page.
  *
  * @return void
  * @access public
  */
 public function launch()
 {
     global $interface;
     // Retrieve the record from the index
     if (!($record = $this->db->getRecord($_GET['id']))) {
         PEAR_Singleton::raiseError(new PEAR_Error('Record Does Not Exist'));
     }
     // Send basic information to the template.
     $interface->setPageTitle(isset($record['heading']) ? $record['heading'] : 'Heading unavailable.');
     $interface->assign('record', $record);
     // Load MARC data
     require_once ROOT_DIR . '/sys/MarcLoader.php';
     $marcRecord = MarcLoader::loadMarcRecordFromRecord($record);
     if (!$marcRecord) {
         PEAR_Singleton::raiseError(new PEAR_Error('Cannot Process MARC Record'));
     }
     $xml = trim($marcRecord->toXML());
     // Transform MARCXML
     $style = new DOMDocument();
     $style->load('services/Record/xsl/record-marc.xsl');
     $xsl = new XSLTProcessor();
     $xsl->importStyleSheet($style);
     $doc = new DOMDocument();
     if ($doc->loadXML($xml)) {
         $html = $xsl->transformToXML($doc);
         $interface->assign('details', $html);
     }
     // Assign the ID of the last search so the user can return to it.
     $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false);
     // Display Page
     $interface->setTemplate('record.tpl');
     $interface->display('layout.tpl');
 }
コード例 #5
0
ファイル: processing.php プロジェクト: haiha262/WAD
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();
    }
}
コード例 #6
0
 public function doAction(Zend_Controller_Action $action)
 {
     $entryId = $action->getRequest()->getParam('entry-id');
     $xslt = $action->getRequest()->getParam('xslt');
     $this->client = Infra_ClientHelper::getClient();
     $xml = $this->client->media->getMrss($entryId);
     $xslParams = array();
     $xslParams['entryDistributionId'] = '';
     $xslParams['distributionProfileId'] = '';
     ob_start();
     $xmlDoc = new DOMDocument();
     $xmlDoc->loadXML($xml);
     $xsltDoc = new DOMDocument();
     $xsltDoc->loadXML($xslt);
     $xslt = new XSLTProcessor();
     $xslt->registerPHPFunctions();
     // it is safe to register all php fuctions here
     $xslt->setParameter('', $xslParams);
     $xslt->importStyleSheet($xsltDoc);
     $ob = ob_get_clean();
     ob_end_clean();
     if ($ob) {
         $action->getHelper('json')->direct(array('error' => $ob));
     }
     $obj = array('result' => $xslt->transformToXml($xmlDoc));
     $action->getHelper('json')->direct($obj);
 }
コード例 #7
0
ファイル: Pigment.php プロジェクト: JhunCabas/pigment
 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);
         }
     }
 }
コード例 #8
0
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());
    }
}
コード例 #9
0
function xsl_transform($filename, $xslname = null)
{
    // Get the original XML document
    $xml = new DOMDocument();
    $xml->load($filename);
    if ($xslname == null) {
        // extract bound stylesheet from embedded link
        $xp = new DOMXPath($xml);
        // use xpath to get the directive
        $pi = $xp->evaluate('/processing-instruction("xml-stylesheet")')->item(0);
        // extract the "data" part of it
        $data = $pi->data;
        // find out where the href starts
        $start = strpos($data, 'href=');
        // and extract the stylesheet name
        $xslname = XML_FOLDER . substr($data, $start + 6, -1);
    }
    // load the XSL stylesheet
    $xsl = new DOMDocument();
    $xsl->load($xslname);
    // prime the transform engine
    $xslt = new XSLTProcessor();
    $xslt->importStyleSheet($xsl);
    // and away we go!
    return $xslt->transformToXml($xml);
}
コード例 #10
0
ファイル: FOP.php プロジェクト: uzerpllp/uzerp
 public function go()
 {
     $fopcfg = dirname(__FILE__) . '/fop_config.xml';
     $tmppdf = tempnam('/tmp', 'FOP');
     if (!extension_loaded('java')) {
         $tmpxml = tempnam('/tmp', 'FOP');
         $tmpxsl = tempnam('/tmp', 'FOP');
         file_put_contents($tmpxml, $this->xml);
         file_put_contents($tmpxsl, $this->xsl);
         exec("fop -xml {$tmpxml} -xsl {$tmpxsl} -pdf {$tmppdf} 2>&1");
         @unlink($tmpxml);
         @unlink($tmpxsl);
     } else {
         $xml = new DOMDocument();
         $xml->loadXML($this->xml);
         $xsl = new DOMDocument();
         $xsl->loadXML($this->xsl);
         $proc = new XSLTProcessor();
         $proc->importStyleSheet($xsl);
         $java_library_path = 'file:/usr/share/fop/lib/fop.jar;file:/usr/share/fop/lib/FOPWrapper.jar';
         try {
             java_require($java_library_path);
             $j_fwc = new JavaClass("FOPWrapper");
             $j_fw = $j_fwc->getInstance($fopcfg);
             $j_fw->run($proc->transformToXML($xml), $tmppdf);
         } catch (JavaException $ex) {
             $trace = new Java("java.io.ByteArrayOutputStream");
             $ex->printStackTrace(new Java("java.io.PrintStream", $trace));
             print "java stack trace: {$trace}\n";
         }
     }
     return $tmppdf;
 }
コード例 #11
0
ファイル: Documento.php プロジェクト: DaniloEpic/slast
 public function outPut()
 {
     $processor = new XSLTProcessor();
     $processor->importStyleSheet($this->apresentacao);
     $out = $processor->transformToXML($this->conteudo);
     return $out;
 }
コード例 #12
0
    protected function doRemoveNamespacedNodes(&$pq)
    {
        $xsl = <<<____EOF
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl">
          <xsl:template match="*[local-name()=name()]">
              <xsl:element name="{local-name()}">
                  <xsl:apply-templates select="@* | node()"/>
              </xsl:element>
          </xsl:template>
          <xsl:template match="@* | text()">
              <xsl:copy/>
          </xsl:template>
      </xsl:stylesheet>
____EOF;
        $xsl = \DOMDocument::loadXml($xsl);
        $proc = new \XSLTProcessor();
        $proc->importStyleSheet($xsl);
        $pq->document = $proc->transformToDoc($pq->document);
        for ($i = $pq->document->documentElement->attributes->length; $i >= 0; --$i) {
            $attr = $pq->document->documentElement->attributes->item($i);
            if (substr($attr->name, 0, 6) === 'xmlns:') {
                $pq->document->documentElement->removeAttributeNode($attr);
            }
        }
        $pq = PhpQuery::newDocumentHTML($pq->document->saveHTML());
        return $this;
    }
コード例 #13
0
ファイル: Template.class.php プロジェクト: jvmxgs/howto
 function DataAsHTML($xslFileName)
 {
     $xmlData = new SimpleXMLElement('<page/>');
     $this->generateXML($xmlData, $this->data);
     $xmlfilemodule = simplexml_load_file("modules/" . $this->data['name'] . "/elements.xml");
     $xmlData = dom_import_simplexml($xmlData)->ownerDocument;
     foreach (dom_import_simplexml($xmlfilemodule)->childNodes as $child) {
         $child = $xmlData->importNode($child, TRUE);
         $xmlData->documentElement->appendChild($child);
     }
     $xslfile = "templates/" . $this->template_name . "/" . $xslFileName . ".xsl";
     $xslfilemodule = "modules/" . $this->data['name'] . "/elements.xsl";
     if (in_array($this->data['name'], $this->selfPages)) {
         $xslfile = "templates/" . $this->template_name . "/" . $this->data['name'] . ".xsl";
     }
     $domXSLobj = new DOMDocument();
     $domXSLobj->load($xslfile);
     $xpath = new DomXPath($domXSLobj);
     $next = $xpath->query('//xsl:include');
     $next = $next->item(0);
     $next->setAttribute('href', $xslfilemodule);
     $next->setAttribute('xml:base', ROOT_SYSTEM);
     $xsl = new XSLTProcessor();
     $xsl->importStyleSheet($domXSLobj);
     return $xsl->transformToXml($xmlData);
 }
コード例 #14
0
ファイル: Html5.php プロジェクト: CG77/ezpublish-kernel
 /**
  * Returns the XSLTProcessor to use to transform internal XML to HTML5.
  *
  * @return \XSLTProcessor
  */
 protected function getXSLTProcessor()
 {
     if (isset($this->xsltProcessor)) {
         return $this->xsltProcessor;
     }
     $xslDoc = new DOMDocument();
     $xslDoc->load($this->stylesheet);
     // Now loading custom xsl stylesheets dynamically.
     // According to XSL spec, each <xsl:import> tag MUST be loaded BEFORE any other element.
     $insertBeforeEl = $xslDoc->documentElement->firstChild;
     foreach ($this->getSortedCustomStylesheets() as $stylesheet) {
         if (!file_exists($stylesheet)) {
             throw new RuntimeException("Cannot find XSL stylesheet for XMLText rendering: {$stylesheet}");
         }
         $newEl = $xslDoc->createElement('xsl:import');
         $hrefAttr = $xslDoc->createAttribute('href');
         $hrefAttr->value = $stylesheet;
         $newEl->appendChild($hrefAttr);
         $xslDoc->documentElement->insertBefore($newEl, $insertBeforeEl);
     }
     // Now reload XSL DOM to "refresh" it.
     $xslDoc->loadXML($xslDoc->saveXML());
     $this->xsltProcessor = new XSLTProcessor();
     $this->xsltProcessor->importStyleSheet($xslDoc);
     $this->xsltProcessor->registerPHPFunctions();
     return $this->xsltProcessor;
 }
コード例 #15
0
 /**
  * Main entry point
  * Perform the XSLT transformation on the found sas.xml files to transform the xml content to the wiki format
  * Create an output.xml file containing the export 
  * @return boolean
  */
 public function transform()
 {
     $this->log('Sas 2 Wiki', true);
     $sasFiles = $this->getSasFiles();
     $doc = new DOMDocument();
     $doc->load($this->xslFile);
     $xsl = new XSLTProcessor();
     $xsl->importStyleSheet($doc);
     $buffer = '';
     foreach ($sasFiles as $sasFile) {
         $this->log('perform transformation on ' . $sasFile);
         $doc->load($sasFile);
         $buffer .= $xsl->transformToXML($doc);
     }
     if (!empty($buffer)) {
         $content = "====== List of services ======\nThe sections below give us the list of all available services in the process authoring tool. \nSo you can use each of these TAO's chunk to build your services.";
         $content .= "\n{$buffer}\n";
         $content .= "''Generated by wfEngine/scripts/wikiSas.php : SaSWiki::transform on " . date('Y-m-d') . "''";
     }
     if (file_put_contents($this->outputFile, $content)) {
         $this->log($this->outputFile . " created");
         return true;
     }
     return false;
 }
コード例 #16
0
ファイル: XsltBlock.php プロジェクト: planetenkiller/core
 /**
  * display block
  *
  * @param        array       $blockinfo     a blockinfo structure
  * @return       output      the rendered bock
  */
 public function display($blockinfo)
 {
     if (!SecurityUtil::checkPermission('xsltblock::', "{$blockinfo['title']}::", ACCESS_OVERVIEW)) {
         return;
     }
     // Get our block vars
     $vars = BlockUtil::varsFromContent($blockinfo['content']);
     if ((!isset($vars['docurl']) || !isset($vars['styleurl'])) && (!isset($vars['doccontents']) || !isset($vars['stylecontents']))) {
         return;
     }
     // create new objects
     $doc = new \DOMDocument();
     $xsl = new \XSLTProcessor();
     // load stylesheet
     if (isset($vars['styleurl']) && !empty($vars['styleurl'])) {
         $doc->load($vars['styleurl']);
     } else {
         $doc->loadXML($vars['stylecontents']);
     }
     $xsl->importStyleSheet($doc);
     // load xml source
     if (isset($vars['docurl']) && !empty($vars['docurl'])) {
         $doc->load($vars['docurl']);
     } else {
         $doc->loadXML($vars['doccontents']);
     }
     // apply stylesheet and return output
     $blockinfo['content'] = $xsl->transformToXML($doc);
     return BlockUtil::themeBlock($blockinfo);
 }
コード例 #17
0
ファイル: retrieve.php プロジェクト: ulbricht/pmdmeta
function outdom($xmldom)
{
    $xsl = new XSLTProcessor();
    $xsldom = new DOMDocument();
    $xsldom->load("convert-remove-namespace.xslt");
    $xsl->importStyleSheet($xsldom);
    echo $xsl->transformToXML($xmldom);
}
コード例 #18
0
ファイル: Xslt.php プロジェクト: RickDB/newznab-tmux
 /**
  * Constructor
  *
  * @param string $xslt
  */
 public function __construct($xslt)
 {
     $xsl = new \XSLTProcessor();
     $xsldoc = new \DOMDocument();
     $xsldoc->loadXML($xslt);
     $xsl->importStyleSheet($xsldoc);
     $this->xsl = $xsl;
 }
コード例 #19
0
ファイル: template.php プロジェクト: PapaKot/Horowitz
 function transform($xml_data)
 {
     if ($this->de() && ($xml = $this->getXML($xml_data))) {
         $proc = new XSLTProcessor();
         $proc->importStyleSheet($this->dd());
         return $proc->transformToXML($xml->dd());
     }
     throw new Exception('Template not found');
 }
コード例 #20
0
ファイル: postToFile.php プロジェクト: rsdoiel/Jaxer
/**
 * write_xml_file
 */
function write_xml_file()
{
    // grab data
    $dataSource = $_SERVER["REQUEST_METHOD"] == "GET" ? $_GET : $_POST;
    // init attribute values
    $errors = 0;
    $failures = 0;
    $tests = 0;
    $time = 0;
    $tables = array();
    // grab key values of interest
    foreach ($dataSource as $key => $value) {
        switch ($key) {
            case "numCommandErrors":
                $errors = $value;
                break;
            case "numTestFailures":
                $failures = $value;
                break;
            case "numTestTotal":
                $tests = $value;
                break;
            case "totalTime":
                $time = $value;
                break;
            default:
                // Unescape double-quotes and replace nbsp entities with spaces
                if (preg_match('/^testTable_\\d+$/', $key)) {
                    $no_quotes = str_replace('\\"', '"', $value);
                    $no_entities = str_replace('&nbsp;', " ", $no_quotes);
                    array_push($tables, $no_entities);
                }
                break;
        }
    }
    // emit JUnit-style XML file
    $handle = fopen("test-result.xml", "w");
    // build XML text
    array_unshift($tables, "<testsuite errors=\"{$errors}\" failures=\"{$failures}\" tests=\"{$tests}\" time=\"{$time}\">");
    array_push($tables, "</testsuite>");
    $xml = join($tables, "\r\n");
    // load XML
    $doc = new DOMDocument();
    $doc->loadXML($xml);
    // load XSLT
    $xsl = new DOMDocument();
    $xsl->load("results-to-junit.xslt");
    // create XSLT processor
    $proc = new XSLTProcessor();
    $proc->importStyleSheet($xsl);
    // transform XML
    $result = $proc->transformToXML($doc);
    // write result
    fwrite($handle, $result);
    // we're done, so close the file
    fclose($handle);
}
コード例 #21
0
ファイル: rssreader.class.php プロジェクト: abbeet/server39
 function getFormattedXML($item)
 {
     $xml = @simplexml_load_string($item, 'SimpleXMLElement', LIBXML_NOWARNING);
     // create the XSLTProcessor object
     $proc = new XSLTProcessor();
     // attach the XSL
     $proc->importStyleSheet($this->mXsl);
     // apply the transformation and return formatted data as XML string
     return $proc->transformToXML($xml);
 }
コード例 #22
0
ファイル: xsl.php プロジェクト: BGCX262/zwf-svn-to-git
function xsl_transform_feed($feedUrl, $xslPath)
{
    $doc = new DOMDocument();
    $xsl = new XSLTProcessor();
    $doc->load(parse_path($xslPath));
    $xsl->importStyleSheet($doc);
    $doc->loadXML(file_get_contents(parse_path($feedUrl)));
    $xsl->registerPHPFunctions(array('xsl_counter'));
    return $xsl->transformToXML($doc);
}
コード例 #23
0
 public function printStatus()
 {
     if ($this->isRunning) {
         $xsl = new XSLTProcessor();
         $xsl->importStyleSheet(DOMDocument::load(FILE_FC_STATUS_XSL));
         $output = $xsl->transformToXML($this->domdoc);
         return $output;
     } else {
         return NULL;
     }
 }
コード例 #24
0
 static function get_feed_to_rif_transformer()
 {
     if (is_null(self::$feed_to_rif_transformer)) {
         $getRifFromFeed = new DomDocument();
         $getRifFromFeed->load('applications/registry/data_source/transforms/extract_rif_from_feed.xsl');
         $getRifFromFeedproc = new XSLTProcessor();
         $getRifFromFeedproc->importStyleSheet($getRifFromFeed);
         self::$feed_to_rif_transformer = $getRifFromFeedproc;
     }
     return self::$feed_to_rif_transformer;
 }
コード例 #25
0
 public function xslTransform($xhtml, $xsl_file)
 {
     $xml = new \DOMDocument();
     @$xml->loadXML($xhtml);
     $xsl = new \DOMDocument();
     $xsl->load($xsl_file);
     $proc = new \XSLTProcessor();
     $proc->importStyleSheet($xsl);
     // attach the xsl rules
     return $proc->transformToXML($xml);
 }
コード例 #26
0
ファイル: XSL.php プロジェクト: jasny/Q
 /**
  * Creates a new XSLTProcessor object and imports the stylesheet into the object 
  *
  * @return XSLTProcessor object
  */
 protected function getXSLTProcessor()
 {
     if (empty($this->template) || !is_string($this->template) && !$this->template instanceof Fs_Node) {
         throw new Transform_Exception("Unable to start XSL transformation : No template available or wrong variable type");
     }
     $toLoad = $this->template;
     $xslDoc = $this->loadXML($this->template);
     $xsltProcessor = new \XSLTProcessor();
     $xsltProcessor->importStyleSheet($xslDoc);
     return $xsltProcessor;
 }
コード例 #27
0
 /**
  * Do the transformation of the payload to RIFCS.
  *
  * @return string A valid RIFCS XML string (including wrapper)
  */
 public function payloadToRIFCS($payload, &$log = array())
 {
     $dom = new DOMDocument();
     $dom->loadXML($payload);
     unset($payload);
     $log[] = "[CROSSWALK] Attempting to execute crosswalk " . $this->identify();
     $xsl = new DomDocument();
     $xsl->load(REGISTRY_APP_PATH . 'core/crosswalks/_xsl/dc_to_rifcs.xsl');
     $transformer = new XSLTProcessor();
     $transformer->importStyleSheet($xsl);
     return $transformer->transformToXML($dom);
 }
コード例 #28
0
 /**
  * transform
  * @param $xslt string if string starts with less-than character XSLT is passed as string **OTHERWISE** filename!!
  * @return string html-content
  */
 function transform($xsltOrFilename)
 {
     $xslt = new XSLTProcessor();
     $style = substr($xsltOrFilename, 0, 1) == '<' ? DomDocument::loadXML($xsltOrFilename) : DomDocument::load($xsltOrFilename);
     // error in loading the xslt
     if ($style == null) {
         return '<b>Failed to load:</b><pre>' . $xsltOrFilename . '</pre>';
     }
     $xslt->importStyleSheet($style);
     return $xslt->transformToXML($this->xml);
     // return result
 }
コード例 #29
0
ファイル: functions.php プロジェクト: emylonas/Decameron
function runXSLT($xml, $xsl, $params)
{
    $loadfile = new DOMDocument();
    $processor = new XSLTProcessor();
    $loadfile->load($xsl);
    $processor->importStyleSheet($loadfile);
    foreach ($params as $key => $value) {
        $processor->setParameter('', $key, $value);
    }
    $loadfile->load($xml);
    return $processor->transformToXML($loadfile);
}
コード例 #30
0
ファイル: XSLClass.php プロジェクト: rasstroen/audio
	public function getHTML($xml) {
		global $current_user;
		Log::timingplus('XSLTProcessor');
		$xslTemplate = new DOMDocument();
		$xslProcessor = new XSLTProcessor();
		$filename = Config::need('xslt_files_path') . DIRECTORY_SEPARATOR . $current_user->getTheme() . DIRECTORY_SEPARATOR . $this->xsltFileName;
		$xslTemplate->load($filename, LIBXML_NOENT | LIBXML_DTDLOAD);
		$xslProcessor->importStyleSheet($xslTemplate);
		$html = $xslProcessor->transformToXML($xml);
		Log::timingplus('XSLTProcessor');
		return $html;
	}