diff --git a/src/main/scala/scala/xml/PrettyPrinter.scala b/src/main/scala/scala/xml/PrettyPrinter.scala index 515c9c088..a175f1df2 100755 --- a/src/main/scala/scala/xml/PrettyPrinter.scala +++ b/src/main/scala/scala/xml/PrettyPrinter.scala @@ -244,7 +244,7 @@ class PrettyPrinter(width: Int, step: Int) { * @param pscope the namespace to prefix mapping * @return the formatted string */ - def format(n: Node, pscope: NamespaceBinding = null): String = + def format(n: Node, pscope: NamespaceBinding = TopScope): String = sbToString(format(n, pscope, _)) /** diff --git a/src/test/scala/scala/xml/XMLTest.scala b/src/test/scala/scala/xml/XMLTest.scala index b86f2c9ef..01431baf1 100644 --- a/src/test/scala/scala/xml/XMLTest.scala +++ b/src/test/scala/scala/xml/XMLTest.scala @@ -824,4 +824,16 @@ expected closing tag of foo } } + @UnitTest + def issue28: Unit = { + val x = + // val ns = new NamespaceBinding("x", "gaga", sc) + // val x = Elem("x", "foo", e, ns) + val pp = new xml.PrettyPrinter(80, 2) + // This assertion passed + assertEquals("""""", x.toString) + // This was the bug, producing an errant xmlns attribute + assertEquals("""""", pp.format(x)) + } + }