Project

Profile

Help

Support #2175

A problem with pre-compiled php_saxon.dll in WAMP environment

Added by Dmitry Kruglov almost 6 years ago. Updated almost 6 years ago.

Status:
New
Priority:
Normal
Category:
PHP API
Start date:
2014-10-10
Due date:
% Done:

0%

Estimated time:
Found in version:
0.3.1

Description

Hi

I downloaded and installed Saxon-HEC http://www.saxonica.com/saxon-c/libsaxon-HEC-setup-v0.3.1.exe for Windows and used pre-compiled php_saxon.dll for PHP 5.4.x

I have freshly installed x86 WAMP 2.4 with PHP 5.4.33

This is my test code:

<?php
$xml = 'trax\xml\foo.xml';
$xsl = 'trax\xsl\foo.xsl';
if(file_exists($xml)) echo "XML file {$xml} is OK; ";
if(file_exists($xml)) echo "XSL file {$xsl} is OK; ";
@$proc = new SaxonProcessor();
$proc->setSourceFile($xml);
$proc->setStylesheetFile($xsl);
$result = $proc->transformToString();                          
var_dump($result);

This is my output:

XML file trax\xml\foo.xml is OK; XSL file trax\xsl\foo.xsl is OK; 
( ! ) Warning: C:\wamp\bin\apache\Apache2.4.4 in C:\wamp\www\sax\test.php on line 6
object(SaxonProcessor)[1]
null

First, instantiation of SaxonProcessor class always throws a weird Warning message, however the object is created.

Apache log:

[Fri Oct 10 16:59:30.703287 2014] [:error] [pid 7472:tid 1532] [client 127.0.0.1:53302] PHP Warning:  C:\\wamp\\bin\\apache\\Apache2.4.4 in C:\\wamp\\www\\sax\\test.php on line 6
[Fri Oct 10 16:59:30.703287 2014] [:error] [pid 7472:tid 1532] [client 127.0.0.1:53302] PHP Stack trace:
[Fri Oct 10 16:59:30.703287 2014] [:error] [pid 7472:tid 1532] [client 127.0.0.1:53302] PHP   1. {main}() C:\\wamp\\www\\sax\\test.php:0
[Fri Oct 10 16:59:30.703287 2014] [:error] [pid 7472:tid 1532] [client 127.0.0.1:53302] PHP   2. SaxonProcessor->__construct() C:\\wamp\\www\\sax\\test.php:6

Second, it always prepends working directory of Apache (not the webroot) to the files' path which makes it hard to feed source files to the methods. Also, it makes it impossible to set files on a different drive. This is what happens when just a relative path to xsl file is given:

Error 
  I/O error reported by XML parser processing
  C:\wamp\bin\apache\Apache2.4.4/trax\xsl\foo.xsl: The system cannot find the path specified
Exception in thread "main" net.sf.saxon.s9api.SaxonApiException: Failed to compile stylesheet. 1 error detected.
	at net.sf.saxon.option.cpp.XsltProcessorForCpp.xsltApplyStylesheet(Unknown Source)
Caused by: net.sf.saxon.trans.XPathException: Failed to compile stylesheet. 1 error detected.
	... 1 more

History

#1 Updated by O'Neil Delpratt almost 6 years ago

Hi, On windows the working directory does not seem to work in the same way as on linux. This is an outstanding bug issue which is still pending.

As a workaround you can pass a working directory as an argument to the Processor object. See below:

$proc = new SaxonProcessor("C:/www");

#2 Updated by Dmitry Kruglov almost 6 years ago

Thanks O'Neil,

Everything works great.

I should have read this page http://www.saxonica.com/saxon-c/index.xml properly:

On Windows we recommend setting the cwd using the overloaded constructor because there remains an issue with building Saxon/C with PHP when using the function VCWD_GETCWD. Example: i.e. $proc = new SaxonProcessor('C://www/html//trax//');

Though it is still worth mentioning that constructor may accept an argument in here: http://www.saxonica.com/saxon-c/php_api.xml

#3 Updated by O'Neil Delpratt almost 6 years ago

Yes, I will mention it in the API documentation shortly. Although this work around is temporary that is probably why I did not add it before.

Please register to edit this issue

Also available in: Atom PDF