File: demo.php

package info (click to toggle)
php-fxsl 1.1.1-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 236 kB
  • sloc: php: 350; xml: 177; sh: 12; makefile: 8
file content (44 lines) | stat: -rw-r--r-- 860 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php

use TheSeer\fXSL\fXSLCallback;
use TheSeer\fXSL\fXSLTProcessor;

require 'TheSeer/fXSL/fxslcallback.php';
require 'TheSeer/fXSL/fxsltprocessor.php';

function demo() {
   return 'Demo reply';
}

class foo {
   public function bar($a, $b) {
      $x = new \DOMDocument();
      $x->loadXML('<?xml version="1.0" ?><root />');
      $p = $x->createTextNode($a . ' -> ' . $b);
      $x->documentElement->appendChild($p);
      return $x->documentElement;
   }
}


$tpl = new DOMDocument();
$tpl->load('test.xsl');

$dom = new DOMDocument();

$xsl = new fXSLTProcessor($tpl);
$xsl->registerPHPFunctions('demo');

$test = new fXSLCallback('test:only','test');
$test->setObject(new foo());

$xsl->registerCallback($test);


$result = $xsl->transformToXml($dom);

$tpl->formatOutput = true;
echo "Template:\n" . $tpl->saveXML();

echo "\n\nOutput:\n".$result;