Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scala.xml.PrettyPrinter changes attribute values by removing multiple whitespace #3286

Closed
scabug opened this issue Apr 13, 2010 · 2 comments
Closed

Comments

@scabug
Copy link

scabug commented Apr 13, 2010

scala.xml.PrettyPrinter seems to change the values of attributes in some instances, by replacing repeated white space. Not always, though.

Notice in the example below how

<babba orth="B    A"/>

turns into

<babba orth="B A"></babba>

after PrettyPrinting:

Welcome to Scala version 2.8.0.Beta1-prerelease (Java HotSpot(TM) Client VM, Java 1.6.0_16).
Type in expressions to have them evaluated.
Type :help for more information.

scala> <abba orth="A    B"><babba orth="B    A"/></abba>
res0: scala.xml.Elem = <abba orth="A    B"><babba orth="B    A"></babba></abba>

scala> new xml.PrettyPrinter(200, 2)                    
res1: scala.xml.PrettyPrinter = scala.xml.PrettyPrinter@1886a34

scala> res1.format(res0)                                
res2: String = 
<abba orth="A    B">
  <babba orth="B A"></babba>
</abba>

Crazy width and indentation nukes the multiple whitespaces in the attributes of both nodes:

scala> new xml.PrettyPrinter(2, 20)  
res8: scala.xml.PrettyPrinter = scala.xml.PrettyPrinter@1f0f0c8

scala> res8.format(res0)           
res9: String = 
<abba orth="A B"><babba orth="B A"></babba></abba>

We ran into this problem when checking whether some XML attributes were identical to the original input.

I guess you should be able to trust Pretty Mr Printer not to change the values of any attributes?

Since I'm far from an expert in XML, I might be wrong about what is the correct way of treating whitespace inside attribute values. Sorry if this already works according to the XML specs.

Kind regards,

/nikolaj lindberg

@scabug
Copy link
Author

scabug commented Apr 13, 2010

Imported From: https://issues.scala-lang.org/browse/SI-3286?orig=1
Reporter: nikolaj lindberg (nikolaj)

@scabug
Copy link
Author

scabug commented Jul 17, 2015

@SethTisue said:
The scala-xml library is now community-maintained. Issues with it are now tracked at https://github.com/scala/scala-xml/issues instead of here in the Scala JIRA.

Interested community members: if you consider this issue significant, feel free to open a new issue for it on GitHub, with links in both directions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant