1--TEST--
2Test: Canonicalization - C14N() with references
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7// Adapted from canonicalization.phpt
8
9$xml = <<<EOXML
10<?xml version="1.0" encoding="ISO-8859-1" ?>
11<foo xmlns="http://www.example.com/ns/foo"
12     xmlns:fubar="http://www.example.com/ns/fubar" xmlns:test="urn::test"><contain>
13  <bar><test1 /></bar>
14  <bar><test2 /></bar>
15  <fubar:bar xmlns:fubar="http://www.example.com/ns/fubar"><test3 /></fubar:bar>
16  <fubar:bar><test4 /></fubar:bar>
17</contain>
18</foo>
19EOXML;
20
21$dom = new DOMDocument();
22$dom->loadXML($xml);
23$doc = $dom->documentElement->firstChild;
24
25$xpath = [
26    'query' => '(//a:contain | //a:bar | .//namespace::*)',
27    'namespaces' => ['a' => 'http://www.example.com/ns/foo'],
28];
29$prefixes = ['test'];
30
31foreach ($xpath['namespaces'] as $k => &$v);
32unset($v);
33foreach ($xpath as $k => &$v);
34unset($v);
35foreach ($prefixes as $k => &$v);
36unset($v);
37
38echo $doc->C14N(true, false, $xpath, $prefixes);
39?>
40--EXPECT--
41<contain xmlns="http://www.example.com/ns/foo" xmlns:test="urn::test"><bar></bar><bar></bar></contain>
42