File: test.patch

package info (click to toggle)
libxml-xpath-perl 1.13-7
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, wheezy
  • size: 448 kB
  • ctags: 448
  • sloc: perl: 3,969; xml: 34; makefile: 2
file content (55 lines) | stat: -rw-r--r-- 1,803 bytes parent folder | download
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
--- /dev/null
+++ b/t/base.t
@@ -0,0 +1,52 @@
+print "1..6\n";
+use XML::XPath;
+use XML::XPath::Parser;
+use XML::XPath::XMLParser;
+
+# $XML::XPath::Debug = 1;
+
+my $p = XML::XPath->new( filename => 'examples/test.xml' );
+if ($p) { print "ok 1\n"; }
+else { print "not ok 1\n"; }
+
+my $pp = XML::XPath::Parser->new();
+if ($pp) { print "ok 2\n"; }
+else { print "not ok 2\n"; }
+
+$pp->parse("variable('amount', number(number(./rate/text()) * number(./units_worked/text())))");
+
+my $path = $pp->parse('.//
+		tag/
+		child::*/
+		processing-instruction("Fred")/
+		self::node()[substr("33", 1, 1)]/
+		attribute::ra[../@gunk]
+			[(../../@att="va\'l") and (@bert = "geee")]
+			[position() = child::para/fred]
+			[0 -.3]/
+		geerner[(farp | blert)[predicate[@vee]]]');
+
+if ($path) { print "ok 3\n"; }
+else { print "not ok 3\n"; }
+
+#$path = $pp->parse('param|title');
+
+warn "PATH: ", $path->as_string, "\n\n";
+
+if ($path->as_string) { # eq q^(self::node()/descendant-or-self::node()/child::tag/child::*/child::processing-instruction('Fred')/child::id((child::xml/child::vccc/child::bbbb/attribute::fer))/self::node()[(substr(('33'),(1),(1)))]/attribute::ra[(parent::node()/attribute::gunk)][((parent::node()/parent::node()/attribute::att = ('va'l')) and ((attribute::bert = ('geee'))))][(position() = (child::para/child::fred))][(.3)]/child::geerner[((child::fart | (child::blert))[(child::predicate[(attribute::vee)])])])^ ) {
+	print "ok 4\n";
+}
+else { print "not ok 4\n"; }
+
+my $nodes = $p->find('/timesheet//wednesday');
+
+# warn "$nodes size: ", $nodes->size, "\n";
+
+if ($nodes->size) { print "ok 5\n"; }
+else { print "not ok 5\n"; }
+
+foreach my $node ($nodes->get_nodelist) {
+	warn "NODES:\n", XML::XPath::XMLParser::as_string($node), "\n\n";
+}
+
+print "ok 6\n";