Unable to transformToXML()
Status: Abandoned
Brought to you by:
boen_robot
Hello,
I am attempting to use your package and am having some trouble. I have validated that the importStyleSheet() function is loading by outputting it's result... I assume the '1' is true, or successful. However, I can't get the transformToXML() function to return anything at all. Any ideas?
<?php
include "/usr/share/pear/XML/XSLT2Processor.php";
?>
<html>
<head>
<title>Test</title>
</head>
<? print(Date("l F d, Y")); ?>
<p>
<p>
<?
$doc = new DOMDocument();
$xslt2 = new XML_XSLT2Processor();
$doc->load("IntuitectProjectToExcelXml.xsl");
echo $xslt2->importStyleSheet($doc); //attach xsl rules
$doc->load("IntuitectProjectModel.xml");
echo $xslt2->transformToXML($doc);
?>
<body>
</body>
</html>
Logged In: YES
user_id=1582968
Originator: NO
Hello, and thanks for trying out XML_XSLT2Processor.
If you're not outputting anything, it's likely that there is an error during the transformation. Also, I'm not sure, but I believe function names are case sencetive, meaning you should use importStylesheet() instead of importStyleSheet().
Replace
echo $xslt2->transformToXML($doc);
with
===
if ($transform = $xslt2->transformToXML($doc)) {
echo $transform;
}else {
echo "There is an error during the transformation.";
}
===
If then you see the error message instead of an empty output, it's certain the fault is in your XSLT/XML (either that, or you have discovered a serious bug in XML_XSLT2Processor). In that case, please show the XML and XSLT files, so we could see where in them the error is. If you're not comfortable with sharing them, and/or believe they are OK, try to self debug this by using the XML_XSLT2Processor::getErrors() function or the "command" property to ensure you're initiating SAXON right. Perhaps like:
if ($transform = $xslt2->transformToXML($doc)) {
echo $transform;
}else {
echo "The command XML_XSLT2Processor tryed to run on the command line was:\n" . $xslt2->command;
echo "The message from the last error was:\n" . $xslt2->getErrors(-1)->message;
}
===
Logged In: YES
user_id=1582968
Originator: NO
Oh, and judging by your sample, you're using Linux (or another *nix OS), aren't you?
If so, I suppose you're using the JAVA version of SAXON, since this is the only thing that runs on this OS. The .NET version works only on Windows, and so is AltovaXML.
In that case, you need to explicitly say in the constructor that you're using a *.jar file, by using the JAVA-CLI interface of SAXON like:
$xslt2 = new XML_XSLT2Processor('SAXON',null,'JAVA-CLI');
Which assumes saxon.jar (note the missing major version number) is available from the path in the SAXON_HOME or PATH environmental variables. Explicitly stating the path as well would be best.
Either way, you must be very close if you didn't had an Exception thrown from the constructor.
Logged In: YES
user_id=1582968
Originator: NO
It turns out you were using the XML_XSLT2Processor defaults, which are just not usable under UNIX. You need to explicitly point the path to the SAXON jar.
In 0.5.0, you could take the SAXON from the PATH. However, you still need to specify the processor and interface like
XML_XSLT2Processor('SAXON', null, 'JAVA-CLI');
I'm closing this issue now. If you're still experiencing problems even with 0.5.0, please reopen this entry.