summaryrefslogtreecommitdiff
path: root/test/files/jvm/xmlstuff.scala
diff options
context:
space:
mode:
authorburaq <buraq@epfl.ch>2004-02-11 11:49:26 +0000
committerburaq <buraq@epfl.ch>2004-02-11 11:49:26 +0000
commitda6966888b1703c69dfe17f7f471565edc46e5a2 (patch)
tree92fce0402f318a339eef05d6efe1ee0767b99192 /test/files/jvm/xmlstuff.scala
parentbd2cb9d56f03843f34c6580983d96731d6dd14e2 (diff)
downloadscala-da6966888b1703c69dfe17f7f471565edc46e5a2.tar.gz
scala-da6966888b1703c69dfe17f7f471565edc46e5a2.tar.bz2
scala-da6966888b1703c69dfe17f7f471565edc46e5a2.zip
these are jvm dependent
Diffstat (limited to 'test/files/jvm/xmlstuff.scala')
-rw-r--r--test/files/jvm/xmlstuff.scala50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/files/jvm/xmlstuff.scala b/test/files/jvm/xmlstuff.scala
new file mode 100644
index 0000000000..28f753ce90
--- /dev/null
+++ b/test/files/jvm/xmlstuff.scala
@@ -0,0 +1,50 @@
+import java.io.StringReader;
+import org.xml.sax.InputSource;
+import scala.xml.nobinding.XML;
+import scala.testing.UnitTest.assertEquals ;
+import scala.xml.NodeList;
+
+object Test with Application {
+ val xmlFile1 = "<hello><world/></hello>";
+ val isrc1 = new InputSource( new StringReader( xmlFile1 ) );
+ val parsedxml1 = XML.load( isrc1 );
+
+ val xmlFile2 = "<bib><book><author>Peter Buneman</author><author>Dan Suciu</author><title>Data on ze web</title></book><book><author>John Mitchell</author><title>Foundations of Programming Languages</title></book></bib>";
+ val isrc2 = new InputSource( new StringReader( xmlFile2 ) );
+ val parsedxml2 = XML.load( isrc2 );
+
+ // xmlFile2/book -> book,book
+
+ Console.println( parsedxml1/'world ); /* List('world()) */
+ Console.println( parsedxml1/'_ ); /* List('world()) */
+
+ Console.println( "\nparsedxml2/'_"); /* List(book,book) */
+ Console.println( parsedxml2/'_); /* List(book,book) */
+
+ Console.println( "\nparsedxml2/'author"); /* List() */
+ Console.println( parsedxml2/'author); /* List() */
+
+ Console.println( "\nparsedxml2/'book:");
+ Console.println( parsedxml2/'book); /* List(book,book) */
+
+ Console.println( "\nparsedxml2/'_/'_");
+ Console.println( parsedxml2/'_/'_ );
+ Console.println( "\nparsedxml2/'_/'author");
+ Console.println( parsedxml2/'_/'author );
+ Console.println( "\nparsedxml2/'_/'_/'author");
+ Console.println( parsedxml2/'_/'_/'author );
+ /* List('author(Text("Peter Buneman")),
+ 'author(Text("Dan Suciu")),
+ 'author(Text("John Mitchell")))); */
+
+ Console.println( "\nparsedxml2/#'author");
+ Console.println( parsedxml2/#'author );
+
+ Console.println( "\nnew NodeList(List(parsedxml2))/#'_");
+ Console.println( new NodeList( List( parsedxml2 ))/#'_ );
+
+ Console.println( "\nnew NodeList(List(parsedxml2))/#'title");
+ Console.println( new NodeList( List( parsedxml2 ))/#'title );
+
+
+}