Beispiel #1
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $flow = Nexista_Flow::Singleton('Nexista_Flow');
     $file_path = Nexista_Path::parseInlineFlow($this->params['xsl']);
     $xslfile = NX_PATH_APPS . $file_path;
     if (!is_file($xslfile)) {
         Nexista_Error::init('XSL Action - file unavailable: ' . $xslfile, NX_ERROR_FATAL);
     }
     $xsl = new DomDocument('1.0', 'UTF-8');
     $xsl->substituteEntities = false;
     $xsl->resolveExternals = false;
     $xslfilecontents .= file_get_contents($xslfile);
     $xsl->loadXML($xslfilecontents);
     $xsl->documentURI = $xslfile;
     $use_xslt_cache = "yes";
     if ($use_xslt_cache != "yes" || !class_exists('xsltCache')) {
         $xslHandler = new XsltProcessor();
     } else {
         $xslHandler = new xsltCache();
     }
     $xslHandler->importStyleSheet($xsl);
     $my_output = $xslHandler->transformToXML($flow->flowDocument);
     if ($my_output === false) {
         Nexista_Error::init('XSL Action - Error processing XSL file: ' . $xslfile, NX_ERROR_FATAL);
         return false;
     }
     $new_node = $this->params['new_node'];
     Nexista_Flow::add($new_node, $my_output);
     return true;
 }
Beispiel #2
0
 /**
  * process xsl template with Flow xml
  *
  * @param   string      xsl source file
  * @return  string      xsl transformation output
  */
 public function process($xslfile)
 {
     $flow = Nexista_Flow::Singleton('Nexista_Flow');
     // The following can be used with the NYT xslt cache.
     $use_xslt_cache = "yes";
     if (!is_file($xslfile)) {
         Nexista_Error::init('XSL Handler - Error processing XSL file,
             it is unavailable: ' . $xslfile, NX_ERROR_FATAL);
     }
     if ($use_xslt_cache != "yes" || !class_exists('xsltCache')) {
         $xsl = new DomDocument('1.0', 'UTF-8');
         $xsl->substituteEntities = false;
         $xsl->resolveExternals = false;
         $xslfilecontents .= file_get_contents($xslfile);
         $xsl->loadXML($xslfilecontents);
         $xsl->documentURI = $xslfile;
         $xslHandler = new XsltProcessor();
         $xslHandler->importStyleSheet($xsl);
         if (4 == 3 && function_exists('setProfiling')) {
             $xslHandler->setProfiling("/tmp/xslt-profiling.txt");
         }
     } else {
         $xslHandler = new xsltCache();
         $xslHandler->importStyleSheet($xslfile);
     }
     $output = $xslHandler->transformToXML($flow->flowDocument);
     if ($output === false) {
         Nexista_Error::init('XSL Handler - Error processing XSL file: ' . $xslfile, NX_ERROR_FATAL);
     }
     return $output;
 }