diff options
-rw-r--r-- | config/list/library.lst | 2 | ||||
-rw-r--r-- | sources/scala/xml/NodeSeq.scala | 4 | ||||
-rw-r--r-- | sources/scala/xml/NodeTraverser.scala | 19 | ||||
-rw-r--r-- | sources/scala/xml/parsing/MarkupHandler.scala | 5 | ||||
-rw-r--r-- | sources/scala/xml/parsing/MarkupParser.scala | 3 |
5 files changed, 28 insertions, 5 deletions
diff --git a/config/list/library.lst b/config/list/library.lst index 5c5aac872b..85b3ffda7c 100644 --- a/config/list/library.lst +++ b/config/list/library.lst @@ -225,7 +225,7 @@ xml/Node.scala xml/NodeBuffer.scala xml/NodeSeq.scala xml/Null.scala -#xml/NodeTraverser.scala +xml/NodeTraverser.scala xml/Parsing.scala xml/PrettyPrinter.scala xml/PrefixedAttribute.scala diff --git a/sources/scala/xml/NodeSeq.scala b/sources/scala/xml/NodeSeq.scala index 56a72b30d8..56ab68a130 100644 --- a/sources/scala/xml/NodeSeq.scala +++ b/sources/scala/xml/NodeSeq.scala @@ -11,6 +11,10 @@ package scala.xml ; object NodeSeq { final val Empty = new NodeSeq { def theSeq = Nil; } + def fromSeq(s:Seq[Node]):NodeSeq = new NodeSeq { + def theSeq = s; + } + def view(s:Seq[Node]):NodeSeq = fromSeq(s); } /** a wrapper around Seq[Node] that adds XPath and comprehension methods */ diff --git a/sources/scala/xml/NodeTraverser.scala b/sources/scala/xml/NodeTraverser.scala new file mode 100644 index 0000000000..e46adff393 --- /dev/null +++ b/sources/scala/xml/NodeTraverser.scala @@ -0,0 +1,19 @@ +package scala.xml; + +import parsing.MarkupHandler; + +trait NodeTraverser extends MarkupHandler { + + def traverse(n:Node): Unit = n match { + case x:ProcInstr => procInstr(0, x.target, x.text) + case x:Comment => comment(0, x.text) + case x:Text => text(0, x.data) + case x:EntityRef => entityRef(0, x.entityName) + case _ => + elemStart(0, n.prefix, n.label, n.attributes, n.scope); + for(val m <- n.child) + traverse(m); + elem(0, n.prefix, n.label, n.attributes, n.scope, NodeSeq.fromSeq(n.child)); + elemEnd(0, n.prefix, n.label); + } +} diff --git a/sources/scala/xml/parsing/MarkupHandler.scala b/sources/scala/xml/parsing/MarkupHandler.scala index 74ced1b666..21710759d7 100644 --- a/sources/scala/xml/parsing/MarkupHandler.scala +++ b/sources/scala/xml/parsing/MarkupHandler.scala @@ -21,7 +21,7 @@ import scala.util.logging._; * @todo can we ignore more entity declarations (i.e. those with extIDs)? * @todo expanding entity references */ -abstract class MarkupHandler extends AnyRef with Logged with ConsoleLogger { +abstract class MarkupHandler extends AnyRef with Logged { // impl. of Logged //def log(msg:String) = {} @@ -29,9 +29,6 @@ abstract class MarkupHandler extends AnyRef with Logged with ConsoleLogger { /** returns true is this markup handler is validing */ val isValidating: Boolean = false; - /** if true, does not remove surplus whitespace */ - val preserveWS: Boolean; - var decls: List[Decl] = Nil; var ent: Map[String, EntityDecl] = new HashMap[String, EntityDecl](); diff --git a/sources/scala/xml/parsing/MarkupParser.scala b/sources/scala/xml/parsing/MarkupParser.scala index a9bd9d34f1..524c029475 100644 --- a/sources/scala/xml/parsing/MarkupParser.scala +++ b/sources/scala/xml/parsing/MarkupParser.scala @@ -27,6 +27,9 @@ abstract class MarkupParser: (MarkupParser with MarkupHandler) extends AnyRef wi val input: Source; + /** if true, does not remove surplus whitespace */ + val preserveWS: Boolean; + def externalSource(systemLiteral: String): Source; // |