facebook/hhvm — pull request #1700 by aloiret (2014-02-03 11:54:38+00:00)
Title: Implement XSL extension

Hello,

I am currently working on implementing the XSL extension in HHVM. The current pull request is a WIP, with notably the following items left to do:
- allow SimpleXMLElement objects for importStylesheet.
- allow Node arguments to registered PHP functions.
- allow multiple parameters for setParameter.
- implement setSecurityPrefs/getSecurityPrefs.
- consider namespaceURI for parameters.
- add EXSLT support.

Beside that, the current implementation seems to be working smoothly. I tested it one some "production" code, and on an improved version of the very classical "collection.xsl" example (as found on PHP website), using HHVM in server mode and Apache Benchmark:

$ cat collection.xml

Fight for your mind

Ben Harper
1995

Electric Ladyland

Jimi Hendrix
1997

$ cat collection.xsl

Hey! Welcome to 's sweet CD collection!

by -

$ cat test.php
load("collection.xsl");
$xmlDoc = new DOMDocument();
$xmlDoc->load("collection.xml");
$proc = new XSLTProcessor();
$proc->importStylesheet($xslDoc);
$proc->setParameter("", "owner", "Nicolas Eliaszewicz");
$proc->registerPHPfunctions('rawurlencode');
echo $proc->transformToXML($xmlDoc);
echo $proc->transformToDoc($xmlDoc)->saveXML();
$proc->transformToURI($xmlDoc, 'file:///dev/stdout');
?>

$ hhvm -m server -p 8000 -vEval.Jit=true
$ ab -n 10000 -c 200 http://127.0.0.1:8000/test.php
[...]
Concurrency Level: 200
Time taken for tests: 6.379 seconds
Complete requests: 10000
Failed requests: 0
[...]

I plan to complete the implementation, including the to do items listed above. In the meantime, would you mind comment on my code? I am new to both HHVM and C++.

Thank you for the awesome software HHVM is!

Signed-off-by: Arthur Loiret