applied hide_doc.patch from Ricardo Pedroso
[swftools.git] / lib / as3 / ok / xml_ns.as
1 package {
2     import flash.display.MovieClip
3     public class Main extends flash.display.MovieClip {
4         var count:int = 1;
5         var num:int = 9;
6         function assert(b:Boolean) {
7             if(b) {
8                 trace("ok "+count+"/"+num);
9             } else {
10                 trace("error "+count+"/"+num);
11             }
12             count = count + 1
13         }
14         function Main() {
15             var x:XML = 
16                 <tests xmlns:test1="http://www.quiss.org/test1/"
17                        xmlns:test2="http://www.quiss.org/test2/"
18                        xmlns:test3="http://www.quiss.org/test3/">
19                     <test1:test>P1</test1:test>
20                     <test2:test>P2</test2:test>
21                     <test3:test a="b">P3</test3:test>
22                 </tests>
23
24             var top:Namespace = x.namespace();
25             var ns1:Namespace = x.namespace("test1");
26             var ns2:Namespace = x.namespace("test2");
27             var ns3:Namespace = x.namespace("test3");
28             assert(ns1 == new Namespace("http://www.quiss.org/test1/"));
29             assert(ns2 == new Namespace("http://www.quiss.org/test2/"));
30             assert(x.ns1::test == "P1");
31             assert(x.ns2::test == "P2");
32
33             assert(x.ns1::* == "P1")
34
35             default xml namespace = ns2;
36             assert(x.test == "P2")
37
38             assert(x.*::* == (x.ns1::*+x.ns2::*+x.ns3::*))
39             //attribute with a namespace:
40             assert(x..@*::* == "b");
41
42             x.ns2::test = x.ns3::test;
43             assert(x..@a.toString() == "bb");
44
45             trace("[exit]");
46         }
47     }
48 }