note 46893 added to function.xsl-xsltprocessor-register-php-functions

From: Date: Wed, 27 Oct 2004 08:48:59 +0000
Subject: note 46893 added to function.xsl-xsltprocessor-register-php-functions
Groups: php.notes 
Request: Send a blank email to php-notes+get-79161@lists.php.net to get a copy of this message
One thing I have told a lot of people to do if they are having issues with this function is to check for any 'xmlns' attributes that get generated and added to your xml pages by some types of popular software. <?php $file = "http://data.map***.net/m***ck.asmx/GetMessages?IMEI=$id"; $docxml = file_get_contents($file); //You may have to do something like this where //I remove any instance of xmlns tags that get //returned by my ASP.NET SOAP responses. $docxml = str_replace("xmlns=\"http://data.map***.net/m***ck.asmx?WSDL\"", "",$docxml); $xslt = new xsltProcessor; //You don't remove them then this function will blow up. $xslt->registerPHPFunctions(); $xslt->importStyleSheet(DomDocument::load('../xsl/message.xsl')); print $xslt->transformToXML(DomDocument::loadXML($docxml)); ?> Also a few cool tricks with this function is that you can call built in PHP functions. For example: <xsl:value-of select="php:function('nl2br',string(MessageContent/Message))" disable-output-escaping="yes"/> That XSL value will now return your normal string but replace all your new line charactors in your xml with '<br />'s. Also note the 'disable-output-escaping="yes"' statement. If you don't call this, then the output of that bind will be ran thru basicly a "htmlencode()" type function. Last but not least, take a look at the 'string()' function I called in XSL before passing it back. That is because without calling that, when it runs it will try and pass the node object, and not its value (which is what you most likely only want). This function is very awsome and could lead to some very interesting code development. Skins could be loaded remotely. You could write an RSS viewer in PHP without much code. You could parse XHTML pages into another view (either localy or remotely). Then you can take that same XML content and throw it against ASP.NET, Java, or even a command line processing tool using that same exact XSL style sheet and generate the front ends for you page without much change. I'm very excited. Happy codding. ---- Manual Page -- http://www.php.net/manual/en/function.xsl-xsltprocessor-register-php-functions.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46893 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46893&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46893&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46893&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46893&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46893&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46893&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+46893&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#79161) next »