summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBurak Emir <emir@epfl.ch>2006-03-25 14:15:08 +0000
committerBurak Emir <emir@epfl.ch>2006-03-25 14:15:08 +0000
commit7d8791d5c5153a5fc1088b79e9fc44721e1961d1 (patch)
treedaa357bfb55acfdaf3919a9e587c5e6388b1f0d8 /src
parent705747005fd5ff524a8766edf82c44efd19dd1c6 (diff)
downloadscala-7d8791d5c5153a5fc1088b79e9fc44721e1961d1.tar.gz
scala-7d8791d5c5153a5fc1088b79e9fc44721e1961d1.tar.bz2
scala-7d8791d5c5153a5fc1088b79e9fc44721e1961d1.zip
handle xml:space in printing
Diffstat (limited to 'src')
-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