Hi,

below is my second attempt to pass variables to
sablotron with PHP:

http://www.php.net/manual/en/function.xslt-run.php
says:
"[...] the processor is started with xslt_args"
how to do that?

doesn't work:

$xslt_params["chosen_first_name"] = 'Mister';
$xslt_params["chosen_last_name"] = 'Test';

$xml_file = "all-bup.xml";
$xsl_file = "contacts.xslt";

$fd = fopen ($xml_file, "r");
$xml = fread ($fd, filesize ($xml_file));
fclose ($fd);

$fd = fopen ($xsl_file, "r");
$xsl = fread ($fd, filesize ($xsl_file));
fclose ($fd);

$processor = xslt_create();
xslt_run ($processor, $xsl, $xml, $xslt_params);

$result = xslt_fetch_result ($processor);
echo ($result);


Tobi

--- Tobias Reif <[EMAIL PROTECTED]> wrote:
> 
> Antti and Bernhard,
> 
> thank you both very much for your help!
> 
> But I still can't get it to work; in the the code
> below 
> I tried to include all of your suggestions:
> 
> $xslt_params["chosen_first_name"] = 'Mister';
> $xslt_params["chosen_last_name"] = 'Test';
> $xml_file =
> 'file://f:/programs/apache/htdocs/all-bup.xml';
> $xsl_file =
> 'file://f:/programs/apache/htdocs/contacts.xslt';
> $xml_handle = fopen($xml_file, "r") or die("Can't
> open
> XML file!");
> $xsl_handle = fopen($xsl_file, "r") or die("Can't
> open
> XSL file!");
> $xml_content = fread($xml_handle,
> filesize($xml_file));
> $xsl_content = fread($xsl_handle,
> filesize($xsl_file));
> $processor = xslt_create();
> xslt_run($processor, $xsl_content, $xml_content,
> "arg:/_result", $xslt_params);
> $result = xslt_fetch_result ($processor);
> xslt_free($processor);
> echo $result;
> 
> Does the above code work for you?
> Do I need to open the files in a different way if I
> specify the absolute path to it?
> 
> Tobi
> 
> 
> > I figured it out. This works:
> > 
> > $processor = xslt_create();
> > xslt_run ($processor, $xsl_file, $xml_file,
> > "arg:/_result",
> > $xslt_params);
> > $result = xslt_fetch_result ($processor);
> > xslt_free ($processor);
> > echo $result;
> 

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

Reply via email to