Hey All,
I'm trying to use xslt_process() but can't seem to use absolute paths to my XML & XSL files. I'm getting my XML off of a different server than what my PHP script lives on, so I need to be able to specify an absolute path.
Thanks,
Brent
xslt_process()
Moderator: General Moderators
...
Try something like that:
And than:
This should work ... ?
Code: Select all
$fpXSLT = fopen( $strURLGetXSLT, "r" );
$strXSLTContent = fread( $fpXSLT, 600000 );
fclose( $fpXSLT );Code: Select all
$arrayArgumentsї'/_xml'] = $strXMLContent; // You can do the same with XML file as XSLT (fopen, fread, ...)
$arrayArgumentsї'/_xsl'] = $strXSLTContent;
$strHTML = &xslt_process( $parserXSLT, "arg:/_xml", "arg:/_xsl", NULL, $arrayArguments );-
brentwatson
- Forum Newbie
- Posts: 4
- Joined: Tue Dec 10, 2002 11:17 am
More complicated now....
Well, my problem just got more complicated now :S
Now I need to add an attribute to my XML documents root then pass it into xslt_process.
the set up of my document is as such:
<xdocument>
<xpage>
<xbody>
etc., etc.
</xbody>
</xpage>
</xdocument>
I need to add an attribute called "formAction" to xdocument before applying the transformation [xslt_process()].
Thanks for all the help!
Brent Watson
Now I need to add an attribute to my XML documents root then pass it into xslt_process.
the set up of my document is as such:
<xdocument>
<xpage>
<xbody>
etc., etc.
</xbody>
</xpage>
</xdocument>
I need to add an attribute called "formAction" to xdocument before applying the transformation [xslt_process()].
Thanks for all the help!
Brent Watson
-
brentwatson
- Forum Newbie
- Posts: 4
- Joined: Tue Dec 10, 2002 11:17 am
A tad more info
A bit of extra info:
I've successfully added an attribute to the root like so:
$XMLAttribFile = domxml_open_file("sample.xml");
$root = $XMLAttribFile->root();
$root->set_attribute("formAction", "testTESTtest");
Now inorder to use the XML file in xslt_process I need to somehow turn my XML Dom file ($XMLAttribFile) into a string....then we should be home-free....
Anyone know how I could turn this object into a string??!!
Thanks once again,
Brent Watson
I've successfully added an attribute to the root like so:
$XMLAttribFile = domxml_open_file("sample.xml");
$root = $XMLAttribFile->root();
$root->set_attribute("formAction", "testTESTtest");
Now inorder to use the XML file in xslt_process I need to somehow turn my XML Dom file ($XMLAttribFile) into a string....then we should be home-free....
Anyone know how I could turn this object into a string??!!
Thanks once again,
Brent Watson
...
Perhaps this will work:
http://www.php.net/manual/en/function.d ... mp-mem.php
http://www.php.net/manual/en/function.d ... mp-mem.php
-
brentwatson
- Forum Newbie
- Posts: 4
- Joined: Tue Dec 10, 2002 11:17 am
Got it working! :)....
Got it working
I used dump_mem() to pass the object into a string...
Here is my code incase someone else comes across the same sort of problem:
Also, remeber to do a xslt_set_base($xh,"file://C:/your_xsl_dir/"); before your xslt_process() if you have <xsl:include>'s in your XSL.
Thanks for all the help!!
Brent Watson
I used dump_mem() to pass the object into a string...
Here is my code incase someone else comes across the same sort of problem:
Code: Select all
$XMLFile = "http:\\path_to_xml";
$XSLFile = "http:\\path_to_xsl";
$XMLAttribFile = domxml_open_file($XMLFile);
$root = $XMLAttribFile->root();
$root->set_attribute("formAction", "myTestAttribute");
$fpXSLT = fopen($XSLFile, "r");
$strXSLTContent = fread($fpXSLT, 6000000);
fclose( $fpXSLT );
$strXMLContent=$XMLAttribFile->dump_mem(true);
$arrayArgumentsї'/_xml'] = $strXMLContent;
$arrayArgumentsї'/_xsl'] = $strXSLTContent;
$xh = xslt_create();
$result = xslt_process($xh,"arg:/_xml", "arg:/_xsl", NULL, $arrayArguments);
if ($result)
print $result;
else
{
print " Error: " . xslt_error($xh) .
print " Error code " . xslt_errno($xh);
}
xslt_free($xh);Thanks for all the help!!
Brent Watson