Skip to content

Commit 96ff473

Browse files
author
Dominique Quatravaux
committed
Test-first for new feature: namespacing support
1 parent 84c02bf commit 96ff473

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

t/19namespace.t

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use strict;
2+
use warnings;
3+
4+
use Test::More "no_plan"; # I, for one, don't like it when a plan
5+
# comes together
6+
7+
use XML::XPathScript;
8+
9+
my $xps = XML::XPathScript->new;
10+
11+
my $noop_stylesheet = '<%= apply_templates() %>';
12+
my $result = $xps->transform( <<'NAMESPACED_XML', $noop_stylesheet);
13+
<rss xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wp="http://wordpress.org/export/1.2/" version="2.0">
14+
<channel>
15+
<title>Geography Channel</title>
16+
<wp:wxr_version>1.2</wp:wxr_version>
17+
</channel>
18+
</rss>
19+
NAMESPACED_XML
20+
21+
my ($rss_attributes) = $result =~ m/^<rss ([^>]*)>/;
22+
my @rss_attributes = split m/ /, $rss_attributes;
23+
is scalar(grep { $_ eq 'version="2.0"' } @rss_attributes), 1;
24+
is scalar(grep { $_ =~ m/^xmlns:/ } @rss_attributes), 3;
25+
unlike $result, qr{xmlns:xmlns:};
26+
like $result, qr{<wp:wxr_version>1.2</wp:wxr_version>};
27+
like $result, qr{<title>Geography Channel</title>};

0 commit comments

Comments
 (0)