summaryrefslogtreecommitdiff
path: root/test/files/jvm
diff options
context:
space:
mode:
authorBurak Emir <emir@epfl.ch>2008-01-29 12:01:45 +0000
committerBurak Emir <emir@epfl.ch>2008-01-29 12:01:45 +0000
commitd855e454426fb782730542f84c01f3bfd9d50f7d (patch)
tree906173179c0698b603ac55b08ee118de3851f3af /test/files/jvm
parent0799efb89361220930c4009c78fe6ebeaf54a3c8 (diff)
downloadscala-d855e454426fb782730542f84c01f3bfd9d50f7d.tar.gz
scala-d855e454426fb782730542f84c01f3bfd9d50f7d.tar.bz2
scala-d855e454426fb782730542f84c01f3bfd9d50f7d.zip
demo of entity handling
Diffstat (limited to 'test/files/jvm')
-rw-r--r--test/files/jvm/xml03syntax.scala16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/files/jvm/xml03syntax.scala b/test/files/jvm/xml03syntax.scala
index fab139e5e8..9c1cee19e1 100644
--- a/test/files/jvm/xml03syntax.scala
+++ b/test/files/jvm/xml03syntax.scala
@@ -64,6 +64,21 @@ object Test extends AnyRef with Assert {
println
}
+ // this demonstrates how to handle entities
+ val s = io.Source.fromString("<a>&nbsp;</a>")
+ object parser extends xml.parsing.ConstructingParser(s, false /*ignore ws*/) {
+ override def replacementText(entityName: String): io.Source = {
+ entityName match {
+ case "nbsp" => io.Source.fromString("\u0160");
+ case _ => super.replacementText(entityName);
+ }
+ }
+ nextch; // !!important, to initialize the parser
+ }
+ val parsed = parser.element(TopScope) // parse the source as element
+ // alternatively, we could call document()
+ parsed
+
/** see SVN r13821 (emir): support for <elem key={x:Option[Seq[Node]]} />,
* so that Options can be used for optional attributes.
*/
@@ -75,6 +90,7 @@ object Test extends AnyRef with Assert {
val x2: Option[Seq[Node]] = None
val n2 = <elem key={x2} />;
println("node="+n2+", key="+n2.attribute("key"))
+>>>>>>> .r13822
}
}