Skip to content

Commit da14049

Browse files
committed
Fix default namespace in PrettyPrinter.formatNodes
1 parent 1498d97 commit da14049

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/main/scala/scala/xml/PrettyPrinter.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ class PrettyPrinter(width: Int, step: Int) {
253253
* @param nodes the sequence of nodes to be serialized
254254
* @param pscope the namespace to prefix mapping
255255
*/
256-
def formatNodes(nodes: Seq[Node], pscope: NamespaceBinding = null): String =
256+
def formatNodes(nodes: Seq[Node], pscope: NamespaceBinding = TopScope): String =
257257
sbToString(formatNodes(nodes, pscope, _))
258258

259259
/**

src/test/scala/scala/xml/XMLTest.scala

+10
Original file line numberDiff line numberDiff line change
@@ -836,4 +836,14 @@ expected closing tag of foo
836836
assertEquals("""<x:foo xmlns:x="gaga"/>""", pp.format(x))
837837
}
838838

839+
@UnitTest
840+
def nodeSeqNs: Unit = {
841+
val x = {
842+
<x:foo xmlns:x="abc"/><y:bar xmlns:y="def"/>
843+
}
844+
val pp = new PrettyPrinter(80, 2)
845+
val expected = """<x:foo xmlns:x="abc"/><y:bar xmlns:y="def"/>"""
846+
assertEquals(expected, pp.formatNodes(x))
847+
}
848+
839849
}

0 commit comments

Comments
 (0)