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.2.1 - Property Accessors");
47 <order id="123456" timestamp="Mon Mar 10 2003 16:03:25 GMT-0800 (PST)">
49 <firstname>John</firstname>
50 <lastname>Doe</lastname>
53 <description>Big Screen Television</description>
54 <price>1299.99</price>
55 <quantity>1</quantity>
61 <firstname>John</firstname>
62 <lastname>Doe</lastname>
65 TEST(1, correct, order.customer);
66 TEST_XML(2, 123456, order.@id);
70 <description>Big Screen Television</description>
71 <price>1299.99</price>
72 <quantity>1</quantity>
75 TEST(3, correct, order.children()[1]);
79 <firstname>John</firstname>
80 <lastname>Doe</lastname>
83 <description>Big Screen Television</description>
84 <price>1299.99</price>
85 <quantity>1</quantity>
89 TEST(4, correct, order.*);
91 correct = new XMLList();
92 correct += new XML("123456");
93 correct += new XML("Mon Mar 10 2003 16:03:25 GMT-0800 (PST)");
94 TEST(5, correct, order.@*);
98 <firstname>John</firstname>
99 <lastname>Doe</lastname>
102 <description>Big Screen Television</description>
103 <price>1299.99</price>
104 <quantity>1</quantity>
107 <description>DVD Player</description>
108 <price>399.99</price>
109 <quantity>1</quantity>
114 <description>Big Screen Television</description> +
115 <description>DVD Player</description>;
117 TEST(6, correct, order.item.description);
119 correct = new XMLList();
120 correct += new XML("3456");
121 correct += new XML("56789");
122 TEST(7, correct, order.item.@id);
126 <description>DVD Player</description>
127 <price>399.99</price>
128 <quantity>1</quantity>
131 TEST(8, correct, order.item[1]);
134 <description>Big Screen Television</description> +
135 <price>1299.99</price> +
136 <quantity>1</quantity> +
137 <description>DVD Player</description> +
138 <price>399.99</price> +
139 <quantity>1</quantity>;
141 TEST(9, correct, order.item.*);
144 <price>1299.99</price>;
146 TEST(10, correct, order.item.*[1]);
148 // The spec requires that we get the first (and only) order [treating single element as a list].
149 // We ignore this for xml objects that can have children and always return children for numeric
153 // <firstname>John</firstname>
154 // <lastname>Doe</lastname>
157 // <description>Big Screen Television</description>
158 // <price>1299.99</price>
159 // <quantity>1</quantity>
162 // <description>DVD Player</description>
163 // <price>399.99</price>
164 // <quantity>1</quantity>
168 // TEST(11, order, order[0]);
170 // Any other index should return undefined, but we return the other child.
171 // TEST(12, undefined, order[1]);