diff options
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/xml/PrettyPrinter.scala | 9 | ||||
-rw-r--r-- | src/library/scala/xml/dtd/ElementValidator.scala | 2 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/library/scala/xml/PrettyPrinter.scala b/src/library/scala/xml/PrettyPrinter.scala index 2b8c50088e..56e3a2db1b 100644 --- a/src/library/scala/xml/PrettyPrinter.scala +++ b/src/library/scala/xml/PrettyPrinter.scala @@ -153,6 +153,9 @@ class PrettyPrinter( width:Int, step:Int ) { protected def fits(test: String) = test.length < width - cur + private def doPreserve(node: Node) = + node.attribute(XML.namespace, XML.space).map(_.toString == XML.preserve) getOrElse false + /** @param tail: what we'd like to sqeeze in */ protected def traverse(node: Node, pscope: NamespaceBinding, ind: Int): Unit = node match { @@ -166,10 +169,8 @@ class PrettyPrinter( width:Int, step:Int ) { val test = { val sb = new StringBuilder() Utility.toXML(node, pscope, sb, false) - if (node.attribute("http://www.w3.org/XML/1998/namespace", "space") == "preserve") - sb.toString() - else - TextBuffer.fromString(sb.toString()).toText(0)._data + if (doPreserve(node)) sb.toString + else TextBuffer.fromString(sb.toString()).toText(0)._data } if (childrenAreLeaves(node) && fits(test)) { makeBox(ind, test) diff --git a/src/library/scala/xml/dtd/ElementValidator.scala b/src/library/scala/xml/dtd/ElementValidator.scala index bbee01aa97..de969cab64 100644 --- a/src/library/scala/xml/dtd/ElementValidator.scala +++ b/src/library/scala/xml/dtd/ElementValidator.scala @@ -88,7 +88,7 @@ class ElementValidator() extends Function1[Node,Boolean] { //Console.println("exc"); exc = fromUndefinedAttribute( attr.key ) :: exc; - case AttrDecl(_, tpe, DEFAULT(true, fixedValue)) if(attr.value != fixedValue) => + case AttrDecl(_, tpe, DEFAULT(true, fixedValue)) if attr.value.toString != fixedValue => exc = fromFixedAttribute( attr.key, fixedValue, attr.value.toString) :: exc; case s => |