<commit_before><?php

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

require '../src/fxslcallback.php';
require '../src/fxsltprocessor.php';

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

class foo {
   public function bar() {
      $x = new \DOMDocument();      
      $x->loadXML('<?xml version="1.0" ?><root />');
      $p = $x->createTextNode('Hello world');
      $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);

echo $xsl->transformToXml($dom);
<commit_msg>Better output for showcase ;)<commit_after><?php

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

require '../src/fxslcallback.php';
require '../src/fxsltprocessor.php';

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

class foo {
   public function bar() {
      $x = new \DOMDocument();      
      $x->loadXML('<?xml version="1.0" ?><root />');
      $p = $x->createTextNode('Hello world');
      $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;

{'fraction_non_alphanumeric': 0.20350241545893719, 'fraction_numerical': 0.0024154589371980675, 'mean_word_length': 4.161993769470405, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 2, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2795736', 'n_tokens_mistral': 597, 'n_tokens_neox': 592, 'n_words': 112}