blob: 350d3034bffdd35de2ea483ccc4eb0bf34e35d21 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
--TEST--
Test: Canonicalization - C14N()
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
$xml = <<<EOXML
<?xml version="1.0" encoding="ISO-8859-1" ?>
<foo xmlns="http://www.example.com/ns/foo"
xmlns:fubar="http://www.example.com/ns/fubar" xmlns:test="urn::test"><contain>
<bar><test1 /></bar>
<bar><test2 /></bar>
<fubar:bar xmlns:fubar="http://www.example.com/ns/fubar"><test3 /></fubar:bar>
<fubar:bar><test4 /></fubar:bar>
<!-- this is a comment -->
</contain>
</foo>
EOXML;
$dom = new DOMDocument();
$dom->loadXML($xml);
$doc = $dom->documentElement->firstChild;
/* inclusive/without comments first child element of doc element is context. */
echo $doc->C14N()."\n\n";
/* exclusive/without comments first child element of doc element is context. */
echo $doc->c14N(TRUE)."\n\n";
/* inclusive/with comments first child element of doc element is context. */
echo $doc->C14N(FALSE, TRUE)."\n\n";
/* exclusive/with comments first child element of doc element is context. */
echo $doc->C14N(TRUE, TRUE)."\n\n";
/* exclusive/without comments using xpath query. */
echo $doc->c14N(TRUE, FALSE, array('query'=>'(//. | //@* | //namespace::*)'))."\n\n";
/* exclusive/without comments first child element of doc element is context.
using xpath query with registered namespace.
test namespace prefix is also included. */
echo $doc->c14N(TRUE, FALSE,
array('query'=>'(//a:contain | //a:bar | .//namespace::*)',
'namespaces'=>array('a'=>'http://www.example.com/ns/foo')),
array('test'))."\n\n";
/* exclusive/without comments first child element of doc element is context.
test namespace prefix is also included */
echo $doc->C14N(TRUE, FALSE, NULL, array('test'));
?>
--EXPECT--
<contain xmlns="http://www.example.com/ns/foo" xmlns:fubar="http://www.example.com/ns/fubar" xmlns:test="urn::test">
<bar><test1></test1></bar>
<bar><test2></test2></bar>
<fubar:bar><test3></test3></fubar:bar>
<fubar:bar><test4></test4></fubar:bar>
</contain>
<contain xmlns="http://www.example.com/ns/foo">
<bar><test1></test1></bar>
<bar><test2></test2></bar>
<fubar:bar xmlns:fubar="http://www.example.com/ns/fubar"><test3></test3></fubar:bar>
<fubar:bar xmlns:fubar="http://www.example.com/ns/fubar"><test4></test4></fubar:bar>
</contain>
<contain xmlns="http://www.example.com/ns/foo" xmlns:fubar="http://www.example.com/ns/fubar" xmlns:test="urn::test">
<bar><test1></test1></bar>
<bar><test2></test2></bar>
<fubar:bar><test3></test3></fubar:bar>
<fubar:bar><test4></test4></fubar:bar>
<!-- this is a comment -->
</contain>
<contain xmlns="http://www.example.com/ns/foo">
<bar><test1></test1></bar>
<bar><test2></test2></bar>
<fubar:bar xmlns:fubar="http://www.example.com/ns/fubar"><test3></test3></fubar:bar>
<fubar:bar xmlns:fubar="http://www.example.com/ns/fubar"><test4></test4></fubar:bar>
<!-- this is a comment -->
</contain>
<foo xmlns="http://www.example.com/ns/foo"><contain>
<bar><test1></test1></bar>
<bar><test2></test2></bar>
<fubar:bar xmlns:fubar="http://www.example.com/ns/fubar"><test3></test3></fubar:bar>
<fubar:bar xmlns:fubar="http://www.example.com/ns/fubar"><test4></test4></fubar:bar>
</contain>
</foo>
<contain xmlns="http://www.example.com/ns/foo" xmlns:test="urn::test"><bar></bar><bar></bar></contain>
<contain xmlns="http://www.example.com/ns/foo" xmlns:test="urn::test">
<bar><test1></test1></bar>
<bar><test2></test2></bar>
<fubar:bar xmlns:fubar="http://www.example.com/ns/fubar"><test3></test3></fubar:bar>
<fubar:bar xmlns:fubar="http://www.example.com/ns/fubar"><test4></test4></fubar:bar>
</contain>
|