xref: /php-src/ext/xsl/tests/cloneDocument.phpt (revision 3bb56ae4)
1--TEST--
2cloneDocument
3--EXTENSIONS--
4xsl
5dom
6--FILE--
7<?php
8
9$xml = new DOMDocument;
10$xml->loadXML('<?xml version="1.0"?><root><foo>hello</foo></root>');
11
12function test() {
13    global $xml;
14    $xml->documentElement->firstChild->textContent = "bye";
15}
16
17$xsl = new DOMDocument;
18$xsl->loadXML(<<<XML
19<?xml version="1.0"?>
20<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl" version="1.0">
21    <xsl:template match="/root">
22        <xsl:value-of select="php:function('test')"/>
23        <xsl:value-of select="//root/foo"/>
24    </xsl:template>
25</xsl:stylesheet>
26XML);
27
28$xslt = new XSLTProcessor;
29$xslt->registerPHPFunctions();
30$xslt->cloneDocument = true;
31$xslt->importStylesheet($xsl);
32echo $xslt->transformToXml($xml);
33
34$xslt = new XSLTProcessor;
35$xslt->registerPHPFunctions();
36$xslt->cloneDocument = false;
37$xslt->importStylesheet($xsl);
38echo $xslt->transformToXml($xml);
39
40?>
41--EXPECT--
42<?xml version="1.0"?>
43hello
44<?xml version="1.0"?>
45bye
46