function getXMLSing($xmlHon,$priv_key){ //Carga Certificado $xml = new DomDocument(); $xml->loadXML($xmlHon); //Carga prosedimiento de proceso de cadena original $xsl = new DomDocument; $xsl->load("ostring.xsl"); $proc = new xsltprocessor(); $proc->importStyleSheet($xsl); $original =$proc->transformToXML($xml); //firma la cadena original //$fp = $cert[0]['certificates']['key']; //$priv_key = $f['key']; //die($f['key']); //fclose($fp); $pkeyid = openssl_get_privatekey($priv_key); openssl_sign($original, $signature, $pkeyid,OPENSSL_ALGO_MD5); openssl_free_key($pkeyid); //coloca el sello en xml $esqueletonew=$xmlHon; $esqueletonew=str_replace("#1#",base64_encode($signature),$esqueletonew); $xmlReturn[1]=$esqueletonew; $xmlReturn[2]=$original; $xmlReturn[3]=base64_encode($signature); return $xmlReturn; }
function render($controller_name, $layout_template = false) { parent::parse($controller_name, $layout_template); $xsl = new DomDocument(); $xsl->load($this->template); $proc = new xsltprocessor(); $proc->importStyleSheet($xsl); echo $proc->transformToXML($this->props_to_xml()); }
/** * render the product finder using an XSL stylesheet * * @access public * @param string xsl stylesheet * @return string result of the transformation */ public function render($xsl = null) { if (is_string($xsl)) { $xsl = DomDocument::loadXML($xsl); } $proc = new xsltprocessor(); $proc->importStyleSheet($xsl); return $proc->transformToXML($this->dom); }
private function _xsltProcess($sVml, $sXslFilePath) { $oProcessor = new xsltprocessor(); $oXml = new DomDocument(); $oXml->loadXML($sVml); $oXsl = new DomDocument(); $oXsl->load($sXslFilePath); $oProcessor->importStyleSheet($oXsl); return $oProcessor->transformToXML($oXml); }
protected function renderXSLT($response, $template) { if ($template == '') { throw new Exception(JText::_('COM_AAWS_TEMPLATE_DOES_NOT_EXIST')); } $type = strtolower(substr(get_class($this), strlen('AawsController'))); $path = JPATH_COMPONENT . DS . 'xslt' . DS . $type . DS . $template . '.xslt'; if (!JFile::exists($path)) { throw new Exception(JText::_('COM_AAWS_TEMPLATE_DOES_NOT_EXIST')); } $xml = new DOMDocument(); $xml->loadXML($response); $xsl = new DOMDocument(); $xsl->load($path); $proc = new xsltprocessor(); $proc->importStyleSheet($xsl); $proc->setParameter('', 'language', 'es-ES'); if (method_exists($this, '_setVariablesTo')) { $this->_setVariablesTo($proc, $template); } echo $proc->transformToXML($xml); }
chmod($dirname . "/img/bar.gif", 0777); } } // ******************* PROVEDENI XSL TRANSFORMACE HLAVNI STRANKA ******************************** // naètení dokumentu XML $xml = new DomDocument(); $xml->load($fname); // naètení stylu XSLT dle vybraneho jazyka $xsl = new DomDocument(); if ('czech' == $_SESSION['step_all_1']['language']) { $xsl->load("./xml/xslt/blog_cz.xsl"); } else { $xsl->load("./xml/xslt/blog_en.xsl"); } // vytvoøení procesoru XSLT $proc = new xsltprocessor(); $proc->registerPhpFunctions(); $proc->importStylesheet($xsl); // provedení transformace a vypsání výsledku $newdom = $proc->transformToDoc($xml); $newdom->save($dirname . "/" . $_SESSION['step_all_4']['presentation_name'] . ".php"); deleteXmlHeading($dirname . "/" . $_SESSION['step_all_4']['presentation_name'] . ".php"); chmod($dirname . "/" . $_SESSION['step_all_4']['presentation_name'] . ".php", 0744); // ***************** ZJISTI URL VYSLEDNE STRANKY **************************************************** $url = getUrl($_SESSION['step_all_2']['user_name'], $_SESSION['step_all_4']['presentation_name'], $fname); $_SESSION['step_blog_8']['page_url'] = $url; ?> <form action="<?php echo $_SERVER['REQUEST_URI']; ?>
<?php print "Test 11: php:function Support\n"; class foo { function __construct() { } function __toString() { return "not a DomNode object"; } } $dom = new domDocument(); $dom->load(dirname(__FILE__) . "/xslt011.xsl"); $proc = new xsltprocessor(); $xsl = $proc->importStylesheet($dom); $xml = new DomDocument(); $xml->load(dirname(__FILE__) . "/xslt011.xml"); $proc->registerPHPFunctions(); print $proc->transformToXml($xml); function foobar($id, $secondArg = "") { if (is_array($id)) { return $id[0]->value . " - " . $secondArg; } else { return $id . " - " . $secondArg; } } function nodeSet($id = null) {
<?php $xslDom = new domdocument(); $xslDom->load('rss.xsl'); $xmlDom = new domdocument(); $xmlDom->load('data.rss'); $xsl = new xsltprocessor(); $xsl->importStylesheet($xslDom); print $xsl->transformToXML($xmlDom);
[expect php] [file] <?php require 'Phalanger.inc'; echo "Test 10: EXSLT Support"; $dom = new domDocument(); $dom->load(dirname(__FILE__) . "/exslt.xsl"); $proc = new xsltprocessor(); $xsl = $proc->importStylesheet($dom); $xml = new DomDocument(); $xml->load(dirname(__FILE__) . "/exslt.xml"); print __xml_norm($proc->transformToXml($xml));
</item> <item date="3247283732"> <caption>Testing...</caption> <content> <![CDATA[ dies ist ein zweiter test... ]]> </content> </item> </news>'; $xsl2str = '<xsl:stylesheet version = "1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <xsl:template match="content"> <b><xsl:value-of select="." /></b> </xsl:template> '; $xml = new DomDocument(); $xml->loadxml($xmlstr); $xsl = new DomDocument(); $xsl->load("test1.xsl"); $xsl2 = new DomDocument(); $xsl2->load("test1-2.xsl"); $proc = new xsltprocessor(); $proc->importStyleSheet($xsl2); $proc->importStyleSheet($xsl); echo $proc->transformToXML($xml); echo '<br><br>'; printf("%s<br>Count: %d", md5("29o3_DEFAULT_THEME"), strlen(md5("test")));
[expect php] [file] <?php require 'Phalanger.inc'; echo "Test 12: Using Associative Array of Parameters"; $dom = new domDocument(); $dom->load(dirname(__FILE__) . "/xslt.xml"); if (!$dom) { echo "Error while parsing the document\n"; exit; } $xsl = new domDocument(); $xsl->load(dirname(__FILE__) . "/xslt012.xsl"); if (!$xsl) { echo "Error while parsing the document\n"; exit; } $proc = new xsltprocessor(); if ($proc === false) { echo "Error while making xsltprocessor object\n"; exit; } $proc->importStylesheet($xsl); $parameters = array('foo' => 'barbar', 'foo1' => 'test'); $proc->setParameter("", $parameters); print "\n"; print __xml_norm($proc->transformToXml($dom)); print "\n";
$fp = fopen($file, "r"); $return = fread($fp, filesize($file)); fclose($fp); echo $return;*/ $xmlfilename = $toolchain_name; $xsltfilename = "config.xsl"; $xml = new DomDocument(); $xml->load($xmlfilename); ## Tag renaming $mapping = array('target_options' => 'Target Options', 'target_arch' => 'Target Architecture', 'target_variant' => 'Target Variant', 'abi' => 'ABI', 'float' => 'FPU', 'endiannes' => 'Endianness', 'toolchain_options' => 'Toolchain Options', 'build_shared_lib' => 'Build Shared Libraries', 'manufacturer' => 'Manufacturer', 'sysroot' => 'Sysroot', 'os' => 'Operating System', 'target_os' => 'Type', 'kernel_version' => 'Kernel Version', 'gmp_mpfr' => 'GMP-MPFR', 'use_gmp_mpfr' => 'Build GMP-MPFR', 'gmp_version' => 'GMP Version', 'mpfr_version' => 'MPFR Version', 'debug' => 'Debugging', 'gdb' => 'GDB', 'duma' => 'Duma', 'dmalloc' => 'Dmalloc', 'ltrace' => 'Ltrace', 'strace' => 'Strace', 'clib' => 'C Library', 'libc' => 'LIBC', 'clib_version' => 'Version', 'threading_lib' => 'Thread Model', 'cc' => 'C Compiler', 'gcc_version' => 'GCC Version', 'cpp' => 'CPP', 'fortran' => 'FORTRAN', 'java' => 'JAVA', 'binutils' => 'Binutils', 'libbfd' => 'Libbfd', 'libiberty' => 'Libiberty', 'binutils_version' => 'Version', 'tools' => 'Tools', 'libelf' => 'Libelf', 'sstrip' => 'Sstrip'); foreach ($mapping as $key => $value) { foreach ($xml->getElementsByTagName($key) as $node) { $node->setAttribute("name", $value); } } $xsl = new DomDocument(); $xsl->load($xsltfilename); $proc = new xsltprocessor(); $proc->importStyleSheet($xsl); $result = $proc->transformToXML($xml); ?> <DIV> <H2>Configuration de la chaîne :<BR /><?php echo $_GET['toolchain']; ?> </H2> <?php print "{$result}"; return; ?> </DIV>
$type = $doc->createElement("type"); $type = $content->appendChild($type); $htext = $doc->createTextNode($list['type']); $htext = $type->appendChild($htext); //create date $date = $doc->createElement("date"); $date = $content->appendChild($date); $htext = $doc->createTextNode($list['date']); $htext = $date->appendChild($htext); } //write to the file $filename = "xml/sitemap.xml"; $doc->save($filename); if ($_GET['sortby']) { $sortingrule = $_GET['sortby']; } else { $sortingrule = "headline"; } /* NOW WE CAN GET BUSY! */ $xml = new DomDocument(); // from /ext/dom $xml->load('xml/sitemap.xml'); $xsl = new DomDocument(); $xsl->load('xslt/sitemap.xsl'); /* Configure the transformer */ $proc = new xsltprocessor(); $proc->importStyleSheet($xsl); // attach the xsl rules $proc->setParameter("", "SORT", "{$sortingrule}"); echo $proc->transformToXML($xml); // actual transformation
/** * Render the page - this is ran automaticly * * @return Boolean */ public function render() { /** * Must be a logged in user with admin role to access the admin pages */ $user = User::instance(); if ((!$user->logged_in() || !array_intersect($user->get_role(), User::get_roles())) && $this->request->controller() != 'login') { $this->redirect('admin/login'); } if ($this->transform === TRUE || $this->transform === FALSE || $this->transform == 'auto') { $this->dom->insertBefore($this->dom->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="' . $this->xslt_path . $this->xslt_stylesheet . '.xsl"'), $this->xml); // If the stylesheet name includes an additional path, we need to extract it $extra_xslt_path = ''; $extra_path_parts = explode('/', $this->xslt_stylesheet); foreach ($extra_path_parts as $nr => $extra_path_part) { if ($nr < count($extra_path_parts) - 1) { $extra_xslt_path .= $extra_path_part . '/'; } } // See if we have a user agent that triggers the server side HTML generation $user_agent_trigger = FALSE; foreach (Kohana::$config->load('xslt.user_agents') as $user_agent) { if (strpos($_SERVER['HTTP_USER_AGENT'], $user_agent)) { $user_agent_trigger = TRUE; } } if ($this->transform === TRUE || $this->transform == 'auto' && $user_agent_trigger == TRUE) { $xslt = new DOMDocument(); if (file_exists(getenv('DOCUMENT_ROOT') . $this->xslt_path . $this->xslt_stylesheet . '.xsl')) { // If the stylesheet exists in the specified path, load it directly $xslt->load(getenv('DOCUMENT_ROOT') . $this->xslt_path . $this->xslt_stylesheet . '.xsl'); } else { // Else make a search for it // We need to load all theme modules foreach (scandir(MODPATH) as $modulePath) { if (substr($modulePath, 0, 5) == 'theme') { Kohana::modules(array($modulePath => MODPATH . $modulePath) + Kohana::modules()); } } $xslt->load(Kohana::find_file(rtrim(preg_replace('/^' . str_replace('/', '\\/', Kohana::$base_url) . '/', '', $this->xslt_path), '/'), $this->xslt_stylesheet, 'xsl')); } // We need to update paths to included XSL elements $XPath = new DOMXPath($xslt); $include_nodes = $XPath->query('//xsl:include'); foreach ($include_nodes as $include_node) { foreach ($include_node->attributes as $attribute_node) { $new_filename = Kohana::find_file(rtrim(preg_replace('/^' . str_replace('/', '\\/', Kohana::$base_url) . '/', '', $this->xslt_path . $extra_xslt_path), '/'), substr($attribute_node->nodeValue, 0, strlen($attribute_node->nodeValue) - 4), 'xsl'); $include_node->removeAttribute('href'); $include_node->setAttribute('href', $new_filename); } } // Done updating paths $proc = new xsltprocessor(); $proc->importStyleSheet($xslt); echo $proc->transformToXML($this->dom); } else { $this->response->headers('Content-Type', 'application/xml; encoding=' . Kohana::$charset . ';'); echo $this->dom->saveXML(); } } elseif ($this->transform == 'XML') { $this->response->headers('Content-Type', 'application/xml; encoding=' . Kohana::$charset . ';'); echo $this->dom->saveXML(); } elseif ($this->transform == 'JSON') { $this->response->headers('Content-type: application/json; encoding=' . Kohana::$charset . ';'); echo json_encode(new SimpleXMLElement($this->dom->saveXML(), LIBXML_NOCDATA)); } return TRUE; }
/** * Renders the xsl object to a string. Global and local data are merged * and extracted to create local variables within the xsl file. * * $output = $xsl->render(); * * [!!] Global variables with the same key name as local variables will be * overwritten by the local variable. * * @param string xsl filename * @return string * @throws Kohana_Exception */ public function render($file = NULL) { if ($file !== NULL) { $this->set_filename($file); } if (empty($this->_file)) { throw new Kohana_Exception('You must set the file to use within your xsl before rendering'); } if (Xslt::$_global_data) { // Import the global xsl variables to local namespace and maintain references $this->_data = array_merge(Xslt::$_global_data, $this->_data); } // Create the XML DOM $this->_dom = new DomDocument('1.0', 'UTF-8'); $this->_dom->preserveWhiteSpace = FALSE; $this->_dom->formatOutput = TRUE; // echo $this->array2xml( $this->_data ); $this->_dom->loadXML($this->array2xml($this->_data)); // Link the xml and xsl $this->_dom->insertBefore($this->_dom->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="' . $this->_file . '"')); // Load the xsl $xslt = new DOMDocument(); $doc = array("content" => Xslt::capture($this->_file), "pattern" => "/<!DOCTYPE (.*) PUBLIC \"(.*)\" \"(.*)\">/i", "match" => array(), "method" => "xml", "public" => "", "system" => ""); preg_match($doc["pattern"], $doc["content"], $match); if (!empty($match)) { $doc["content"] = preg_replace($doc["pattern"], "", $doc["content"]); $doc["match"] = $match; $doc["method"] = $doc["match"][1]; $doc["public"] = "doctype-public=\"" . $doc["match"][2] . "\""; $doc["system"] = "doctype-system=\"" . $doc["match"][3] . "\""; } $doc["content"] = $this->get_includes($doc["content"]); $xslt->loadXML("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\t\t\t<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n\t\t\t<xsl:output\n\t\t\t\tmethod=\"xml\"\n\t\t\t\tencoding=\"" . Kohana::$charset . "\"\n\t\t\t\tomit-xml-declaration=\"no\"\n\t\t\t\t" . $doc["public"] . "\n\t\t\t\t" . $doc["system"] . "\n\t\t\t\tindent=\"no\"\n\t\t\t\t/>\n\n\t\t\t<xsl:template match=\"/root\">" . $doc["content"] . "</xsl:template></xsl:stylesheet>"); // Process XSLT $proc = new xsltprocessor(); $proc->importStyleSheet($xslt); // Return HTML $return_html = $proc->transformToDoc($this->_dom)->saveXML(); $return_html = html_entity_decode($return_html); return str_replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n", "", $return_html); }
/** * Transforms the DB4 schema to a Propel one. */ function doConvertSchema() { // XML $xml = new DomDocument(); $xml->loadXML(file_get_contents($this->file_path)); // DB4 xsl $db4_transformation_file = dirname(__FILE__) . '/../vendor/db2/dbd2propel.xsl'; $xsl = new DomDocument(); $xsl->load($db4_transformation_file); // Attach the xsl rules $proc = new xsltprocessor(); $proc->importStyleSheet($xsl); $xmlstr = $proc->transformToXML($xml); // Automatised i18n $i18nlist = array(); preg_match_all('#\\<table name=\\"(.+)_i18n\\"#', $xmlstr, $i18nlist); if (is_array($i18nlist) && isset($i18nlist[1]) && is_array($i18nlist[1])) { foreach ($i18nlist[1] as $tableName) { $xmlstr = str_replace('<table name="' . $tableName . '"', '<table name="' . $tableName . '" isI18N="true" i18nTable="' . $tableName . '_i18n"', $xmlstr); } } // Others replacments $xmlstr = str_replace(array('name="culture"', 'package="lib.model"'), array('name="culture" isCulture="true"', sprintf('package="%s"', $this->package)), $xmlstr); // Delete external tables if (!empty($this->external_tables)) { $this->external_tables_array = explode(',', $this->external_tables); $this->log(' - Removing external tables'); foreach ($this->external_tables_array as $external_table) { $this->log(' > ' . $external_table); $reg_exp = '/(<table name="' . trim($external_table) . ')(((.)*(\\s)*)*?)(<\\/table>)/'; $xmlstr = preg_replace($reg_exp, '', $xmlstr); } } // Xml file save $this->xmlstr = $xmlstr; $this->output_path = sfConfig::get('sf_root_dir') . $this->output_dir . '/' . $this->output . '.xml'; }
function _generateRDF() { $model = new MemModel(); $model->setBaseURI($this->doclink); $proc = new xsltprocessor(); include_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_RDF; $pars = new RdfParser(); foreach ($this->stylelink as $key => $value) { $xsl = new DomDocument(); $xsl->load($value); $proc->importStyleSheet($xsl); $model->addModel($pars->generateModel($proc->transformToXML($this->domdoc), $this->doclink)); } return $model; }
public function transform($xslt_file) { $xslt = new domdocument(); $xml = new domdocument(); if (file_exists($xslt_file) == false) { return false; } else { if ($xslt->load($xslt_file) == false) { return false; } } if ($xml->loadxml($this->document) == false) { return false; } $processor = new xsltprocessor(); $processor->importstylesheet($xslt); foreach ($this->xslt_parameters as $key => $value) { $processor->setparameter("", $key, $value); } return $processor->transformtoxml($xml); }
<?php echo "Test 10: EXSLT Support"; $dom = new domDocument(); $dom->load(dirname(__FILE__) . "/exslt.xsl"); $proc = new xsltprocessor(); $xsl = $proc->importStylesheet($dom); $xml = new DomDocument(); $xml->load(dirname(__FILE__) . "/exslt.xml"); print $proc->transformToXml($xml);
public function applyTransform() { preg_match('#(</OTA_[^>]*>)#', $this->_response, $matches); $xmlString = explode($matches[1], $this->_response); $xmlString = $xmlString[0]; $xmlString .= $this->_getAdministrativeFeeXMLVersion(); $xmlString .= $matches[1]; $xml = new DOMDocument(); $xml->loadXML($xmlString); $path = JPATH_SITE . DS . 'plugins' . DS . 'amadeus' . DS . 'administrativefee' . DS . 'transform.xslt'; if (!JFile::exists($path)) { throw new Exception(JText::_('PLG_AAWS_TEMPLATE_DOES_NOT_EXIST')); } $xsl = new DOMDocument(); $xsl->load($path); $proc = new xsltprocessor(); $proc->importStyleSheet($xsl); $this->_response = substr($proc->transformToXML($xml), 22); return true; }