diff --git a/src/main/scala/scala/xml/PrettyPrinter.scala b/src/main/scala/scala/xml/PrettyPrinter.scala index a175f1df2..4f1024e1a 100755 --- a/src/main/scala/scala/xml/PrettyPrinter.scala +++ b/src/main/scala/scala/xml/PrettyPrinter.scala @@ -203,7 +203,7 @@ class PrettyPrinter(width: Int, step: Int) { * @param sb the stringbuffer to append to */ def format(n: Node, sb: StringBuilder) { // entry point - format(n, null, sb) + format(n, TopScope, sb) } def format(n: Node, pscope: NamespaceBinding, sb: StringBuilder) { // entry point @@ -253,7 +253,7 @@ class PrettyPrinter(width: Int, step: Int) { * @param nodes the sequence of nodes to be serialized * @param pscope the namespace to prefix mapping */ - def formatNodes(nodes: Seq[Node], pscope: NamespaceBinding = null): String = + def formatNodes(nodes: Seq[Node], pscope: NamespaceBinding = TopScope): String = sbToString(formatNodes(nodes, pscope, _)) /** diff --git a/src/test/scala/scala/xml/XMLTest.scala b/src/test/scala/scala/xml/XMLTest.scala index 01431baf1..23c143396 100644 --- a/src/test/scala/scala/xml/XMLTest.scala +++ b/src/test/scala/scala/xml/XMLTest.scala @@ -836,4 +836,25 @@ expected closing tag of foo assertEquals("""""", pp.format(x)) } + @UnitTest + def nodeSeqNs: Unit = { + val x = { + + } + val pp = new PrettyPrinter(80, 2) + val expected = """""" + assertEquals(expected, pp.formatNodes(x)) + } + + @UnitTest + def nodeStringBuilder: Unit = { + val x = { + + } + val pp = new PrettyPrinter(80, 2) + val expected = """""" + val sb = new StringBuilder + pp.format(x, sb) + assertEquals(expected, sb.toString) + } }