diff options
author | Burak Emir <emir@epfl.ch> | 2006-03-25 14:15:08 +0000 |
---|---|---|
committer | Burak Emir <emir@epfl.ch> | 2006-03-25 14:15:08 +0000 |
commit | 7d8791d5c5153a5fc1088b79e9fc44721e1961d1 (patch) | |
tree | daa357bfb55acfdaf3919a9e587c5e6388b1f0d8 /src/library | |
parent | 705747005fd5ff524a8766edf82c44efd19dd1c6 (diff) | |
download | scala-7d8791d5c5153a5fc1088b79e9fc44721e1961d1.tar.gz scala-7d8791d5c5153a5fc1088b79e9fc44721e1961d1.tar.bz2 scala-7d8791d5c5153a5fc1088b79e9fc44721e1961d1.zip |
handle xml:space in printing
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/xml/PrettyPrinter.scala | 13 | ||||
-rw-r--r-- | src/library/scala/xml/XML.scala | 8 |
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 |