xref: /php-src/ext/dom/tests/dom_xinclude.phpt (revision a068a9a5)
1--TEST--
2Test: Xinclude and Streams
3--EXTENSIONS--
4dom
5--SKIPIF--
6<?php
7in_array('compress.zlib', stream_get_wrappers()) or die('skip compress.zlib wrapper is not available');
8?>
9--FILE--
10<?php
11$data = file_get_contents(__DIR__."/xinclude.xml");
12$reldir = str_replace(getcwd(),".",__DIR__);
13if (DIRECTORY_SEPARATOR == '\\') {
14    $reldir = str_replace('\\',"/", $reldir);
15}
16$data = str_replace('compress.zlib://ext/dom/tests/','compress.zlib://'.$reldir."/", $data);
17
18$dom = new domdocument;
19$dom->loadXML($data);
20$dom->xinclude();
21print $dom->saveXML()."\n";
22foreach ($dom->documentElement->childNodes as $node) {
23    print $node->nodeName."\n";
24}
25
26$dom = Dom\XMLDocument::createFromString($data);
27$dom->xinclude();
28print $dom->saveXML()."\n";
29foreach ($dom->documentElement->childNodes as $node) {
30    print $node->nodeName."\n";
31}
32?>
33--EXPECTF--
34<?xml version="1.0"?>
35<foo xmlns:xi="http://www.w3.org/2001/XInclude">
36    <book xml:base="compress.zlib://%sbook.xml">
37  <title>The Grapes of Wrath</title>
38  <author>John Steinbeck</author>
39 </book><book xml:base="compress.zlib://%sbook.xml">
40  <title>The Pearl</title>
41  <author>John Steinbeck</author>
42 </book>
43 </foo>
44
45#text
46book
47book
48#text
49<?xml version="1.0" encoding="UTF-8"?>
50<foo xmlns:xi="http://www.w3.org/2001/XInclude">
51    <book xml:base="compress.zlib://./ext/dom/tests/book.xml">
52  <title>The Grapes of Wrath</title>
53  <author>John Steinbeck</author>
54 </book><book xml:base="compress.zlib://./ext/dom/tests/book.xml">
55  <title>The Pearl</title>
56  <author>John Steinbeck</author>
57 </book>
58 </foo>
59#text
60book
61book
62#text
63