note 39285 deleted from function.xslt-process by sobak
| From: | sobak@php.net | Date: | Tue, 22 Nov 2016 03:34:12 +0000 |
| Subject: | note 39285 deleted from function.xslt-process by sobak | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-207365@lists.php.net to get a copy of this message | ||
Note Submitter: greg _at_ rhythmicdesign _dot_ com
----
Figuring out the syntax to get parameters in was difficult but this works for me:
// Allows user to pass argument from URL as script.php?foo=VALUE
$xml = file_get_contents ('n.xml') ;
$xsl = file_get_contents ('n.xsl') ;
// Perform the transformation
$args = array (
'/_xml' => $xml,
'/_xsl' => $xsl
);
$params = array (
'foo' => $foo
) ;
$html = xslt_process($xsltproc, 'arg:/_xml', 'arg:/_xsl', NULL, $args,
$params);
then in the XSL FILE:
--------------------------
<xsl:param name="foo"/>
<xsl:template match="/">
<root>
<test><xsl:value-of select="$foo"/></test>
<xsl:apply-templates/></root>
</xsl:template>
Note: the param definition and the '$' dollar sign