1 /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is Rhino code, released
19 * The Initial Developer of the Original Code is
20 * Netscape Communications Corporation.
21 * Portions created by the Initial Developer are Copyright (C) 1997-2000
22 * the Initial Developer. All Rights Reserved.
29 * Alternatively, the contents of this file may be used under the terms of
30 * either the GNU General Public License Version 2 or later (the "GPL"), or
31 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
32 * in which case the provisions of the GPL or the LGPL are applicable instead
33 * of those above. If you wish to allow use of your version of this file only
34 * under the terms of either the GPL or the LGPL, and not to allow others to
35 * use your version of this file under the terms of the MPL, indicate your
36 * decision by deleting the provisions above and replace them with the notice
37 * and other provisions required by the GPL or the LGPL. If you do not delete
38 * the provisions above, a recipient may use your version of this file under
39 * the terms of any one of the MPL, the GPL or the LGPL.
41 * ***** END LICENSE BLOCK ***** */
44 START("11.6.1 - XML Assignment");
46 // Change the value of the id attribute on the second item
50 <description>Big Screen Television</description>
51 <price>1299.99</price>
54 <description>DVD Player</description>
58 <description>CD Player</description>
62 <description>8-Track Player</description>
70 <description>Big Screen Television</description>
71 <price>1299.99</price>
74 <description>DVD Player</description>
78 <description>CD Player</description>
82 <description>8-Track Player</description>
87 order.item[1].@id = 1.23;
88 TEST(1, correct, order);
90 // Add a new attribute to the second item
94 <description>Big Screen Television</description>
95 <price>1299.99</price>
98 <description>DVD Player</description>
102 <description>CD Player</description>
103 <price>199.99</price>
106 <description>8-Track Player</description>
114 <description>Big Screen Television</description>
115 <price>1299.99</price>
117 <item id="2" newattr="new value">
118 <description>DVD Player</description>
119 <price>399.99</price>
122 <description>CD Player</description>
123 <price>199.99</price>
126 <description>8-Track Player</description>
131 order.item[1].@newattr = "new value";
132 TEST(2, correct, order);
134 // Construct an attribute list containing all the ids in this order
138 <description>Big Screen Television</description>
139 <price>1299.99</price>
142 <description>DVD Player</description>
143 <price>399.99</price>
146 <description>CD Player</description>
147 <price>199.99</price>
150 <description>8-Track Player</description>
155 order.@allids = order.item.@id;
156 TEST_XML(3, "1 2 3 4", order.@allids);
158 // Replace first child of the order element with an XML value
163 <address>948 Ranier Ave.</address>
164 <city>Portland</city>
168 <description>Big Screen Television</description>
169 <price>1299.99</price>
172 <description>DVD Player</description>
173 <price>399.99</price>
176 <description>CD Player</description>
177 <price>199.99</price>
180 <description>8-Track Player</description>
189 <address>123 Foobar Ave.</address>
190 <city>Bellevue</city>
198 <address>123 Foobar Ave.</address>
199 <city>Bellevue</city>
203 <description>Big Screen Television</description>
204 <price>1299.99</price>
207 <description>DVD Player</description>
208 <price>399.99</price>
211 <description>CD Player</description>
212 <price>199.99</price>
215 <description>8-Track Player</description>
220 TEST(4, correct, order);
222 // Replace the second child of the order element with a list of items
228 <address>948 Ranier Ave.</address>
229 <city>Portland</city>
233 <description>Big Screen Television</description>
234 <price>1299.99</price>
237 <description>DVD Player</description>
238 <price>399.99</price>
241 <description>CD Player</description>
242 <price>199.99</price>
245 <description>8-Track Player</description>
254 <address>948 Ranier Ave.</address>
255 <city>Portland</city>
258 <item>item one</item>
259 <item>item two</item>
260 <item>item three</item>
262 <description>DVD Player</description>
263 <price>399.99</price>
266 <description>CD Player</description>
267 <price>199.99</price>
270 <description>8-Track Player</description>
275 order.item[0] = <item>item one</item> +
276 <item>item two</item> +
277 <item>item three</item>;
279 TEST(5, correct, order);
281 // Replace the third child of the order with a text node
286 <address>948 Ranier Ave.</address>
287 <city>Portland</city>
291 <description>Big Screen Television</description>
292 <price>1299.99</price>
295 <description>DVD Player</description>
296 <price>399.99</price>
299 <description>CD Player</description>
300 <price>199.99</price>
303 <description>8-Track Player</description>
312 <address>948 Ranier Ave.</address>
313 <city>Portland</city>
317 <description>Big Screen Television</description>
318 <price>1299.99</price>
320 <item id="2">A Text Node</item>
322 <description>CD Player</description>
323 <price>199.99</price>
326 <description>8-Track Player</description>
331 order.item[1] = "A Text Node";
333 TEST(6, correct, order);
335 // append a new item to the end of the order
341 <address>948 Ranier Ave.</address>
342 <city>Portland</city>
346 <description>Big Screen Television</description>
347 <price>1299.99</price>
350 <description>DVD Player</description>
351 <price>399.99</price>
354 <description>CD Player</description>
355 <price>199.99</price>
358 <description>8-Track Player</description>
367 <address>948 Ranier Ave.</address>
368 <city>Portland</city>
372 <description>Big Screen Television</description>
373 <price>1299.99</price>
376 <description>DVD Player</description>
377 <price>399.99</price>
380 <description>CD Player</description>
381 <price>199.99</price>
384 <description>8-Track Player</description>
387 <item>new item</item>
390 order.*[order.*.length()] = <item>new item</item>;
392 TEST(7, correct, order);
394 // Change the price of the item
397 <description>Big Screen Television</description>
398 <price>1299.99</price>
403 <description>Big Screen Television</description>
409 TEST(8, item, correct);
411 // Change the description of the item
414 <description>Big Screen Television</description>
415 <price>1299.99</price>
420 <description>Mobile Phone</description>
421 <price>1299.99</price>
424 item.description = "Mobile Phone";
426 TEST(9, item, correct);