Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing a variable to an xsl template

Status
Not open for further replies.

hame22

Programmer
Apr 25, 2005
9
GB
Hi, i am looking to pass a variable from a php page into an xsl stylesheet

i have found some code but it does not seem to work.

stylesheet:

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"
xmlns:xsl="<xsl:eek:utput method="html"/>
<xsl:template match="/">
<html>
<head><title>test</title></head>
<body>
<h2>Activity</h2>
<xsl:param name="myvar"/>

<xsl:for-each select ="Lom/general">
<h3> Activity Name: <p><B> <xsl:value-of select="title"/></B></p></h3>
<p>Description:</p><p><xsl:value-of select="description"/></p>
</xsl:for-each>


<xsl:for-each select="Lom/technical">

<p>Activity format: <xsl:value-of select="format"/></p>
</xsl:for-each>
<xsl:for-each select="Lom/technical/location">
<a href="{@link}">


<p>Click to access</p>
</a>


</xsl:for-each>
My PHP variable : <h3><xsl:value-of select="$myvar"/></h3><br />

</body>
</html>
</xsl:template></xsl:stylesheet>


php page

<?php
// Gonna contain PHP-XML output


$xh = xslt_create();

$p_id = 'cia01';


// Read plain PHP-XML output
//$xmlData = file_get_contents (' "r");

$c = curl_init('curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$xml = curl_exec($c);

// Stack up output into one String
//while ($line = fgets ($xmlData))
//$xml .= $line;
//print $xml;

$arguments = array(
'/_xml' => $xml,
);


$parameters = array (
'myvar' => 'test'
);

// Process the document
$result = xslt_process($xh, 'arg:/_xml', 'xml2.xsl', NULL, $arguments, $parameters);

// Print out your transformed document
echo $result;

xslt_free($xh);

?>

would appreciate any ideas or help

thanks in advance

alex
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top