Пример #1
0
 public function saveXML($me = true)
 {
     $xml = new XMLDom();
     if (!self::$xsl instanceof \XSLTProcessor) {
         self::$xsl = new \XSLTProcessor();
         self::$xsl->importStylesheet(XMLDom::loadXMLString('<?xml version="1.0" encoding="utf-8"?>
             <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
             <xsl:output omit-xml-declaration="yes" method="xml"/>
             <xsl:template match="node()|@*" priority="-4">
                 <xsl:copy>
                     <xsl:apply-templates  select="@*"/>
                     <xsl:apply-templates />
                 </xsl:copy>
             </xsl:template>
             <xsl:template match="/" priority="-4">
                 <xsl:apply-templates />
             </xsl:template>
         </xsl:stylesheet>'));
     }
     if ($me) {
         $xml->appendChild($xml->importNode($this, true));
         return self::$xsl->transformToXml($xml);
     } else {
         foreach ($this->childNodes as $node) {
             $xml->appendChild($xml->importNode($node, true));
         }
     }
     return self::$xsl->transformToXml($xml);
 }
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);
}
Пример #3
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);
 }
Пример #4
0
 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);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $environment = $input->getOption('env');
     try {
         $transformer = $input->getOption('xsl');
         $xsl = new \DOMDocument();
         $xsl->load($transformer);
         $xslt = new \XSLTProcessor();
         $xslt->registerPHPFunctions();
         $xslt->importStylesheet($xsl);
         $files = $input->getOption('file');
         foreach ($files as $file) {
             $output->writeln('Transforming file: ' . $file);
             $doc = new \DOMDocument();
             $doc->load($file);
             $xml = $xslt->transformToXml($doc);
             $xmlobj = new \SimpleXMLElement($xml);
             $xmlobj->asXML('output.xml');
         }
     } catch (\Exception $ex) {
         $exception = new OutputFormatterStyle('red');
         $output->getFormatter()->setStyle('exception', $exception);
         $output->writeln("\n\n");
         $output->writeln('<exception>[Exception in: ' . get_class($this) . ']</exception>');
         $output->writeln('<exception>Exception: ' . get_class($ex) . ' with message: ' . $ex->getMessage() . '</exception>');
         $output->writeln('<exception>Stack Trace:</exception>');
         $output->writeln('<exception>' . $ex->getTraceAsString() . '</exception>');
         exit(1);
     }
     exit(0);
 }
 /**
  * Tests that the header stylesheet does not reprints the complete log file
  * content. This issue occured with some CC versions because the corresponding
  * template does not include a default template for <b>/</b>.
  *
  * @return void
  * @group stylesheet
  */
 public function testHeaderDoesNotContainCompleteLogFileContentXsltProcessor()
 {
     $xsl = $this->createXslStylesheet('header.xsl');
     $xml = $this->createCruiseControlLog();
     $proc = new XSLTProcessor();
     $proc->importStylesheet($xsl);
     $this->assertSame($this->loadExpectedResult(), trim($proc->transformToXml($xml)));
 }
Пример #7
0
 /**
  * @param DOMDocument|SimpleXMLElement $doc
  * @return string
  */
 public function transformToXML($doc)
 {
     $styleSheet = $this->styleSheetToDomDocument();
     $transpiler = $this->createTranspiler($styleSheet);
     libxml_use_internal_errors();
     parent::importStylesheet($this->getTranspiledStyleSheet($transpiler, $styleSheet));
     return $transpiler->transform(function () use($doc) {
         return parent::transformToXml($doc);
     });
 }
Пример #8
0
 /**
  * Transform the XML/XSL documents into an XML (probably XHTML) document
  * @return string
  */
 public function execute($parameters = array())
 {
     $xslt = new XSLTProcessor();
     $xslt->importStylesheet($this->xsl);
     $xslt->setParameter(null, $parameters);
     //unfortunately this doesn't capture any warnings generated whilst transforming
     $transformation = $xslt->transformToXml($this->xml);
     if ($transformation === false) {
         throw new MalformedPage("There was an error tranforming the page");
     }
     return $transformation;
 }
Пример #9
0
 public function process()
 {
     $xslt = new XSLTProcessor();
     $xslt->registerPHPFunctions();
     $baseExt = 'Base';
     $xslt->setParameter('', 'ext', $baseExt);
     $xslt->importStylesheet($this->stylesheet);
     $baseTypes = $xslt->transformToXml($this->schema);
     $fp = fopen('BaseTypes.php', 'w');
     fwrite($fp, $baseTypes);
     fclose($fp);
 }
