function parse_server_status_XML($xml_) { if (!$xml_ || strlen($xml_) == 0) { return false; } $dom = new DomDocument('1.0', 'utf-8'); $buf = @$dom->loadXML($xml_); if (!$buf) { return false; } if (!$dom->hasChildNodes()) { return false; } $node = $dom->getElementsByTagname('server')->item(0); if (is_null($node)) { return false; } if (!$node->hasAttribute('name')) { return false; } if (!$node->hasAttribute('status')) { return false; } return array('name' => $node->getAttribute('name'), 'status' => $node->getAttribute('status')); }
/** * @param string|null $data * @param bool $formatOutput * * @throws \Exception */ public function __construct($data = null, $formatOutput = false) { $this->dom = new \DomDocument('1.0', 'UTF-8'); $this->dom->preserveWhiteSpace = false; $this->dom->formatOutput = $formatOutput; $this->dom->substituteEntities = false; if (!$data) { $data = '<x:xmpmeta xmlns:x="adobe:ns:meta/" />'; } // load xml $this->dom->loadXML($data); $this->dom->encoding = 'UTF-8'; if ('x:xmpmeta' !== $this->dom->documentElement->nodeName) { throw new \RuntimeException('Root node must be of type x:xmpmeta.'); } // set up xpath $this->xpath = new \DOMXPath($this->dom); foreach ($this->namespaces as $prefix => $url) { $this->xpath->registerNamespace($prefix, $url); } // try and find an rdf:about attribute, and set it as the default if found $about = $this->xpath->query('//rdf:Description/@rdf:about')->item(0); if ($about) { $this->about = $about->nodeValue; } }
/** * Construct the response object. * * @param OneLogin_Saml_Settings $settings Settings containing the necessary X.509 certificate to decode the XML. * @param string $assertion A UUEncoded SAML assertion from the IdP. */ public function __construct(OneLogin_Saml_Settings $settings, $assertion) { $this->_settings = $settings; $this->assertion = base64_decode($assertion); $this->document = new DOMDocument(); $this->document->loadXML($this->assertion); }
/** * Construct the response object. * * @param string $saml_response A UUEncoded SAML response from the IdP. */ public function __construct($saml_response, $settings = null) { if ($settings == null) { $settings = Maestrano::sso()->getSamlSettings(); } $this->_settings = $settings; $this->assertion = base64_decode($saml_response); $this->document = new DOMDocument(); $this->document->loadXML($this->assertion); }
/** * @param {@link ViewElement} $viewElement * @param integer $arity * @param array $arguments */ public function evaluate(ViewElementTag $viewElement, $arity, $arguments) { $xmlString = $arguments[0]; $xml = new \DomDocument(); $successParse = @$xml->loadXML($xmlString, LIBXML_NOENT); if (!$successParse) { $explicitRoot = $arity >= 2 ? $arguments[1] : 'xml'; $xmlString = '<' . $explicitRoot . '>' . $arguments[0] . '</' . $explicitRoot . '>'; // This time we let a warning be fired in case of invalid xml. $xml->loadXML($xmlString, LIBXML_NOENT); } $xpath = new \DOMXPath($xml); return $xpath; }
function get_document($aNode) { //get the directory in which the documents are contained from the config.php file global $xml_dir, $html_dir, $xslt, $html_xslt; //create the xslt $xp = new XsltProcessor(); // create a DOM document and load the XSL stylesheet $xsl = new DomDocument(); $xsl->load($xslt); // import the XSL styelsheet into the XSLT process $xp->importStylesheet($xsl); //open the xml document $xml = new DomDocument(); $xml->loadXML($aNode); //transform if ($html = $xp->transformToXML($xml)) { $return = str_replace('<?xml version="1.0"?>' . "\n", "", $html); $return = str_replace('<!DOCTYPE div PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' . "\n", "", $return); $return = str_replace("\n", "", $return); $return = str_replace("\n ", "", $return); return str_replace("\t", "", $return); } else { trigger_error('XSL transformation failed.', E_USER_ERROR); } }
function getAttachment($inMessage) { $cid2stringMap = $inMessage->attachments; $cid2contentMap = $inMessage->cid2contentType; $imageName; foreach ($cid2stringMap as $i => $value) { $f = $cid2stringMap[$i]; $contentType = $cid2contentMap[$i]; if (strcmp($contentType, "image/jpeg") == 0) { $imageName = $i . "." . "jpg"; if (stristr(PHP_OS, 'WIN')) { file_put_contents($imageName, $f); } else { file_put_contents("/tmp/" . $imageName, $f); } } } $arraysize = count($cid2contentMap); if ($arraysize == 0) { $dom = new DomDocument(); $dom->loadXML($inMessage->str); $images = $dom->documentElement->getElementsByTagName('image'); $image = $images->item(0); if (stristr(PHP_OS, 'WIN')) { file_put_contents("base64image.txt", $image->nodeValue); } else { file_put_contents("/tmp/base64image.txt", $image->nodeValue); } } $resPayload = <<<XML <ns1:response xmlns:ns1="http://wso2.org/wsfphp/samples/mtom">Image Saved</ns1:response> XML; $returnMessage = new WSMessage($resPayload); return $returnMessage; }
/** * 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; }
function xslt_process(&$proc, $xml_var, $xslt_var, $dummy, $args, $params, $a_no_warnings = false) { $xslt = $proc->myProc; //echo htmlentities($args[substr($xslt_var, 4)]); $xslt_domdoc = new DomDocument(); $xslt_domdoc->loadXML($args[substr($xslt_var, 4)]); $xslt->importStyleSheet($xslt_domdoc); if (is_array($params)) { foreach ($params as $key => $value) { $xslt->setParameter("", $key, $value); } } // supress warnings all the time. (some lib xslt bring warnings due to & in links) //if ($a_no_warnings) //{ $xml_domdoc = new DomDocument(); $xml_domdoc->loadXML($args[substr($xml_var, 4)]); // show warnings again due to discussion in #12866 $result = $xslt->transformToXML($xml_domdoc); //} //else //{ // $result = $xslt->transformToXML(DomDocument::loadXML($args[substr($xml_var, 4)])); //} //echo "<br><br><b>xslt_process</b>".htmlentities($result); return $result; }
/** * Logs into Windows Live * * @return true on success else error */ public function login() { // Register device $register = $this->registerDevice(); // Get binary DA token $response = $this->getBinaryDAToken($this->messageid, $this->deviceUserName, $this->devicePassword); $responsedom = new DomDocument(); $responsedom->loadXML($response); $cipherValues = $responsedom->getElementsbyTagName("CipherValue"); $this->cipherValue = $cipherValues->item(0)->textContent; if (!empty($this->cipherValue)) { // Get security tokens $response = $this->getSecurityTokens($this->cipherValue); $responsedom = new DomDocument(); $responsedom->loadXML($response); $cipherValues = $responsedom->getElementsbyTagName("CipherValue"); $this->securityToken0 = $cipherValues->item(0)->textContent; $this->securityToken1 = $cipherValues->item(1)->textContent; $this->keyIdentifier = $responsedom->getElementsbyTagName("KeyIdentifier")->item(0)->textContent; if (empty($this->keyIdentifier) || empty($this->securityToken0) || empty($this->securityToken1)) { $this->_error = "Failed to get security tokens."; } else { return true; } } else { $this->_error = "Failed to get binary DA token."; } }
function __construct($url, $response, $browser) { $this->url = $url; $this->html = $response; $this->parseResponse($response); $this->is_xml = isset($this->headers['Content-Type']) && preg_match('/\\bxml\\b/i', $this->headers['Content-Type']) ? true : false; $this->browser = $browser; $this->dom = new DOMDocument(); if ($this->is_xml) { @$this->dom->loadXML($this->html); } else { @$this->dom->loadHTML($this->html); } $this->xpath = new DOMXPath($this->dom); $this->title = ($node = $this->xpath->query('//title')->item(0)) ? $node->nodeValue : ''; $this->forms = array(); foreach ($this->xpath->query('//form') as $form) { $this->_forms[] = new PGForm($form, $this); } if ($browser->convertUrls) { $this->convertUrls(); } $this->setParser($this->html, $this->is_xml); if (function_exists('gc_collect_cycles')) { gc_collect_cycles(); } }
public static function create_from_server_report($server_id_, $xml_input_) { $server = Abstract_Server::load($server_id_); if ($server === false) { return; } $external_name = $server->getExternalName(); $dom = new DomDocument('1.0', 'utf-8'); $dom->loadXML($xml_input_); if (!is_object($dom)) { return null; } $node = $dom->getElementsByTagName('cpu'); if ($node->length > 0) { $cpu = round($node->item(0)->getAttribute('load'), 2); } else { $cpu = -1; } $node = $dom->getElementsByTagName('ram'); if ($node->length > 0) { $total = (double) $server->ram_total; $used = (double) $node->item(0)->getAttribute('used'); if ($total > 0) { $ram = round($used / $total * 100, 2); } else { $ram = 0; } } else { $ram = -1; } $sessions = $dom->getElementsByTagName('session'); $apps_link = application_desktops_to_ids(); $sessions_infos = array(); $applications_infos = array(); /* the interesting <session> nodes of the xml are like: <session id="ID" mode="MODE" status="STATUS" user="******"> <instance application="APP_ID" id="ApS_ID"/> </session> */ foreach ($sessions as $session) { $sessid = $session->getAttribute('id'); $sessions_infos[$sessid] = $session->getAttribute('user'); foreach ($session->childNodes as $instance_node) { if ($instance_node->tagName == 'instance') { $desktop = $instance_node->getAttribute('application'); if (!array_key_exists($desktop, $apps_link)) { continue; } $id = $apps_link[$desktop]; if (!array_key_exists($id, $applications_infos)) { $applications_infos[$id] = array(); } $applications_infos[$id][] = $sessid; } } } $data = self::infos2Xml($sessions_infos, $applications_infos); $report = new self(time(), $server_id_, $server->fqdn, $external_name, $cpu, $ram, $data); return $report; }
function upcoming_events() { header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true); $xml = new DomDocument(); $xml->loadXML($this->get_upcoming_events()); echo $xml->saveXML(); }
function format($xml) { $dom = new DomDocument(); $dom->loadXML($xml); $dom->formatOutput = true; return $dom->saveXML(); }
public function testUpdateOnLicenceChange() { $document = $this->createTestDocument(); $document->store(); $documentCacheTable = new Opus_Db_DocumentXmlCache(); $docXmlCache = $documentCacheTable->find($document->getId(), '1')->current()->xml_data; $domDoc = new DomDocument(); $domDoc->loadXML($docXmlCache); $licences = $domDoc->getElementsByTagName('Licence'); $this->assertTrue($licences->length == 0, 'Expected no Licence element in dom.'); $licence = new Opus_Licence(); $licence->setNameLong('TestLicence'); $licence->setLinkLicence('http://example.org/licence'); $licenceId = $licence->store(); $document->setServerState('published'); $document->setLicence($licence); $docId = $document->store(); $licence = new Opus_Licence($licenceId); $licence->setNameLong('TestLicenceAltered'); $licence->store(); $docXmlCacheResult = $documentCacheTable->find($document->getId(), '1'); $this->assertTrue($docXmlCacheResult->count() == 0, 'Expected empty document xml cache'); $this->executeScript('cron-update-document-cache.php'); $docXmlCacheAfter = $documentCacheTable->find($docId, '1')->current()->xml_data; $domDocAfter = new DomDocument(); $domDocAfter->loadXML($docXmlCacheAfter); $licencesAfter = $domDocAfter->getElementsByTagName('Licence'); $this->assertTrue($licencesAfter->length == 1, 'Expected one Licence element in dom.'); $licences = $document->getLicence(); $licences[0]->delete(); }
/** * Metainformation catalogue * -------------------------------------------------- * * Lib_XML for MicKa * * @link http://www.bnhelp.cz * @package Micka * @category Metadata * @version 20121206 * */ function applyTemplate($xmlSource, $xsltemplate) { $rs = FALSE; if (File_Exists(CSW_XSL . '/' . $xsltemplate)) { if (!extension_loaded("xsl")) { if (substr(PHP_OS, 0, 3) == "WIN") { dl("php_xsl.dll"); } else { dl("php_xsl.so"); } } $xp = new XsltProcessor(); $xml = new DomDocument(); $xsl = new DomDocument(); $xml->loadXML($xmlSource); $xsl->load(CSW_XSL . '/' . $xsltemplate); $xp->importStyleSheet($xsl); //$xp->setParameter("","lang",$lang); $xp->setParameter("", "user", $_SESSION['u']); $rs = $xp->transformToXml($xml); } if ($rs === FALSE) { setMickaLog('applyTemplate === FALSE', 'ERROR', 'micka_lib_xml.php'); } return $rs; }
function areXmlSame($xmlString1, $xmlString2) { $document1 = new DomDocument(); $document2 = new DomDocument(); $document1->loadXML($xmlString1); $document2->loadXML($xmlString2); $allNodes1 = $document1->getElementsByTagName("*"); $allNodes2 = $document2->getElementsByTagName("*"); $length1 = $allNodes1->length; $length2 = $allNodes2->length; if ($length1 != $length2) { return false; } for ($i = 0; $i < $length1; $i++) { $node1 = $allNodes1->item($i); $node2 = $allNodes2->item($i); if (!compareAttributes($node1, $node2)) { return false; } if ($node1->nodeName != $node2->nodeName) { return false; } } return true; }
protected function assertMatchesXpath($html, $expression, $count = 1) { $dom = new \DomDocument('UTF-8'); try { // Wrap in <root> node so we can load HTML with multiple tags at // the top level $dom->loadXML('<root>'.$html.'</root>'); } catch (\Exception $e) { $this->fail(sprintf( "Failed loading HTML:\n\n%s\n\nError: %s", $html, $e->getMessage() )); } $xpath = new \DOMXPath($dom); $nodeList = $xpath->evaluate('/root'.$expression); if ($nodeList->length != $count) { $dom->formatOutput = true; $this->fail(sprintf( "Failed asserting that \n\n%s\n\nmatches exactly %s. Matches %s in \n\n%s", $expression, $count == 1 ? 'once' : $count.' times', $nodeList->length == 1 ? 'once' : $nodeList->length.' times', // strip away <root> and </root> substr($dom->saveHTML(), 6, -8) )); } }
/** * 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; }
/** * @return Dto_MediaInformation|void */ public function retrieveInfo() { $mediaInfo = new Dto_MediaInformation(); $mediaInfo->setValid(false); /* * Create URL to retrive info from, for this provider * we only support direct id lookups for now */ $url = 'http://services.tvrage.com/feeds/showinfo.php?sid=' . $this->getSearchid() . '/'; list($http_code, $tvrage) = $this->_httpProvider->performCachedGet($url, false, 31 * 24 * 60 * 60); if (empty($tvrage)) { return $mediaInfo; } # if # fetch remote content $dom = new DomDocument(); $dom->preserveWhiteSpace = false; $dom->loadXML($tvrage); $showTitle = $dom->getElementsByTagName('showname'); /* * TV rage doesn't returns an 404 or something alike when the content is * not found, so we try to mimic this ourselves. */ # TVRage geeft geen 404 indien niet gevonden, dus vangen we dat zelf netjes op if (!@$showTitle->item(0)->nodeValue) { return $mediaInfo; } # if /* * Get the actual episode title */ $mediaInfo->setTitle($showTitle->item(0)->nodeValue); $mediaInfo->setValid(true); return $mediaInfo; }
private function getDomObject() { if ($this->_verbose > 2) { $this->log('IN:[' . __FUNCTION__ . ']', 0, "purple"); } if ($this->_verbose > 1) { $this->log("Content length: " . strlen($this->_content), 0, "light_purple"); } $DOM = new \DomDocument(); switch ($this->_domType) { case "xml": if ($this->_verbose > 2) { $this->log('<' . __LINE__ . '> DOMDocument->loadXML', 0, "purple"); } @$DOM->loadXML($this->_content); break; case "html": if ($this->_verbose > 2) { $this->log('<' . __LINE__ . '> DOMDocument->loadXML'); } @$DOM->loadHtml($this->_content); break; default: throw new \Exception("Unknwon DOM type used to load content \"" . $this->_domType . "\""); break; } return $DOM; }
function execute($requestXml) { $this->init(); if (is_string($requestXml)) { $dom = new DomDocument(); $dom->preserveWhiteSpace = FALSE; if ($dom->loadXML($xml)) { $requestXml = $dom->firstChild; } } //is_string() $this->warnings = array(); if (is_object($requestXml) && get_class($requestXml) == "DOMElement") { $action = $requestXml->getAttribute('action'); $this->requestNo = $requestXml->getAttribute('no'); $this->reset(); $this->requestXml = $requestXml->ownerDocument->saveXML($requestXml); foreach ($requestXml->attributes as $attr) { $this->params[$attr->name] = $attr->value; } //debug($this->params); if (method_exists($this, $action)) { $this->content = $this->{$action}(); return $this->responseData(); } else { return $this->invalidRequest($requestXml, 405); } } else { return $this->invalidRequest($requestXml); } }
public function fillInXml($xml, $formName, $formId, $values) { $dom = new DomDocument('1.0', sfConfig::get('sf_charset', 'UTF-8')); @$dom->loadXML($xml); $dom = $this->fillInDom($dom, $formName, $formId, $values); return $dom->saveXML(); }
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 getAttachment($inMessage) { $cid2stringMap = $inMessage->attachments; $cid2contentMap = $inMessage->cid2contentType; $imageName; $arraysize = count($cid2contentMap); if ($arraysize == 0) { $dom = new DomDocument(); $dom->loadXML($inMessage->str); $images = $dom->documentElement->getElementsByTagName('image'); $image = $images->item(0); if (stristr(PHP_OS, 'WIN')) { file_put_contents("base64image.txt", $image->nodeValue); $str = base64_decode($image->nodeValue); file_put_contents("decoded_image.jpg", $str); } else { file_put_contents("/tmp/base64image.txt", $image->nodeValue); $str = base64_decode($image->nodeValue); file_put_contents("/tmp/decoded_image.jpg", $str); } } $responsePayload = <<<XML <ns1:response xmlns:ns1="http://php.axis2.org/samples/mtom">Image Saved</ns1:response> XML; $returnMessage = new WSMessage($responsePayload); return $returnMessage; }
public function get_login() { $buf = $this->prefs->get('AuthMethod', 'Token'); $token_url = $buf['url']; $user_node_name = $buf['user_node_name']; $login_attribute_name = $buf['login_attribute_name']; if (!isset($token_url) or $token_url == '') { Logger::error('main', 'Token URL is not defined'); return NULL; } if (!isset($_REQUEST['token'])) { Logger::warning('main', 'Missing parameter : token'); return NULL; } $token_url = str_replace('%TOKEN%', $_REQUEST['token'], $token_url); $xml = query_url($token_url); $dom = new DomDocument('1.0', 'utf-8'); $ret = @$dom->loadXML($xml); if (!$ret) { Logger::error('main', 'Token webservice does not send a valid XML'); return NULL; } $user_node = $dom->getElementsByTagname($user_node_name)->item(0); if (!is_object($user_node)) { Logger::error('main', 'Token webservice does not send a valid XML'); return NULL; } if (!$user_node->hasAttribute($login_attribute_name)) { Logger::error('main', 'Token webservice does not send a valid XML'); return NULL; } $this->login = $user_node->getAttribute($login_attribute_name); return $this->login; }
function parse_session_status_XML($xml_) { if (!$xml_ || strlen($xml_) == 0) { return false; } $dom = new DomDocument('1.0', 'utf-8'); $buf = @$dom->loadXML($xml_); if (!$buf) { return false; } if (!$dom->hasChildNodes()) { return false; } $node = $dom->getElementsByTagname('session')->item(0); if (is_null($node)) { return false; } if (!$node->hasAttribute('id')) { return false; } if (!$node->hasAttribute('status')) { return false; } $ret = array('id' => $node->getAttribute('id'), 'server' => $_SERVER['REMOTE_ADDR'], 'status' => $node->getAttribute('status'), 'reason' => NULL, 'role' => NULL); if ($node->hasAttribute('reason')) { $ret['reason'] = $node->getAttribute('reason'); } if ($node->hasAttribute('role')) { $ret['role'] = $node->getAttribute('role'); } return $ret; }
public function call_success() { global $USER, $COURSE, $CFG; if (empty($this->_xmlresponse)) { if (is_siteadmin($USER->id)) { notice(get_string('adminemptyxml', 'adobeconnect'), $CFG->wwwroot . '/admin/settings.php?section=modsettingadobeconnect'); } else { notice(get_string('emptyxml', 'adobeconnect'), '', $COURSE); } } $dom = new DomDocument(); $dom->loadXML($this->_xmlresponse); $domnodelist = $dom->getElementsByTagName('status'); if ($domnodelist->item(0)->hasAttributes()) { $domnode = $domnodelist->item(0)->attributes->getNamedItem('code'); if (!is_null($domnode)) { if (0 == strcmp('ok', $domnode->nodeValue)) { return true; } else { return false; } } else { return false; } } else { return false; } }
function xslt_process($xsltproc, $xml_arg, $xsl_arg, $xslcontainer = null, $args = null, $params = null) { // Start with preparing the arguments $xml_arg = str_replace('arg:', '', $xml_arg); $xsl_arg = str_replace('arg:', '', $xsl_arg); // Create instances of the DomDocument class $xml = new DomDocument(); $xsl = new DomDocument(); $phpversion = explode('.', PHP_VERSION); $phpversionid = $phpversion[0] * 10000 + $phpversion[1] * 100 + $phpversion[2]; // Load the xml document and the xsl template if ($phpversionid >= 50302 && LIBXML_VERSION >= 20700) { $xmlOptions = LIBXML_PARSEHUGE; } else { $xmlOptions = 0; } $xml->loadXML($args[$xml_arg], $xmlOptions); $xsl->loadXML(file_get_contents($xsl_arg), $xmlOptions); // Load the xsl template $xsltproc->importStyleSheet($xsl); // Set parameters when defined if ($params) { foreach ($params as $param => $value) { $xsltproc->setParameter("", $param, $value); } } // Start the transformation $processed = $xsltproc->transformToXML($xml); // Put the result in a file when specified if ($xslcontainer) { return @file_put_contents($xslcontainer, $processed); } else { return $processed; } }
function __doRequest($request, $location, $action, $version) { $dom = new DomDocument('1.0', 'UTF-8'); $dom->preserveWhiteSpace = false; $dom->loadXML($request); $hdr = $dom->createElement('soapenv:Header'); $secNode = $dom->createElement("wsse:Security"); $secNode->setAttribute("soapenv:mustUnderstand", "1"); $secNode->setAttribute("xmlns:wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"); $usernameTokenNode = $dom->createElement("wsse:UsernameToken"); $usernameTokenNode->setAttribute("wsu:Id", "UsernameToken-1"); $usernameTokenNode->setAttribute("xmlns:wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"); $usrNode = $dom->createElement("wsse:Username"); $usrNode->appendChild($dom->createTextNode(WS_USER)); $pwdNode = $dom->createElement("wsse:Password"); $pwdNode->setAttribute("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"); $pwdNode->appendchild($dom->createTextnode(WS_PWD)); $usernameTokenNode->appendChild($usrNode); $usernameTokenNode->appendChild($pwdNode); $secNode->appendChild($usernameTokenNode); $hdr->appendChild($secNode); $dom->documentElement->insertBefore($hdr, $dom->documentElement->firstChild); $request = $dom->saveXML(); $request = str_replace("SOAP-ENV", "soapenv", $request); $request = str_replace("ns1", "cgt", $request); $request = str_replace('<?xml version="1.0" encoding="UTF-8"?>', '', $request); // echo "Este es el nuevo XML: " . print_r($request, true); return parent::__doRequest($request, $location, $action, $version); }