content/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntax.xul

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:9b84ea78258d
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 tree element - query syntax
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 <treecols id="treecols" orient="horizontal">
19 <treecol id="treecol" primary="true" label="Name" ordinal="1"/>
20 <treecol label="Species" ordinal="3"/>
21 </treecols>
22 <treechildren>
23 <treeitem id="http://www.some-fictitious-zoo.com/birds/emu">
24 <treerow>
25 <treecell label="Emu"/>
26 <treecell step="-6" label="12"/>
27 <treecell step="6" label="0"/>
28 </treerow>
29 </treeitem>
30 <treeitem step="1" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
31 <treerow>
32 <treecell label="Archaeopteryx"/>
33 <treecell step="-4"/>
34 <treecell step="4" label="5"/>
35 </treerow>
36 </treeitem>
37 <treeitem step="-2" id="http://www.some-fictitious-zoo.com/birds/barnowl">
38 <treerow>
39 <treecell label="Barn Owl"/>
40 <treecell label="4"/>
41 </treerow>
42 </treeitem>
43 <treeitem id="http://www.some-fictitious-zoo.com/birds/raven">
44 <treerow>
45 <treecell step="-7" label="Raven"/>
46 <treecell step="7" label="Crow"/>
47 <treecell step="-5" label="0"/>
48 <treecell step="5" label="2"/>
49 </treerow>
50 </treeitem>
51 </treechildren>
52 </data>
53
54 <script src="templates_shared.js"/>
55
56 <script>
57 <![CDATA[
58 SimpleTest.waitForExplicitFinish();
59
60 var testid ="tree element - query syntax";
61 var queryType = "rdf";
62 var isTreeBuilder = false;
63 var needsOpen = false;
64 var notWorkingYet = false;
65 var notWorkingYetDynamic = false;
66 var expectedOutput = document.getElementById("output");
67
68 var changes = [
69 // step 1
70 function(targetds, root) {
71 var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
72 targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
73 RDF.GetLiteral('Archaeopteryx'), true);
74 var container = ContainerUtils.MakeSeq(targetds,
75 RDF.GetResource(ZOO_NS + 'birds'));
76 container.InsertElementAt(newnode, '2', true);
77 },
78 // step 2
79 function(targetds, root) {
80 var container = ContainerUtils.MakeSeq(targetds,
81 RDF.GetResource(ZOO_NS + 'birds'));
82 var removednode = container.RemoveElementAt('3', true);
83 targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'),
84 RDF.GetLiteral('Barn Owl'), true);
85 },
86 // step 3
87 function(targetds, root) {
88 targetds.Assert(RDF.GetResource(ZOO_NS + 'birds/archaeopteryx'),
89 RDF.GetResource(ZOO_NS + 'rdf#species'),
90 RDF.GetLiteral('Archaeopteryx lithographica'), true);
91 },
92 // step 4
93 function(targetds, root) {
94 targetds.Assert(RDF.GetResource(ZOO_NS + 'birds/archaeopteryx'),
95 RDF.GetResource(ZOO_NS + 'rdf#specimens'),
96 RDF.GetLiteral('5'), true);
97 },
98 // step 5
99 function(targetds, root) {
100 var subject = RDF.GetResource(ZOO_NS + 'birds/raven');
101 var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimens');
102 var oldval = targetds.GetTarget(subject, predicate, true);
103 targetds.Change(RDF.GetResource(ZOO_NS + 'birds/raven'),
104 RDF.GetResource(ZOO_NS + 'rdf#specimens'),
105 oldval, RDF.GetLiteral('2'));
106 },
107 // step 6
108 function(targetds, root) {
109 var subject = RDF.GetResource(ZOO_NS + 'birds/emu');
110 var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimens');
111 var oldval = targetds.GetTarget(subject, predicate, true);
112 targetds.Change(RDF.GetResource(ZOO_NS + 'birds/emu'),
113 RDF.GetResource(ZOO_NS + 'rdf#specimens'),
114 oldval, RDF.GetLiteral('0'));
115 },
116 // step 7
117 function(targetds, root) {
118 var subject = RDF.GetResource(ZOO_NS + 'birds/raven');
119 var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
120 var oldval = targetds.GetTarget(subject, predicate, true);
121 targetds.Change(RDF.GetResource(ZOO_NS + 'birds/raven'),
122 RDF.GetResource(ZOO_NS + 'rdf#name'),
123 oldval, RDF.GetLiteral('Crow'));
124 }
125 ];
126 ]]>
127 </script>
128
129 <tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" hidevscroll="true" hidehscroll="true" datasources="rdf:null" flags="" id="root" ref="http://www.some-fictitious-zoo.com/birds">
130 <treecols orient="horizontal" id="treecols">
131 <treecol id="treecol" primary="true" label="Name"/>
132 <treecol label="Species"/>
133 </treecols>
134 <template id="template">
135 <query>
136 <content uri="?uri"/>
137 <member container="?uri" child="?child"/>
138 <triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
139 </query>
140 <rule>
141 <bindings>
142 <binding subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#specimens" object="?specimens"/>
143 </bindings>
144 <action>
145 <treechildren>
146 <treeitem uri="?child">
147 <treerow>
148 <treecell label="?name"/>
149 <treecell label="?specimens"/>
150 </treerow>
151 </treeitem>
152 </treechildren>
153 </action>
154 </rule>
155 </template>
156 </tree>
157
158 </window>

mercurial