summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/xml/PrettyPrinter.scala13
-rw-r--r--src/library/scala/xml/XML.scala8
2 files changed, 17 insertions, 4 deletions
diff --git a/src/library/scala/xml/PrettyPrinter.scala b/src/library/scala/xml/PrettyPrinter.scala
index c612edd2e7..ce906a56b4 100644
--- a/src/library/scala/xml/PrettyPrinter.scala
+++ b/src/library/scala/xml/PrettyPrinter.scala
@@ -149,9 +149,16 @@ class PrettyPrinter( width:Int, step:Int ) {
case _:Atom[Any] | _:Molecule[Any] | _:Comment | _:EntityRef | _:ProcInstr =>
makeBox( ind, node.toString().trim() );
- case _:Node =>
- val test = { val sb = new StringBuffer(); Utility.toXML(node, pscope, sb, false);
- val tb = TextBuffer.fromString(sb.toString()); tb.toText(0)._data};
+ case _ =>
+ val test = {
+ val sb = new StringBuffer();
+ Utility.toXML(node, pscope, sb, false);
+ val tb = if(node.attribute(XML.namespace, XML.space) == XML.preserve)
+ sb.toString();
+ else
+ TextBuffer.fromString(sb.toString());
+ tb.toText(0)._data
+ };
if(childrenAreLeaves(node) && fits(test)) {
makeBox( ind, test );
} else {
diff --git a/src/library/scala/xml/XML.scala b/src/library/scala/xml/XML.scala
index 739eba1f5b..fa46392a11 100644
--- a/src/library/scala/xml/XML.scala
+++ b/src/library/scala/xml/XML.scala
@@ -15,11 +15,17 @@ package scala.xml;
import scala.xml.parsing.NoBindingFactoryAdapter ;
import org.xml.sax.InputSource;
-/** functions to load and save XML elements. use this when data binding is not
+/** constants, and functions to load and save XML elements. use this when data binding is not
** desired, i.e. when XML is handled using Symbol nodes
**/
object XML {
+ val prefix = "xml"
+ val namespace = "http://www.w3.org/XML/1998/namespace"
+ val preserve = "preserve";
+ val space = "space";
+ val lang = "lang";
+
import java.io._ ;
// functions for generic xml loading, saving