I was able to pass parameters to the xsl stylesheet like this:
<?php
$args = array();
$params["test"] = "parameter_to_pass";
// create XSLT processor
$xh = xslt_create();
// call xslt processor
// Process the document
$result = xslt_process($xh, $xmlfile, $xslfile, NULL, $args, $params);
if ($result) {
print $result;
}
else {
print "Sorry, the xml could not be transformed by the xsl into";
print " the \$result variable the reason is that " . xslt_error($xh)
.
print " and the error code is " . xslt_errno($xh);
}
xslt_free($xh);
?>
Then in the stylesheet do this (The parameter must be defined before any
template is declared):
<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:param name="test" />
<xsl:template match="/">
<html>
<head>
<title>Your html page</title>
</head>
<body bgcolor="#FFFFFF">
<xsl:value-of select="$test"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
This will print "parameter_to_pass" to the browser
On Tue, 2002-09-24 at 22:33, [EMAIL PROTECTED] wrote:
>
> I'm wondering if there is a way to include a query string parameter in an xsl
> stylesheet.
>
> I have a script that does this:
>
> xslt_process($xsltprocessor,$xml,$xsl);
>
> I'd like to include the value of a variable passed to this script via a query
> string (eg. xmlscript.php?p=3 ), whereby the value '3' is passed to the xsl
> stylesheet somehow. The xsl stylesheet should then only process section 3 of the
> xml document.
>
> I've played about with extra arguments to xslt_process and <xsl:param name="p"/>
> to no avail.
>
> Hope this is clear enough.
>
> TIA
>
> Mick
>
> ----------------------------------------------------
> MICHAEL HALL Web Development Officer
> Batchelor Institute of Indigenous Tertiary Education
> W: [EMAIL PROTECTED] (08) 8951 8352
> H: [EMAIL PROTECTED] (08) 8953 1442
> ----------------------------------------------------
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php