|
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 query - 3 triples - 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 id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Robert likes Tarantulas"/> |
|
19 <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="Robert likes African Elephants"/> |
|
20 <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="Robert likes African Elephants"/> |
|
21 </data> |
|
22 |
|
23 <script src="templates_shared.js"/> |
|
24 |
|
25 <script> |
|
26 <![CDATA[ |
|
27 SimpleTest.waitForExplicitFinish(); |
|
28 |
|
29 var testid ="query - 3 triples - where contains"; |
|
30 var queryType = "rdf"; |
|
31 var isTreeBuilder = false; |
|
32 var needsOpen = false; |
|
33 var notWorkingYet = false; |
|
34 var notWorkingYetDynamic = false; |
|
35 var expectedOutput = document.getElementById("output"); |
|
36 |
|
37 var changes = [ |
|
38 // step 1 |
|
39 function(targetds, root) { |
|
40 var newnode = RDF.GetResource(ZOO_NS + 'mammals/arctichare'); |
|
41 targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), |
|
42 RDF.GetLiteral('Arctic Hare'), true); |
|
43 var container = ContainerUtils.MakeSeq(targetds, |
|
44 RDF.GetResource(ZOO_NS + 'mammals')); |
|
45 container.AppendElement(newnode); |
|
46 }, |
|
47 // step 2 |
|
48 function(targetds, root) { |
|
49 var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala'); |
|
50 targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), |
|
51 RDF.GetLiteral('Koala'), true); |
|
52 var container = ContainerUtils.MakeSeq(targetds, |
|
53 RDF.GetResource(ZOO_NS + 'mammals')); |
|
54 container.InsertElementAt(newnode, '4', true); |
|
55 }, |
|
56 // step 3 |
|
57 function(targetds, root) { |
|
58 var newnode = RDF.GetResource(ZOO_NS + 'mammals/zebra'); |
|
59 targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), |
|
60 RDF.GetLiteral('Zebra'), true); |
|
61 var container = ContainerUtils.MakeSeq(targetds, |
|
62 RDF.GetResource(ZOO_NS + 'mammals')); |
|
63 container.InsertElementAt(newnode, '1', true); |
|
64 }, |
|
65 // step 4 |
|
66 function(targetds, root) { |
|
67 var container = ContainerUtils.MakeSeq(targetds, |
|
68 RDF.GetResource(ZOO_NS + 'mammals')); |
|
69 var removednode = container.RemoveElementAt('4', true); |
|
70 targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'), |
|
71 RDF.GetLiteral('African Elephant'), true); |
|
72 }, |
|
73 // step 5 |
|
74 function(targetds, root) { |
|
75 var newnode = RDF.GetResource(ZOO_NS + 'mammals/africanelephant'); |
|
76 targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), |
|
77 RDF.GetLiteral('African Elephant'), true); |
|
78 var container = ContainerUtils.MakeSeq(targetds, |
|
79 RDF.GetResource(ZOO_NS + 'mammals')); |
|
80 container.AppendElement(newnode); |
|
81 }, |
|
82 // step 6 |
|
83 function(targetds, root) { |
|
84 targetds.Assert(RDF.GetResource(ZOO_NS + 'mammals/koala'), |
|
85 RDF.GetResource(ZOO_NS + 'rdf#specimensAsString'), |
|
86 RDF.GetLiteral('8'), true); |
|
87 } |
|
88 ]; |
|
89 ]]> |
|
90 </script> |
|
91 |
|
92 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans/robert"> |
|
93 <template id="template"> |
|
94 <query id="query"> |
|
95 <content uri="?uri"/> |
|
96 <triple subject="?uri" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?humanname"/> |
|
97 <triple subject="?uri" predicate="http://www.some-fictitious-zoo.com/rdf#favoriteAnimal" object="?favoriteAnimal"/> |
|
98 <triple subject="?favoriteAnimal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?animalname"/> |
|
99 </query> |
|
100 <rule> |
|
101 <conditions id="conditions"> |
|
102 <where subject="?favoriteAnimal" rel="contains" value="ant"/> |
|
103 </conditions> |
|
104 <action> |
|
105 <label uri="?favoriteAnimal" value="?humanname likes ?animalname^s"/> |
|
106 </action> |
|
107 </rule> |
|
108 </template> |
|
109 </vbox> |
|
110 |
|
111 </window> |