diff options
author | buraq <buraq@epfl.ch> | 2004-04-14 15:27:54 +0000 |
---|---|---|
committer | buraq <buraq@epfl.ch> | 2004-04-14 15:27:54 +0000 |
commit | b9d0a59aadf4937c1e39212413f833107d9eb9dc (patch) | |
tree | 208115defb53e1b8e4621f8c6fed48d5a82ec0e9 /sources | |
parent | c4098caf3319a3f749f88b1b0ff68c1a02bfb0c2 (diff) | |
download | scala-b9d0a59aadf4937c1e39212413f833107d9eb9dc.tar.gz scala-b9d0a59aadf4937c1e39212413f833107d9eb9dc.tar.bz2 scala-b9d0a59aadf4937c1e39212413f833107d9eb9dc.zip |
*** empty log message ***
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scala/xml/Elem.scala | 3 | ||||
-rw-r--r-- | sources/scala/xml/Node.scala | 34 |
2 files changed, 14 insertions, 23 deletions
diff --git a/sources/scala/xml/Elem.scala b/sources/scala/xml/Elem.scala index fc224f0d84..e3b2bb571e 100644 --- a/sources/scala/xml/Elem.scala +++ b/sources/scala/xml/Elem.scala @@ -6,7 +6,8 @@ case class Elem( label:String, child:Node* ) extends Node with Similarity { def similar( x:Any ) = { x match { - case that:Node => (label == that.label) && child.similar( that.child ) + case that:Node => (label == that.label) && child.equals( that.child ) + // sameElements case _ => false; } } diff --git a/sources/scala/xml/Node.scala b/sources/scala/xml/Node.scala index 00c5d88549..caa5dd6e4a 100644 --- a/sources/scala/xml/Node.scala +++ b/sources/scala/xml/Node.scala @@ -44,8 +44,8 @@ trait Node { case that:Node => //Console.print("(Node)"); that.label == this.label && - that.attribute.similar( this.attribute ) && - that.child.similar( this.child ) + that.attribute.sameElements( this.attribute ) && + that.child.sameElements( this.child ) // sameElements case _ => false } @@ -55,18 +55,17 @@ trait Node { */ def \(that:Symbol): NodeSeq = { new NodeSeq({ - val iter = child.elements; - that.name match { + that.name match { - case "_" => iter.toList; - case _ => - var res:List[Node] = Nil; - for( val x <- child.elements; x.label == that.name ) { - res = x::res; - } - res.reverse - } - }); + case "_" => child.toList; + case _ => + var res:List[Node] = Nil; + for( val x <- child.elements; x.label == that.name ) { + res = x::res; + } + res.reverse + } + }); } /** projection function. Similar to XPath, use this \\ 'foo to filter @@ -79,15 +78,6 @@ trait Node { case "_" => this.descendant_or_self; case _ => this.descendant_or_self.asInstanceOf[List[Node]]. filter( x => x.label == that.name ); - /* - val res = new AppendBuffer[Node](); - if( this.label == that.name ) - res.append( this ); - res.append( this.child.elements.flatMap { - x => //x.\\(that).elements - }.toSeq); - res.toList - */ }) } |