summaryrefslogtreecommitdiff
path: root/test/files/xml/lnk.scala
blob: d5f0295f9c70ef0a48efc7a6d6ca49f13c003c3a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// $Id$

import scala.xml.{Attribute, AttributeSeq, Node};
import dtd._;

object Test {

  // 3 ways to construct your data
  def main(args:Array[String]) = {

    val n = Node.NoAttributes ;
    // construct data using original Element name
    //val b: Node = dtd._factory.get("link").match { case Some(x) => x(Nil,null)}; // safe
    // !!! System.out.println(b.toXML);

    // construct data using constructor (valid)
    val c = Link(
      AttributeSeq.fromAttrs(
        Attribute("","target","http://www.scala.org")
      ),
      Name(n, scala.xml.Text("hello-link"))
    );

    try {
      val c2 = Name(
        n,
        Link( n )
      );
      Console.println("eh ?");
    } catch {
      case scala.xml.dtd.ValidationException(msg) => {
        Console.print("validator throws exception: ");
        Console.println( msg );
      }
      case z => // ignore
        Console.println("whut??? "+z.getClass);

    }




    //c.getAttribs.update("target", "http://www.scala.org");
    System.out.println( c );

    // construct data using loading from a file
    val lnkDB = load(args(0));
    System.out.println( lnkDB );
  }

}