|
| 1 | +--TEST-- |
| 2 | +Special operations with XSLTProcessor properties |
| 3 | +--EXTENSIONS-- |
| 4 | +xsl |
| 5 | +dom |
| 6 | +--FILE-- |
| 7 | +<?php |
| 8 | + |
| 9 | +$xml = new DOMDocument; |
| 10 | +$xml->loadXML('<?xml version="1.0"?><root><foo>hello</foo></root>'); |
| 11 | + |
| 12 | +function test() { |
| 13 | + echo "Called test\n"; |
| 14 | +} |
| 15 | + |
| 16 | +$xsl = new DOMDocument; |
| 17 | +$xsl->loadXML(<<<XML |
| 18 | +<?xml version="1.0"?> |
| 19 | +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl" version="1.0"> |
| 20 | + <xsl:template match="/root"> |
| 21 | + <xsl:value-of select="php:function('test')"/> |
| 22 | + <xsl:value-of select="//root/foo"/> |
| 23 | + </xsl:template> |
| 24 | +</xsl:stylesheet> |
| 25 | +XML); |
| 26 | + |
| 27 | +echo "--- Unset cloneDocument ---\n"; |
| 28 | + |
| 29 | +$xslt = new XSLTProcessor; |
| 30 | +$xslt->registerPHPFunctions(); |
| 31 | +unset($xslt->cloneDocument); |
| 32 | +try { |
| 33 | + $xslt->importStylesheet($xsl); |
| 34 | +} catch (Error $e) { |
| 35 | + echo $e->getMessage(), "\n"; |
| 36 | +} |
| 37 | + |
| 38 | +echo "--- Unset doXInclude ---\n"; |
| 39 | + |
| 40 | +$xslt = new XSLTProcessor; |
| 41 | +$xslt->registerPHPFunctions(); |
| 42 | +unset($xslt->doXInclude); |
| 43 | +$xslt->importStylesheet($xsl); |
| 44 | +try { |
| 45 | + echo $xslt->transformToXml($xml); |
| 46 | +} catch (Error $e) { |
| 47 | + echo $e->getMessage(), "\n"; |
| 48 | +} |
| 49 | + |
| 50 | +echo "--- Make properties references ---\n"; |
| 51 | + |
| 52 | +$xslt = new XSLTProcessor; |
| 53 | +$xslt->registerPHPFunctions(); |
| 54 | +$clone =& $xslt->cloneDocument; |
| 55 | +$xinclude =& $xslt->doXInclude; |
| 56 | +$xslt->importStylesheet($xsl); |
| 57 | +echo $xslt->transformToXml($xml); |
| 58 | + |
| 59 | +?> |
| 60 | +--EXPECT-- |
| 61 | +--- Unset cloneDocument --- |
| 62 | +Typed property XSLTProcessor::$cloneDocument must not be accessed before initialization |
| 63 | +--- Unset doXInclude --- |
| 64 | +Typed property XSLTProcessor::$doXInclude must not be accessed before initialization |
| 65 | +--- Make properties references --- |
| 66 | +Called test |
| 67 | +<?xml version="1.0"?> |
| 68 | +hello |
0 commit comments