Пример #10
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     // Check if XSLT extension is loaded properly, because we will need it...
     // The XSL extension implements the XSL standard, performing XSLT transformations using the libxslt library.
     $xslext = extension_loaded('xsl');
     if (!$xslext) {
         $missingextensions = array();
         !$xslext && ($missingextensions[] = 'xsl');
         $errormsg = '<p>' . get_string('europassextensionmissing', 'artefact.europass') . '</p>';
         $errormsg .= '<ul>';
         foreach ($missingextensions as $extension) {
             $errormsg .= '<li><a href="http://www.php.net/' . $extension . '">' . $extension . '</a></li>';
         }
         $errormsg .= '</ul>';
         return $errormsg;
         exit;
     }
     global $USER;
     $configdata = $instance->get('configdata');
     if ($configdata == array()) {
         $locale = set_default_locale(get_config('lang'));
     } else {
         $locale = $configdata['locale'];
     }
     $configdata['viewid'] = $instance->get('view');
     // Load up the Europass CV generated XML string
     //$xmlDoc = new DOMDocument;
     //$xmlDoc->loadXML(generate_europasscv_xml((!empty($configdata['userid']) ? $configdata['userid'] : $USER->get('id')), true, $locale, (!empty($configdata['internaldate']) ? $configdata['internaldate'] : 'dmy11'), (!empty($configdata['externaldate']) ? $configdata['externaldate'] : '/numeric/long')));
     $xmlDoc = simplexml_load_string(generate_europasscv_xml(!empty($configdata['userid']) ? $configdata['userid'] : $USER->get('id'), true, $locale, !empty($configdata['internaldate']) ? $configdata['internaldate'] : 'dmy11', !empty($configdata['externaldate']) ? $configdata['externaldate'] : '/numeric/long'));
     // Load up the appropriate XSL file, according to selected locale
     //$xslDoc = new DOMDocument;
     //$xslDoc->load(get_config('docroot') . 'artefact/europass/blocktype/europasscv/xsl/cv_' . $locale . '_V2.0.xsl');
     $xslDoc = simplexml_load_string(file_get_contents(get_config('wwwroot') . 'artefact/europass/blocktype/europasscv/xsl/cv_' . $locale . '_V2.0.xsl'));
     //Start the XSLT processor and import stylesheet
     $xslt = new XSLTProcessor();
     $xslt->importStyleSheet($xslDoc);
     // Apply the transformation
     $html = $xslt->transformToXml($xmlDoc);
     $start = stripos($html, '<body>');
     $finish = stripos($html, '</body>');
     $result = '<link rel="stylesheet" type="text/css" href="' . get_config('wwwroot') . 'artefact/europass/theme/raw/static/style/html.css">';
     //$result .= '<table width="700" border="0" cellspacing="0" cellpadding="0" class="CV" id="CV">';
     $result .= substr($html, $start + 6, $finish - $start);
     //$result .= '</table>';
     $result = html_entity_decode($result);
     // Replace the following reference because it does not exist anymore:
     // http://europass.cedefop.europa.eu/instruments/images/logospace.gif
     $result = str_replace('http://europass.cedefop.europa.eu/instruments/images/logospace.gif', get_config('wwwroot') . 'artefact/europass/images/space.png', $result);
     return $result;
 }
Пример #11
0
 public function getHtmlForObjectId(\FrameResponseObject $frameResponseObject)
 {
     $mplme = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id);
     if (isset($this->params[1]) && !strstr($this->params[1], "?")) {
         $doc = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $mplme->get_path() . "/" . $this->params[1]);
         if (isset($doc) && $doc !== 0 && $doc instanceof \steam_document) {
             echo $doc->download();
             //echo $doc->get_content();
         } else {
             echo "404";
         }
         die;
     }
     $elements = $mplme->get_inventory();
     $html = "";
     foreach ($elements as $element) {
         if ($element->get_name() == "data.xml") {
             $xmlContent = $element->get_content();
             //$html .= "<b>".$element->get_name()."</b><br><pre>". htmlentities($element->get_content()) . "</pre><br>";
         } else {
             if ($element->get_name() == $_REQUEST["xslName"] . ".xsl") {
                 $xslContent = $element->get_content();
                 //$html .= "<b>".$element->get_name()."</b><br><pre>". htmlentities($element->get_content()) . "</pre><br>";
             } else {
                 //$html .= "<b>".$element->get_name()."</b><br>";
             }
         }
     }
     if (isset($xmlContent) && isset($xslContent)) {
         $xml = new \DOMDocument();
         $xml->loadXML($xmlContent);
         $searchstring = '/<includexslt[ 0-9a-zA-Z=\\/\\"]*url="([~\\-0-9a-zA-Z=\\:\\?\\&\\.\\/]+)"[ 0-9a-zA-Z=\\/"]*[ \\-0-9a-zA-Z=\\/"]*\\/>/i';
         $xslContent = preg_replace_callback($searchstring, array(&$this, 'cb_replace'), $xslContent);
         $xsl = new \DOMDocument();
         $xsl->loadXML($xslContent);
         $proc = new \XSLTProcessor();
         $proc->importStylesheet($xsl);
         $html .= $proc->transformToXml($xml);
     }
     if (isset($_REQUEST['output']) && $_REQUEST['output'] === "download") {
         header('Content-Disposition: attachment; filename=data.' . $_REQUEST['xslName']);
     }
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($html);
     $frameResponseObject->addWidget($rawHtml);
     $frameResponseObject->setHeadline(array(array("name" => "zurück", "link" => "javascript:history.back()"), array("name" => "Mplme")));
     return $frameResponseObject;
 }
