xslt_process functionality question

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
drazhar
Forum Newbie
Posts: 3
Joined: Tue Mar 02, 2004 4:30 pm

xslt_process functionality question

Post 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;
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
drazhar
Forum Newbie
Posts: 3
Joined: Tue Mar 02, 2004 4:30 pm

Post 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?
drazhar
Forum Newbie
Posts: 3
Joined: Tue Mar 02, 2004 4:30 pm

Post 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)
Post Reply