Re: XSLT - Problem passing variables with PHP 4.2 => Solved !
| From: | Ignatius Reilly | Date: | Sun, 18 Aug 2002 07:22:16 +0000 |
| Subject: | Re: XSLT - Problem passing variables with PHP 4.2 => Solved ! | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-15333@lists.php.net to get a copy of this message | ||
Bonjour,
Thanks Sebastian, you put me in the right direction.
I turns out that the newest XSLT API will NOT pass the parameters array when xslt_process() uses
URIs for the XML source and the XSL sheet, like it used to with the previous versions
"xslt_run()". One must use arguments for the XML and XSL content.
In other words:
$xslt_args = array( '/_xml' => $xml, '/_xsl' => $xsl ) ;
$result = xslt_process( $xh, 'arg:/_xml', 'arg:/_xsl', NULL, $xslt_args,
$xslt_params ) ==> good
$xslt_args = array() ;
$result = xslt_process( $xh, 'xml_content.xml', 'xsl_sheet.xsl', NULL,
$xslt_args, $xslt_params ) ==> bad
(the transformation works correctly, but parameters are not passed)
Fortunately it did not prove necessary to turn register_globals ON.
Ignatius Reilly
--------------------------------------------------------------------------------
----- Original Message -----
From: Ignatius Reilly
To: sablist@gingerall.cz
Sent: Saturday, August 17, 2002 6:10 PM
Subject: Re: [Sab] Problem passing variables with PHP 4.2
Thanks Mattes,
That's in fact what I am doing. My script is conform to the documentation. However, my
<xsl:value-of select="{$VAR_NAME}" /> fills empty string values for the variable.
The really strange thing here is that it used to work with PHP 4.0, but not any more.
Could it be a variable scoping problem? Anything to do with register_globals = off (in php.ini) ?
I am really puzzled
------------------------------------------------------------------------------
----- Original Message -----
From: Matthes
To: sablist@gingerall.cz
Sent: Saturday, August 17, 2002 7:35 PM
Subject: Re: [Sab] Problem passing variables with PHP 4.2
You can call your vars simply by defining <xsl:param name="lang" /> at
the top of your script (after xsl headers but before templates
definitions - see php online documentation, there's some comment
about this) and then access them in your xsl script by calling them
like <xsl:value-of select="{$VAR_NAME}" /> or so.
try this:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:param name="lang" />
...
<xsl:value-of select="$lang" />
...
it should work ;)
Matthes
IR> Hi,
IR> Since upgrading from PHP 4.0 to 4.2, I do not manage any longer to pass parameters from
IR> the PHP script. The XSLT transformations is performed allright, though, and use empty values for the
IR> parameters defined.
IR> I tried to kludge by passing parameters in the form of string arguments:
IR> $xslt_args["lang"] = "<a>French</a>" ;
IR> and <xsl:param name="lang"
IR> select="document('arg:/lang0')/a"/>
IR> ... but here again I get a 'arg:/lang' not found error
IR> I use Apache 1.3.14 on a W2K machine
IR> Anybody has encountered the same problem?
IR> Ignatius
IR> ------------------------------------------------------------------------
IR> Archives and info:
IR> http://www.gingerall.org/charlie/ga/xml/m_ml.xml
IR> Mailing list maintained by Ginger Alliance
------------------------------------------------------------------------
Archives and info: http://www.gingerall.org/charlie/ga/xml/m_ml.xml
Mailing list maintained by Ginger Alliance