eawade 0 Newbie Poster

Hello Everyone,

I have an issue that is driving me crazy. I have a xml document and associated stylesheet. I simply want to be able to 1: declare a top level variable 2. Pass a variable value from the URL to the stylesheet so that, for example, if http://someurl.com/index.php?id=3 - the information for the 3rd ID is displayed. Below i have sample code but i can't seem to get this to work with Php 5. Does anyone have a clue as to what is going on. After spending about a week looking through the documents for Php5 and XML, I am totally confused. Note: I am looking for the simplest / most direct solution.

Thanks,

<?php

// XML string
$xml = '<?xml version="1.0"?>
<para>
 change me
</para>';

// XSL string
$xsl = '
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="ISO-8859-1" indent="no"
 omit-xml-declaration="yes"  media-type="text/html"/>
 <xsl:param name="myvar"/>
 <xsl:param name="mynode"/>
 <xsl:template match="/">
My PHP variable : <xsl:value-of select="$myvar"/><br />
My node set : <xsl:value-of select="$mynode"/>
 </xsl:template>
</xsl:stylesheet>';

$xh = xslt_create();

// the second parameter will be interpreted as a string
$parameters = array (
  'myvar' => 'test',
  'mynode' => '<foo>bar</foo>'
);

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

echo xslt_process($xh, 'arg:/_xml', 'arg:/_xsl',NULL, $arguments, $parameters);

?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.