Skip to content

Commit 16622d9

Browse files
committed
Fix #5: Be opinionated and show namespace URIs rather than prefixes
1 parent 6ac7c40 commit 16622d9

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

src/simplexml_tree.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,15 @@ function _simplexml_tree_recursively_process_node($item, $depth, $include_string
158158

159159
// If things are in the current namespace, display them a bit differently
160160
$is_current_namespace = ( $ns_uri == reset($item_ns) );
161-
161+
162+
$ns_uri_quoted = (strlen($ns_uri) == 0 ? 'null' : "'$ns_uri'");
163+
162164
if ( count($attributes) > 0 )
163165
{
164166
if ( ! $is_current_namespace )
165167
{
166168
$dump .= str_repeat($indent, $depth)
167-
. "->attributes('$ns_alias', true)" . PHP_EOL;
169+
. "->attributes($ns_uri_quoted)" . PHP_EOL;
168170
}
169171

170172
foreach ( $attributes as $sx_attribute )
@@ -219,7 +221,7 @@ function _simplexml_tree_recursively_process_node($item, $depth, $include_string
219221
else
220222
{
221223
$dump .= str_repeat($indent, $depth)
222-
. "->children('$ns_alias', true)" . PHP_EOL;
224+
. "->children($ns_uri_quoted)" . PHP_EOL;
223225
$display_depth = $depth + 1;
224226
}
225227

tests/tree-output/basic-default-ns

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SimpleXML object (1 item)
22
[0] // <movies>
3-
->children('', true)
3+
->children('https://github.com/IMSoP/simplexml_debug')
44
->movie[0]
55
->title[0]
66
->characters[0]

tests/tree-output/basic-ns

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SimpleXML object (1 item)
22
[0] // <movies>
3-
->children('test', true)
3+
->children('https://github.com/IMSoP/simplexml_debug')
44
->movie[0]
55
->title[0]
66
->characters[0]
@@ -14,8 +14,8 @@ SimpleXML object (1 item)
1414
->great-lines[0]
1515
->line[0]
1616
->rating[0]
17-
->attributes('', true)
17+
->attributes(null)
1818
->type
1919
->rating[1]
20-
->attributes('', true)
20+
->attributes(null)
2121
->type

tests/tree-output/soap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
SimpleXML object (1 item)
22
[0] // <soap:Envelope>
3-
->children('soap', true)
3+
->children('http://schemas.xmlsoap.org/soap/envelope/')
44
->Header[0]
5-
->children('s', true)
5+
->children('http://example.org/security')
66
->credentials[0]
7-
->children('', true)
7+
->children(null)
88
->username[0]
99
->password[0]
1010
->Body[0]
11-
->children('tns', true)
11+
->children('http://example.org/some-soap-service')
1212
->DoSomething[0]
13-
->children('', true)
13+
->children(null)
1414
->from[0]
1515
->to[0]

0 commit comments

Comments
 (0)