|
1 <?xml version="1.0"?> |
|
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
|
3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> |
|
4 |
|
5 <!-- |
|
6 where - contains |
|
7 --> |
|
8 |
|
9 <window title="XUL Template Tests" width="500" height="600" |
|
10 onload="test_template();" |
|
11 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
12 <script type="application/javascript" |
|
13 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
14 |
|
15 <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/> |
|
16 |
|
17 <data id="output"> |
|
18 <label step="3" id="http://www.some-fictitious-zoo.com/mammals/zebra" value="Zebra"/> |
|
19 <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/> |
|
20 <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/> |
|
21 <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/> |
|
22 <label step="1" id="http://www.some-fictitious-zoo.com/mammals/arctichare" value="Arctic Hare"/> |
|
23 <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/> |
|
24 </data> |
|
25 |
|
26 <script src="templates_shared.js"/> |
|
27 |
|
28 <script> |
|
29 <![CDATA[ |
|
30 SimpleTest.waitForExplicitFinish(); |
|
31 |
|
32 var testid ="where - contains"; |
|
33 var queryType = "rdf"; |
|
34 var isTreeBuilder = false; |
|
35 var needsOpen = false; |
|
36 var notWorkingYet = false; |
|
37 var notWorkingYetDynamic = false; |
|
38 var expectedOutput = document.getElementById("output"); |
|
39 |
|
40 var changes = [ |
|
41 // step 1 |
|
42 function(targetds, root) { |
|
43 var newnode = RDF.GetResource(ZOO_NS + 'mammals/arctichare'); |
|
44 targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), |
|
45 RDF.GetLiteral('Arctic Hare'), true); |
|
46 var container = ContainerUtils.MakeSeq(targetds, |
|
47 RDF.GetResource(ZOO_NS + 'mammals')); |
|
48 container.AppendElement(newnode); |
|
49 }, |
|
50 // step 2 |
|
51 function(targetds, root) { |
|
52 var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala'); |
|
53 targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), |
|
54 RDF.GetLiteral('Koala'), true); |
|
55 var container = ContainerUtils.MakeSeq(targetds, |
|
56 RDF.GetResource(ZOO_NS + 'mammals')); |
|
57 container.InsertElementAt(newnode, '4', true); |
|
58 }, |
|
59 // step 3 |
|
60 function(targetds, root) { |
|
61 var newnode = RDF.GetResource(ZOO_NS + 'mammals/zebra'); |
|
62 targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), |
|
63 RDF.GetLiteral('Zebra'), true); |
|
64 var container = ContainerUtils.MakeSeq(targetds, |
|
65 RDF.GetResource(ZOO_NS + 'mammals')); |
|
66 container.InsertElementAt(newnode, '1', true); |
|
67 }, |
|
68 // step 4 |
|
69 function(targetds, root) { |
|
70 var container = ContainerUtils.MakeSeq(targetds, |
|
71 RDF.GetResource(ZOO_NS + 'mammals')); |
|
72 var removednode = container.RemoveElementAt('4', true); |
|
73 targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'), |
|
74 RDF.GetLiteral('African Elephant'), true); |
|
75 }, |
|
76 // step 5 |
|
77 function(targetds, root) { |
|
78 var newnode = RDF.GetResource(ZOO_NS + 'mammals/africanelephant'); |
|
79 targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), |
|
80 RDF.GetLiteral('African Elephant'), true); |
|
81 var container = ContainerUtils.MakeSeq(targetds, |
|
82 RDF.GetResource(ZOO_NS + 'mammals')); |
|
83 container.AppendElement(newnode); |
|
84 }, |
|
85 // step 6 |
|
86 function(targetds, root) { |
|
87 targetds.Assert(RDF.GetResource(ZOO_NS + 'mammals/koala'), |
|
88 RDF.GetResource(ZOO_NS + 'rdf#specimensAsString'), |
|
89 RDF.GetLiteral('8'), true); |
|
90 } |
|
91 ]; |
|
92 ]]> |
|
93 </script> |
|
94 |
|
95 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/mammals"> |
|
96 <template id="template"> |
|
97 <query id="query"> |
|
98 <content uri="?uri"/> |
|
99 <member container="?uri" child="?animal"/> |
|
100 <triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/> |
|
101 </query> |
|
102 <rule> |
|
103 <conditions id="conditions"> |
|
104 <where subject="?name" rel="contains" value="e"/> |
|
105 </conditions> |
|
106 <action id="action"> |
|
107 <label uri="?animal" value="?name"/> |
|
108 </action> |
|
109 </rule> |
|
110 </template> |
|
111 </vbox> |
|
112 |
|
113 </window> |