summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorburaq <buraq@epfl.ch>2004-03-11 13:51:00 +0000
committerburaq <buraq@epfl.ch>2004-03-11 13:51:00 +0000
commitddc26de6b23f06cbc3dbba5dadf3fa74eccc9ba7 (patch)
treeb743a5f0b012c2c64f854883ee72022d4481d17f /sources
parent952ee03cca851166daa6418aae2f0ee23a27d28f (diff)
downloadscala-ddc26de6b23f06cbc3dbba5dadf3fa74eccc9ba7.tar.gz
scala-ddc26de6b23f06cbc3dbba5dadf3fa74eccc9ba7.tar.bz2
scala-ddc26de6b23f06cbc3dbba5dadf3fa74eccc9ba7.zip
new class for representing XML
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/xml/Elem.scala39
1 files changed, 39 insertions, 0 deletions
diff --git a/sources/scala/xml/Elem.scala b/sources/scala/xml/Elem.scala
new file mode 100644
index 0000000000..950a85f49f
--- /dev/null
+++ b/sources/scala/xml/Elem.scala
@@ -0,0 +1,39 @@
+package scala.xml ;
+
+import scala.collection.immutable.{Map,ListMap} ;
+
+case class Elem( name:String, children:Node* ) extends AttributedNode {
+
+ /** Returns the symbol name as a string.
+ */
+ def label:String = name;
+
+ /** Returns the list of children of this symbol.
+ def children: NodeSeq = new NodeSeq( List.fromIterator(
+ elems.elements map ( x => x match {
+ case n:Node => n;
+ case _ => Text(x.toString());
+ })));
+ */
+
+ /** Returns a map representing the attributes of this node.
+ */
+ def attributes: Map[String, String] = ListMap.Empty;
+
+ /** returns a new symbol with updated attributes
+ */
+ final def %(attrs: List[Pair[String, String]]) =
+ new Elem( name, children:_* ) {
+ val themap = Elem.this.attributes.incl( attrs );
+ override def attributes = themap;
+ };
+
+ /** returns a new symbol with updated attribute
+ */
+ final def %(attr: Pair[String, String]) =
+ new Elem( name, children:_* ) {
+ val themap = Elem.this.attributes.incl( attr );
+ override def attributes = themap;
+ };
+
+}