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.Utility.trim() doesn't properly handle adjacent Text nodes #73

Closed
mbeckerle opened this issue Jul 29, 2015 · 0 comments · Fixed by #113
Closed

scala.xml.Utility.trim() doesn't properly handle adjacent Text nodes #73

mbeckerle opened this issue Jul 29, 2015 · 0 comments · Fixed by #113
Milestone

Comments

@mbeckerle
Copy link

This issue migrated from https://issues.scala-lang.org/browse/SI-3062.

Please note: There is discussion there which is not reproduced here clarifying the needed algorithmic change.

Reproduced here is just the original description of the issue.

if Text("My name is ") followed by Text("Harry") the space following the word "is" will be incorrectly trimmed. Adjacent Text nodes need to be combined before whitespace is removed.

scala> import scala.xml._
import scala.xml._

scala> <div>{Text("My name is ")}{Text("Harry")}</div>
res0: scala.xml.Elem = <div>My name is Harry</div>

scala> Utility.trim(res0)
res1: scala.xml.Node = <div>My name isHarry</div>

This is important when modifying XML and then trimming it. For example we might start with <div>My name is <user:name/></div> and then replace the <user:name/> Elem with "Harry" thus leading to the adjacent Text nodes.

ashawley added a commit to ashawley/scala-xml that referenced this issue Sep 28, 2015
EdgeCaseBerg added a commit to EdgeCaseBerg/scala-xml that referenced this issue Oct 6, 2016
EdgeCaseBerg added a commit to EdgeCaseBerg/scala-xml that referenced this issue Oct 6, 2016
EdgeCaseBerg added a commit to EdgeCaseBerg/scala-xml that referenced this issue Feb 11, 2017
EdgeCaseBerg added a commit to EdgeCaseBerg/scala-xml that referenced this issue Feb 11, 2017
EdgeCaseBerg added a commit to EdgeCaseBerg/scala-xml that referenced this issue Nov 6, 2017
EdgeCaseBerg added a commit to EdgeCaseBerg/scala-xml that referenced this issue Nov 6, 2017
EdgeCaseBerg added a commit to EdgeCaseBerg/scala-xml that referenced this issue Nov 7, 2017
EdgeCaseBerg added a commit to EdgeCaseBerg/scala-xml that referenced this issue Nov 7, 2017
EdgeCaseBerg added a commit to EdgeCaseBerg/scala-xml that referenced this issue Apr 24, 2018
EdgeCaseBerg added a commit to EdgeCaseBerg/scala-xml that referenced this issue Apr 24, 2018
EdgeCaseBerg added a commit to EdgeCaseBerg/scala-xml that referenced this issue Apr 24, 2018
EdgeCaseBerg added a commit to EdgeCaseBerg/scala-xml that referenced this issue Apr 25, 2018
EdgeCaseBerg added a commit to EdgeCaseBerg/scala-xml that referenced this issue Apr 25, 2018
ashawley added a commit that referenced this issue May 24, 2018
Utility.trim collapse whitespace for adjacent text nodes #73
@SethTisue SethTisue added this to the 1.1.1 milestone May 25, 2018
@ashawley ashawley mentioned this issue Aug 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants