diff options
-rw-r--r-- | src/library/scala/xml/Utility.scala | 12 | ||||
-rw-r--r-- | test/files/jvm/xml02.scala | 15 |
2 files changed, 17 insertions, 10 deletions
diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala index 3f3ac9d6e8..b44614fbf9 100644 --- a/src/library/scala/xml/Utility.scala +++ b/src/library/scala/xml/Utility.scala @@ -202,7 +202,7 @@ object Utility extends AnyRef with parsing.TokenTests { if (x.attributes ne null) x.attributes.toString(sb) x.scope.toString(sb, pscope) sb.append('>') - sequenceToXML(x.child, pscope, sb, stripComment) + sequenceToXML(x.child, x.scope, sb, stripComment) sb.append("</") x.nameToString(sb) sb.append('>') @@ -217,22 +217,22 @@ object Utility extends AnyRef with parsing.TokenTests { */ def sequenceToXML(children: Seq[Node], pscope: NamespaceBinding, sb: StringBuilder, stripComment: Boolean) { - if (children.isEmpty) + if (children.isEmpty) { return - else if (children forall { + } else if (children forall { case y: Atom[_] => !y.isInstanceOf[Text] case _ => false }) { // add space val it = children.elements val f = it.next - toXML(f, f.scope, sb, stripComment) + toXML(f, pscope, sb, stripComment) while (it.hasNext) { val x = it.next sb.append(' ') - toXML(x, x.scope, sb, stripComment) + toXML(x, pscope, sb, stripComment) } } else { - for (c <- children) toXML(c, c.scope, sb, stripComment) + for (c <- children) toXML(c, pscope, sb, stripComment) } } diff --git a/test/files/jvm/xml02.scala b/test/files/jvm/xml02.scala index 143d125a7f..2eabaf1fbc 100644 --- a/test/files/jvm/xml02.scala +++ b/test/files/jvm/xml02.scala @@ -15,7 +15,7 @@ object Test extends TestConsoleMain { val bx = <hello foo="bar&x"></hello> - class XmlEx extends TestCase("attributes") with Assert { + object XmlEx extends TestCase("attributes") with Assert { override def runTest = { assertTrue("@one", ax \ "@foo" == "bar") // uses NodeSeq.view! @@ -27,7 +27,7 @@ object Test extends TestConsoleMain { } } - class XmlPat extends TestCase("patterns") with Assert { + object XmlPat extends TestCase("patterns") with Assert { override def runTest = { assertTrue(<hello/> match { case <hello/> => true; case _ => false; }) assertTrue(<x:ga xmlns:x="z"/> match { case <x:ga/> => true; case _ => false; }); @@ -36,8 +36,15 @@ object Test extends TestConsoleMain { } } + object DodgyNamespace extends TestCase("DodgyNamespace") with Assert { + override def runTest = { + val x = <flog xmlns:ee="http://ee.com"><foo xmlns:dog="http://dog.com"><dog:cat/></foo></flog> + assertTrue(x.toString.contains("xmlns:dog=\"http://dog.com\"")); + } + } def suite = new TestSuite( - new XmlEx, - new XmlPat + XmlEx, + XmlPat, + DodgyNamespace ) } |