Пример #12
0
    public function render()
    {
        //return $this->xml;
        // processor
        $processor = new XSLTProcessor();
        // xsl DOMDoc
        $xslDoc = new DOMDocument();
        $xslDoc->loadXML('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
		<xsl:output method="html" doctype-system="http://www.w3.org/TR/html4/strict.dtd" doctype-public="-//W3C//DTD HTML 4.01//EN" indent="yes"/>
		' . $this->xsl . '</xsl:stylesheet>');
        // xml DOMDoc
        $xmlDoc = new DOMDocument();
        $xmlDoc->loadXML($this->xml);
        $processor->importStyleSheet($xslDoc);
        return $processor->transformToXml($xmlDoc);
    }
Пример #13
0
function odt2spip_traiter_mathml($chemin_fichier) {
  // recuperer le contenu du fichier
    if (!$mathml = file_get_contents($chemin_fichier)) return(_T('odtspip:err_transformation_xslt_mathml'));
  
  // virer le DOCTYPE qui plante le parseur vu que la dtd n'est pas disponible
    $mathml = preg_replace('/<!DOCTYPE.*?>/i', '', $mathml);

  // variable en dur pour xslt utilisée
//    $xml_entre = _DIR_TMP.'odt2spip/'.$id_auteur.'/content.xml';  // chemin du fichier xml à lire
    $xslt_texte = _DIR_PLUGIN_ODT2SPIP.'inc/xsltml/mmltex.xsl'; // chemin de la xslt à utiliser pour les maths
    
  // appliquer la transformation XSLT sur le fichier content.xml
    // déterminer les fonctions xslt à utiliser (php 4 ou php 5)
    if (!class_exists('XSLTProcessor')) {
      // on est en php4 : utiliser l'extension et les fonction xslt de Sablotron
      // Crée le processeur XSLT
        $xh = xslt_create();
      // si on est sur un serveur Windows utiliser xslt_set_base avec le préfixe file://
        if (strpos($_SERVER['SERVER_SOFTWARE'], 'Win') !== false) xslt_set_base($xh, 'file://' . getcwd () . '/');
      
      // lancer le parseur
        $arguments = array('/_xml' => $mathml);
        $latex_sortie = xslt_process($xh, 'arg:/_xml', $xslt_texte, NULL, $arguments);
        if (!$latex_sortie) return(_T('odtspip:err_transformation_xslt_mathml'));
      
      // Détruit le processeur XSLT
        xslt_free($xh);
    }
    else {
      // on est php5: utiliser les fonctions de la classe XSLTProcessor
        $proc = new XSLTProcessor();
        
        $xml = new DOMDocument();
        $xml->loadXML($mathml);
        $xsl = new DOMDocument();
        $xsl->load($xslt_texte);
        $proc->importStylesheet($xsl); // attachement des règles xsl
        
      // lancer le parseur
        if (!$latex_sortie = $proc->transformToXml($xml)) return(_T('odtspip:err_transformation_xslt_mathml'));
    }
  
    return $latex_sortie;  
}
Пример #14
0
 public static function transform($data, $type)
 {
     $xslt = APPLICATION_PATH . "/configs/repository/0.1/xslt/" . $type;
     $xslt = $xslt . ".xsl";
     if (file_exists($xslt)) {
         $xsl = new DOMDocument();
         $xsl->load($xslt);
         $xml = new DOMDocument();
         $xml->loadXML($data, LIBXML_NSCLEAN | LIBXML_COMPACT);
         $proc = new XSLTProcessor();
         $proc->registerPHPFunctions();
         $proc->importStylesheet($xsl);
         $data = $proc->transformToXml($xml);
         $data = str_replace('<?xml version="1.0"?' . '>', '', $data);
     } else {
         error_log('Cannot find ' . $xslt);
     }
     return $data;
 }
Пример #15
0
 /**
  * Return the full rendered version of the Horde_Mime_Part object.
  *
  * @return array  See parent::render().
  * @throws Horde_Exception
  */
 protected function _render()
 {
     $has_xsl = Horde_Util::extensionExists('xsl');
     if ($has_xsl) {
         $tmpdir = Horde_Util::createTempDir(true) . '/';
     }
     $fnames = array('content.xml', 'styles.xml', 'meta.xml');
     $tags = array('text:p' => 'p', 'table:table' => 'table border="0" cellspacing="1" cellpadding="0" ', 'table:table-row' => 'tr bgcolor="#cccccc"', 'table:table-cell' => 'td', 'table:number-columns-spanned=' => 'colspan=');
     if (!$this->getConfigParam('zip')) {
         $this->setConfigParam('zip', Horde_Compress::factory('Zip'));
     }
     $list = $this->getConfigParam('zip')->decompress($this->_mimepart->getContents(), array('action' => Horde_Compress_Zip::ZIP_LIST));
     foreach ($list as $key => $file) {
         if (in_array($file['name'], $fnames)) {
             $content = $this->getConfigParam('zip')->decompress($this->_mimepart->getContents(), array('action' => Horde_Compress_Zip::ZIP_DATA, 'info' => $list, 'key' => $key));
             if ($has_xsl) {
                 file_put_contents($tmpdir . $file['name'], $content);
             } elseif ($file['name'] == 'content.xml') {
                 return array($this->_mimepart->getMimeId() => array('data' => str_replace(array_keys($tags), array_values($tags), $content), 'status' => array(), 'type' => 'text/html; charset=UTF-8'));
             }
         }
     }
     if (!$has_xsl) {
         return array();
     }
     $xslt = new XSLTProcessor();
     $xsl = new DOMDocument();
     $xsl->load(realpath(__DIR__ . '/Ooo/export/xhtml/opendoc2xhtml.xsl'));
     $xslt->importStylesheet($xsl);
     $xslt->setParameter('http://www.w3.org/1999/XSL/Transform', array('metaFileURL' => 'file://' . $tmpdir . 'meta.xml', 'stylesFileURL' => 'file://' . $tmpdir . 'styles.xml', 'java' => false));
     $xml = new DOMDocument();
     $xml->load(realpath($tmpdir . 'content.xml'));
     $result = $xslt->transformToXml($xml);
     if (!$result) {
         $result = libxml_get_last_error()->message;
     }
     return array($this->_mimepart->getMimeId() => array('data' => $result, 'status' => array(), 'type' => 'text/html; charset=UTF-8'));
 }
Пример #16
0
function process()
{
    // Load the XML source
    $xml = new DOMDocument();
    $xml->load(SRC_DIR . '/set.xml');
    // Interpolate all XInclude directives.
    $xml->xinclude();
    // Load the XSLT stylesheet.
    $xsl = new DOMDocument();
    $xsl->load(DOCBOOK_STYLESHEET_DIR . '/html/docbook.xsl');
    // Configure the transformer
    $proc = new XSLTProcessor();
    if (!$proc->hasExsltSupport()) {
        throw new Exception('EXSLT Support not available.');
    }
    $proc->importStyleSheet($xsl);
    // attach the xsl rules
    //file_put_contents('test.html', $proc->transformToXml($xml));
    $book = $xml->getElementById('tm');
    var_dump($book);
    var_dump(gettype($book));
    file_put_contents('test-book.html', $proc->transformToXml($book));
}
Пример #17
0
// Load the docbook file (input)
$xml = new \DOMDocument();
$xml->load($docbook);
$xsltFile = __DIR__ . '/doc2rst.xsl';
// Load the XSLT file
$xsl = new \DOMDocument();
if (!file_exists($xsltFile)) {
    echo "The {$xsltFile} is missing, I cannot proceed with the conversion." . PHP_EOL;
    exit(2);
}
$xsl->load($xsltFile);
$proc = new \XSLTProcessor();
$proc->registerPHPFunctions();
$proc->importStyleSheet($xsl);
echo "Writing to {$rstFile}\n";
$output = $proc->transformToXml($xml);
if (false === $output) {
    echo 'Error during the conversion' . PHP_EOL;
    exit(2);
}
// remove single spaces in the beginning of new lines
$lines = explode("\n", $output);
$output = '';
foreach ($lines as $line) {
    if ($line === '') {
        $output .= "\n";
    } elseif ($line[0] === ' ' && $line[1] !== ' ') {
        $output .= substr($line, 1) . "\n";
    } else {
        // Remove trailing spaces
        $output .= rtrim($line) . "\n";
Пример #18
0
 $xml .= "</zutrittskarte>";
 // XSL-Vorlage von content.xml laden
 $xsl_doc = new DOMDocument();
 if (!$xsl_doc->loadXML($xsl_content)) {
     die('Fehler beim Laden der XSL Vorlage von content.xml.');
 }
 // XML Dokument in ein DOM Objekt laden
 $xml_doc = new DOMDocument();
 if (!$xml_doc->loadXML($xml)) {
     die('Fehler beim Laden des XML');
 }
 // XSL File in den Processor laden
 $proc = new XSLTProcessor();
 $proc->importStyleSheet($xsl_doc);
 // XSL-Transformation starten
 $buffer = $proc->transformToXml($xml_doc);
 // Konvertierte content.xml ins Filesystem schreiben
 file_put_contents('content.xml', $buffer);
 //Debugging XML
 //file_put_contents('Pictures/out.xml', $xml);
 // Bilder zum ZIP-File hinzufuegen
 exec("zip {$tempname_zip} Pictures/*");
 // content.xml ins ZIP-File hinzufuegen
 exec("zip {$tempname_zip} content.xml");
 if ($output == 'pdf') {
     exec("unoconv --stdout -f pdf {$tempname_zip} > out.pdf");
     $tempname_zip = 'out.pdf';
 }
 //Ausgeben des Dokuments
 clearstatcache();
 $fsize = filesize($tempname_zip);
Пример #19
0
 /**
  * Applies XSL style sheet to template's parts.
  *
  * @param \DOMDocument $xslDOMDocument
  * @param array $xslOptions
  * @param string $xslOptionsURI
  * @return void
  * @throws \PhpOffice\PhpWord\Exception\Exception
  */
 public function applyXslStyleSheet($xslDOMDocument, $xslOptions = array(), $xslOptionsURI = '')
 {
     $xsltProcessor = new \XSLTProcessor();
     $xsltProcessor->importStylesheet($xslDOMDocument);
     if (false === $xsltProcessor->setParameter($xslOptionsURI, $xslOptions)) {
         throw new Exception('Could not set values for the given XSL style sheet parameters.');
     }
     $xmlDOMDocument = new \DOMDocument();
     if (false === $xmlDOMDocument->loadXML($this->temporaryDocumentMainPart)) {
         throw new Exception('Could not load XML from the given template.');
     }
     $xmlTransformed = $xsltProcessor->transformToXml($xmlDOMDocument);
     if (false === $xmlTransformed) {
         throw new Exception('Could not transform the given XML document.');
     }
     $this->temporaryDocumentMainPart = $xmlTransformed;
 }
Пример #20
0
 /**
  * 
  * @param $article
  * @param $isNew
  */
 function onIndexContent($article, $isNew = false)
 {
     //FIXME move the content type tests and following transformations to the helper
     global $mainframe;
     $pk = $article->id;
     if (!$isNew) {
         JuceneHelper::removeFromIndex('pk:' . $pk);
     }
     $index = JuceneHelper::getIndex();
     $xml_field = substr($article->fulltext, 0, 5) != '<?xml' ? $article->introtext : $article->fulltext;
     if (substr($xml_field, 0, 5) == '<?xml') {
         $dom = new DOMDocument();
         $pmml = true;
         $xslt = new DOMDocument();
         $error = false;
         //load xslt stylesheet
         if (!@$xslt->load(JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_jucene' . DS . 'xslt/jucene.xsl')) {
             $error = true;
             $this->raiseMessage("XSLTLOADERROR", 'error');
         }
         $proc = new XSLTProcessor();
         if (!$proc->importStylesheet($xslt)) {
             $error = true;
             $this->raiseMessage("XSLTIMPORTERROR", 'error');
         }
         unset($artcile->fulltext);
         unset($record->introtext);
         if ($dom->loadXML($xml_field) && !$error && $pmml) {
             //simplify the document - prepare it for the indexation process
             $xslOutput = $proc->transformToXml($dom);
             //create new DOM document to preserve output and transform the XML to the indexable one
             $transXml = new DOMDocument();
             $transXml->preserveWhitespace = false;
             @$transXml->loadXML($xslOutput);
             //unset unneccessary variables
             unset($xslOutput);
             unset($dom);
             unset($xslt);
             //index every assoc rule as document with same credentials
             if (!$error) {
                 $rules = $transXml->getElementsByTagName("AssociationRule");
                 $rulesCount = $rules->length;
                 if ($rulesCount == 0) {
                     $error = true;
                     $this->raiseMessage('XMLDOCUMENTNORULES', 'error');
                 }
                 $rule_doc_position = 0;
                 foreach ($rules as $rule) {
                     $additional['rating'] = 0;
                     $additional['position'] = $rule_doc_position;
                     JPluginHelper::importPlugin('content');
                     $dispatcher =& JDispatcher::getInstance();
                     $results = $dispatcher->trigger('onIndexPmml', array($rule, $additional));
                     $rule_doc_position++;
                 }
             }
         }
     } else {
         $zendDoc = Zend_Search_Lucene_Document_Html::loadHTML($article->fulltext, false, UTF - 8);
         $index->addDocument($zendDoc);
     }
 }
Пример #21
0
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>HTTP XML POST Dump</title>
	</head>
	<body>
		<h1>HTTP XML POST Dump</h1>
		<h2>Raw Data :</h2>
		<?php 
$body = file_get_contents("php://input");
echo strlen($body);
echo " bytes: <br/>";
echo "<pre>{$body}</pre>";
if (substr($body, 0, 9) == "postdata=") {
    $body = urldecode(substr($body, strpos($body, "=") + 1));
}
$xml = new DOMDocument();
$xml->loadXML($body);
$xslt = new XSLTProcessor();
$xsl = new DOMDocument();
$indent = "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\"><xsl:output method=\"xml\" indent=\"yes\" encoding=\"UTF-8\"/><xsl:template match=\"@*|node()\"><xsl:copy-of select=\".\"/></xsl:template></xsl:stylesheet>";
$xsl->loadXML($indent);
$xslt->importStylesheet($xsl);
$result = $xslt->transformToXml($xml);
$result = substr($result, strpos($result, "?>") + 3);
echo "<h2>Indented XML :</h2><pre>" . htmlspecialchars($result, ENT_QUOTES) . "</pre>";
?>
	</body>
</html>
Пример #22
0
    include $_GET['uri'] . "." . $type;
    exit;
} else {
    if (file_exists($_GET['uri'] . ".rdf")) {
        $rdfxml = file_get_contents($_GET['uri'] . ".rdf");
        if ($type == 'ttl') {
            $turtle = convert($rdfxml, "turtle", $prefix);
            header('Content-type: text/turtle');
            echo $turtle;
        } elseif ($type == 'nt') {
            $nt = convert($rdfxml, "ntriples", $prefix);
            header('Content-type: text/plain');
            echo $nt;
        } elseif ($type == 'html') {
            include '../../../header.htmlfrag';
            $xslt = new XSLTProcessor();
            $xslDoc = new DOMDocument();
            $xslDoc->load("../rdf2html.xsl");
            $xslt->importStylesheet($xslDoc);
            echo $xslt->transformToXml(new SimpleXMLElement($rdfxml));
            include '../license.htmlfrag';
            include '../../../footer.htmlfrag';
        }
    } else {
        header('HTTP/1.0 404 Not Found');
        echo "<h1>404 Not Found</h1>";
        echo "No uri";
        echo "The page that you have requested could not be found.";
        exit;
    }
}
 public function transformXslForEntry(EntryDistribution $entryDistribution, $xsl, $xslParams = array())
 {
     $xslParams['entryDistributionId'] = $entryDistribution->getId();
     $xslParams['distributionProfileId'] = $entryDistribution->getDistributionProfileId();
     $mrssDoc = $this->getEntryMrssDoc($entryDistribution);
     $xslDoc = new DOMDocument();
     $xslDoc->loadXML($xsl);
     $xslt = new XSLTProcessor();
     $xslt->registerPHPFunctions();
     // it is safe to register all php fuctions here
     $xslt->setParameter('', $xslParams);
     $xslt->importStyleSheet($xslDoc);
     return $xslt->transformToXml($mrssDoc);
 }
Пример #24
0
 /**
  * Public Method for import of Institutes
  *
  * @param void
  * @return void
  *
  */
 public function start()
 {
     $role = Opus_CollectionRole::fetchByName('institutes');
     $xml = new DomDocument();
     $xslt = new DomDocument();
     $xslt->load($this->_stylesheetPath);
     $proc = new XSLTProcessor();
     $proc->registerPhpFunctions();
     $proc->importStyleSheet($xslt);
     $xml->loadXML($proc->transformToXml($this->_data));
     $doclist = $xml->getElementsByTagName('table_data');
     foreach ($doclist as $document) {
         if ($document->getAttribute('name') === 'university_de') {
             $this->importUniversities($document);
         }
         if ($document->getAttribute('name') === 'faculty_de') {
             $facNumbers = $this->importFaculties($document, $role);
         }
         if ($document->getAttribute('name') === 'institute_de') {
             $instNumbers = $this->importInstitutes($document, $facNumbers);
         }
     }
 }
Пример #25
0
<table class="DE">
<tr><th class="DE">Fencer</th><th colspan="2"  class="DE">Score</th><th class="DE">Opponent</th></tr>
<xsl:variable name="poolid" select="@id"/>
<xsl:for-each select="result[@id != current()/@id]">
<xsl:variable name="score" select="@score"/>
<xsl:for-each select="../../fencer[@id = current()/@id]/result[@id = $poolid]">
<tr><td class="DE"><xsl:value-of select="$fencername" /></td>
<xsl:choose>
<xsl:when test="string-length($score) > 0 and string-length(@score) > 0">
<td class="DE"><xsl:value-of select="$score" /></td><td class="DE"><xsl:value-of select="@score" /></td>
</xsl:when><xsl:otherwise><td class="DE score" colspan="2">-</td></xsl:otherwise></xsl:choose>
<td class="DE"><a><xsl:attribute name="href">fencer.php?competition=' . $compid . '&amp;fencer=<xsl:value-of select="../@fencerid" />&amp;tournament=' . $tournid . '</xsl:attribute><xsl:value-of select="../@name" /></a></td></tr>
</xsl:for-each>
</xsl:for-each>
</table></p>
</xsl:for-each>

<br />
<a><xsl:attribute name="href">competition.php?competition=' . $compid . '&amp;tournament=' . $tournid . '</xsl:attribute>Up to Fencers</a>
</body>
</html>
</xsl:template>


</xsl:stylesheet>';
$xslt = new XSLTProcessor();
$xslt->importStylesheet(new SimpleXMLElement($xslt_string));
$xmlDoc = new DOMDocument();
$xmlDoc->load($tournid . "/competitions/" . $compid . ".xml");
echo $xslt->transformToXml($xmlDoc);
//echo $xslt_string;
Пример #26
0
 * OPUS is free software; you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the Licence, or any later version.
 * OPUS is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details. You should have received a copy of the GNU General Public License 
 * along with OPUS; if not, write to the Free Software Foundation, Inc., 51 
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * @category    Application
 * @author      Ralf Claussnitzer <*****@*****.**>
 * @copyright   Copyright (c) 2009, OPUS 4 development team
 * @license     http://www.gnu.org/licenses/gpl.html General Public License
 * @version     $Id$
 */
$args = $GLOBALS['argv'];
if (count($args) < 3) {
    echo 'Usage: ' . $args[0] . ' PathToXsl PathToXml' . "\n";
    exit;
}
$xslt = new DOMDocument();
$xslt->load($args[1]);
$xml = new DOMDocument();
$xml->load($args[2]);
$proc = new XSLTProcessor();
$proc->registerPhpFunctions();
$proc->importStyleSheet($xslt);
error_reporting(0);
echo $proc->transformToXml($xml);
Пример #27
0
 public static function Transform($xsltname, $version, $query)
 {
     if (count($query) > 0) {
         if (!AppdbAPIRequestProcessor::IsQueryValid($query)) {
             return null;
         }
         $qxml = AppdbAPIRequestProcessor::RequestToXml($query);
         $qres = "";
         //xml representation of the request
         $xf = AppdbAPIRequestProcessor::GetRequestXSLTPath($version) . $xsltname . '.xsl';
         if (file_exists($xf)) {
             $xsl = new DOMDocument();
             $xsl->load($xf);
             $xml = new DOMDocument();
             $xml->loadXML($qxml, LIBXML_NSCLEAN | LIBXML_COMPACT);
             $proc = new XSLTProcessor();
             $proc->importStylesheet($xsl);
             $qres = str_replace('<?xml version="1.0"?>', '', $proc->transformToXml($xml));
             return AppdbAPIRequestProcessor::XmlToRequest($qres);
         }
     }
     return $query;
 }
Пример #28
0
 function ENCODED_OCR($dsid = 'ENCODED_OCR', $label = 'Encoded OCR', $language = 'eng')
 {
     $this->log->lwrite('Starting processing', 'PROCESS_DATASTREAM', $this->pid, $dsid);
     try {
         $output_file = $this->temp_file . '_HOCR';
         $command = "tesseract {$this->temp_file} {$output_file} -l {$language} -psm 1 hocr";
         exec($command, $hocr_output, $return);
         if (!file_exists($output_file . '.html')) {
             exec("convert -quality 99 " . $this->temp_file . " " . $this->temp_file . "_JPG2.jpg");
             $command = "tesseract " . $this->temp_file . "_JPG2.jpg " . $output_file . " -l {$language} -psm 1 hocr";
             exec($command, $hocr2_output, $return);
             if (!file_exists($output_file . '.html')) {
                 $this->log->lwrite("Could not create the {$dsid} derivative!", 'FAIL_DATASTREAM', $this->pid, $dsid, NULL, 'ERROR');
                 return $return;
             }
         }
         $hocr_datastream = new NewFedoraDatastream("HOCR", 'M', $this->object, $this->fedora_object->repository);
         $hocr_datastream->setContentFromFile($output_file . '.html');
         $hocr_datastream->label = 'HOCR';
         $hocr_datastream->mimetype = 'text/html';
         $hocr_datastream->state = 'A';
         $hocr_datastream->checksum = TRUE;
         $hocr_datastream->checksumType = 'MD5';
         $hocr_datastream->logMessage = "HOCR derivative created by tesseract v3.0.1 using command - {$command} || SUCCESS";
         $this->object->ingestDatastream($hocr_datastream);
         $hocr_xml = new DOMDocument();
         $hocr_xml->load($output_file . '.html');
         $xsl = new DOMDocument();
         $xsl->load('hocr_to_lower.xslt');
         $proc = new XSLTProcessor();
         $proc->importStylesheet($xsl);
         $encoded_xml = $proc->transformToXml($hocr_xml);
         $encoded_xml = str_replace('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">', '<?xml version="1.0" encoding="UTF-8"?>', $encoded_xml);
         $encoded_datastream = new NewFedoraDatastream($dsid, 'M', $this->object, $this->fedora_object->repository);
         $encoded_datastream->setContentFromString($encoded_xml);
         $encoded_datastream->label = $label;
         $encoded_datastream->mimetype = 'text/xml';
         $encoded_datastream->state = 'A';
         $encoded_datastream->checksum = TRUE;
         $encoded_datastream->checksumType = 'MD5';
         $encoded_datastream->logMessage = "{$dsid} derivative created by tesseract v3.0.1 and transformed using hocr_to_lower.xslt || SUCCESS";
         $this->object->ingestDatastream($encoded_datastream);
         unlink($output_file . '.html');
         $this->log->lwrite('Finished processing', 'COMPLETE_DATASTREAM', $this->pid, $dsid);
     } catch (Exception $e) {
         $this->log->lwrite("Could not create the {$dsid} derivative!", 'FAIL_DATASTREAM', $this->pid, $dsid, NULL, 'ERROR');
         unlink($output_file . '.html');
     }
     return $return;
 }
Пример #29
0
        }
        return $sqlStatement;
    }
}
/**
 * This will combine the XML and the XSL
 * or generate the HTML, Text
 */
