Xalan via Java Extension
| From: | Florian Clever | Date: | Thu, 21 Sep 2000 13:58:36 +0000 |
| Subject: | Xalan via Java Extension | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-2770@lists.php.net to get a copy of this message | ||
Hi,
I am trying to transform a XML Document with a XSL Stylesheet using
Xalan via PHP's Java extension:
I am basically using the Java class SimpleTransform from
Apache.org/Xalan:
public class SimpleTransform
{
public static void Transform( FileInputStream xmlInStream,
FileInputStream xlsInStream, FileOutputStream xmlOutStream)
throws java.io.IOException, java.net.MalformedURLException,
org.xml.sax.SAXException
{
// Have the XSLTProcessorFactory obtain a interface to a
// new XSLTProcessor object.
XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
// Have the XSLTProcessor processor object transform "foo.xml" to
// System.out, using the XSLT instructions found in "foo.xsl".
processor.process(new XSLTInputSource(xmlInStream),
new XSLTInputSource(xlsInStream),
new XSLTResultTarget(xmlOutStream));
}
}
Now in PHP I call:
$java_xmlInStream = new Java("java.io.FileInputStream", "c:\\foo.xml");
$java_xslInStream = new Java("java.io.FileInputStream", "c:\\foo.xsl");
$java_xmlOutStream = new Java("java.io.FileOutputStream",
"c:\\bar.xml");
$java_simpletransform = new Java("SimpleTransform");
$java_simpletransform->Transform($java_xmlInStream, $java_xslInStream,
$java_xmlOutStream);
$java_xmlOutStream->Close(); // PHP crashes here
And PHP crashes when closing the Outputstream. If I do not close the
Outputstream the file gets written, but without content.
If I pass "c:\\bar.xml" to XSLTResultTarget instead of xmlOutStream the
file is not even created.
Plattform: WinNT 4, SP6a, PWS 4, PHP 4.0.2 from php4win
It would be so cool if PHP could like that transform XML with XSL, so
any hints would be great.
Thanks,
Florian
--
Florian Clever
fc@clever-soft.com
http://www.Clever-Software-Solutions.de/
PGP Key @ ldap://certserver.pgp.net/
24 hours in a day, 24 beers in a case. Coincidence?