Page 1 of 1

xslt_process functionality question

Posted: Tue Mar 02, 2004 4:30 pm
by drazhar
heres the deal. Im using XSL to add/modify/remove data from an XML file. So far it works nicely, but heres the problem. when using the xslt_process function, i cant specify the same source and destination file.

So far i have been renaming the newly created file, after deleting the original. I dont like doing it that way, is there a way i can do it with the xslt_process function. Dont recommend DOM or SAX, i hate them. Anyway, XSLT is the way to go, much easier to use. :wink:

Thanks for any time you spend on this

here is an example of the way if doing the XSLT Processing

Code: Select all

$xslt = xslt_create();

if (!$res = @xslt_process($xslt, $sourceXML, $sourceXSL, $destXML)) 
{ 
print ("Error: <b>" . xslt_error($xslt) . "</b><br/>" . "Code: <b>" . xslt_errno($xslt) . "</b>");
&#125;

xslt_free($xslt);
print $res;

Posted: Wed Mar 03, 2004 3:56 am
by twigletmac
Maybe send the resulting XML to a variable and then copy that data over the existing file? Check out example 3 on the [php_man]xslt_process[/php_man]() info page.

Mac

Posted: Wed Mar 03, 2004 4:47 am
by drazhar
hmmm, got a feeling that ive already tried this, but i'll give it another shot. tanx for the quick response, any other ideas?

Posted: Mon Mar 15, 2004 9:56 am
by drazhar
i sorted this out by the way, twig was correct

instead of specifying the destination file here
xslt_process($xslt, $sourceXML, $sourceXSL, $destXML)

leave it at NULL, and write the result to the file.

ie: $result=xslt_process($xslt, $sourceXML, $sourceXSL, NULL)