$rg = new ReportGenerator();
$rg->setRequest($_REQUEST);
$date = new DateTime();
$Stamp = $date->format('Ymd-His');
$xslt = new XSLTProcessor();
$xslt->registerPHPFunctions();
switch ($rg->format) {
    case 'html':
        header('Content-Type: application/xslt+xml');
        header('Content-Disposition: inline; filename=' . strtolower($rg->reportDir) . '-' . $Stamp . '".html"');
        $xslt->importStylesheet(new SimpleXMLElement($rg->getXSLTemplate()));
        echo $xslt->transformToXml(new SimpleXMLElement($rg->getXMLDocument()));
        break;
    case 'pdf':
        require_once '../../../lib/html2pdf_v4.03/html2pdf.class.php';
        $xslt->importStylesheet(new SimpleXMLElement($rg->getXSLTemplate()));
        $html2pdf = new HTML2PDF('P', 'A4', 'en');
        $html2pdf->pdf->SetAuthor('GaiaEHR');
        $html2pdf->WriteHTML($xslt->transformToXml(new SimpleXMLElement($rg->getXMLDocument())));
        $PDFDocument = base64_encode($html2pdf->Output(strtolower($rg->reportDir) . '-' . $Stamp . '.pdf', "S"));
        echo '<object data="data:application/pdf;base64,' . $PDFDocument . '" type="application/pdf" width="100%" height="100%"></object>';
        break;
}
 /**
  * @param \SimpleXMLElement|\DOMDocument|string $xml
  * @param \SimpleXMLElement|\DOMDocument|string $xslt
  * @param array $params
  * @return string
  */
 private function xsltTransformation($xml, $xslt, $params = array())
 {
     $xsltPreprocessor = new \XSLTProcessor();
     if (is_string($xml)) {
         $xml = simplexml_load_string($xml);
     }
     if (is_string($xslt)) {
         $xslt = simplexml_load_string($xslt);
     }
     $xsltPreprocessor->importStylesheet($xslt);
     //region parameters
     if (!empty($params)) {
         foreach ($params as $name => $value) {
             $value = str_replace('$basePath', $this->basePath, $value);
             $value = str_replace('$lang', $this->language, $value);
             $xsltPreprocessor->setParameter('', $name, $value);
         }
     }
     //endregion parameters
     return $xsltPreprocessor->transformToXml($xml);
 }