note 46928 added to function.xsl-xsltprocessor-get-parameter

From: Date: Wed, 27 Oct 2004 22:41:29 +0000
Subject: note 46928 added to function.xsl-xsltprocessor-get-parameter
Groups: php.notes 
Request: Send a blank email to php-notes+get-79219@lists.php.net to get a copy of this message
Here is an example of getParameter(), setParameter() and removeParameter() <?php # enable all warnings ini_set('error_reporting', E_ALL | E_STRICT); # a simple xsl template as a string $xsl_str = <<<EOT <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:param name="version" >3</xsl:param> </xsl:stylesheet> EOT; # load the XSL template into a DOM document $xsl = new DomDocument; $xsl->loadXML( $xsl_str ); # create a new processor object $proc = new xsltprocessor; # this shows the new proc is empty and reading an empty param is not a PHP Warning echo "Step 1: " . $proc->getParameter("","version") . "\n"; # import the Style Sheet in to the processor $proc->importStyleSheet($xsl); # unable to read param "version" from proc with default name space echo "Step 2: " . $proc->getParameter("","version") . "\n"; # unable to read param "version" from proc with specified name space echo "Step 3: " . $proc->getParameter("http://www.w3.org/1999/XSL/Transform" ,"version") . "\n"; # set param "version" $proc->setParameter("","version", 2); # read back param "version" echo "Step 4: " . $proc->getParameter("","version") . "\n"; # remove param "version" $proc->removeParameter("","version"); # attempt to read removed param "version" echo "Step 5: " . $proc->getParameter("","version") . "\n"; ?> Run it and you get these results with PHP 5.0.2: # php tmp.php Step 1: Step 2: Step 3: Step 4: 2 Step 5: Looks like if you want to read a parameter from an XSL template you need to get it from the DOM object and not the xlstprocessor object. ---- Manual Page -- http://www.php.net/manual/en/function.xsl-xsltprocessor-get-parameter.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46928 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46928&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46928&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46928&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46928&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46928&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46928&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+46928&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#79219) next »