Community
Participate
Working Groups
I have the following XML line (perhaps one of the most common lines of XML in all of Java development)---the opening tag of the root element of a Maven POM: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> In the XML formatter I set the line width to 160. I reformat and get... the exact same thing. No wrapping whatsoever: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> I go into the settings and turn on "Split multiple attributes each on a new line" and reformat. I get this: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> That's not correct either! I don't want _everything_ wrapped. I just want it wrapped at 160 columns, like this: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> If I had a line of Java code like this in an interface: public void foo(@Nonnull final int foo, @Nonnull final int bar, @Nonnull final int example, @Nonnull final int test, @Nonnull final int foobar, @Nonnull final int fooExample, @Nonnull final int barExample); I wouldn't want to have to choose between that one lone line, or every parameter wrapped: public void foo(@Nonnull final int foo, @Nonnull final int bar, @Nonnull final int example, @Nonnull final int test, @Nonnull final int foobar, @Nonnull final int fooExample, @Nonnull final int barExample); public void foo( @Nonnull final int foo, @Nonnull final int bar, @Nonnull final int example, @Nonnull final int test, @Nonnull final int foobar, @Nonnull final int fooExample, @Nonnull final int barExample); Of course not. I would expect wrapping at 160 columns as I requested: public void foo(@Nonnull final int foo, @Nonnull final int bar, @Nonnull final int example, @Nonnull final int test, @Nonnull final int foobar, @Nonnull final int fooExample, @Nonnull final int barExample); And that's what I get in the Java formatter! But I don't get that in the XML formatter; I have to chose between a long line and every-attribute-wrapped. Please fix the XML formatter to only wrap an attribute at or before the number of columns, as I requested in the settings, and similar to how the Java formatter works.
Even worse, if I manually split at 160 columns: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> Then the formatter _joins_ the lines---even though I have the settings to wrap at 160 columns! So in this case the formatter modifies my XML to make it _less_ compliant with the formatting configuration.
P.S. I could swear this is new behavior, because I have a lot of Maven POMs that are nicely formatted, but I'm not sure. Anyway, this current formatter behavior is going to screw up so many files and add unnecessary Git commits.
1) Which version of WTP is this? 2) The xsi:schemaLocation value contains a line feed. Changing that would change the value.
> The xsi:schemaLocation value contains a line feed. Changing that would change the value. Actually not really. Are you familiar with XML attribute normalization? This would not change the parsed DOM at all. See https://www.w3.org/TR/REC-xml/#AVNormalize . So this would only be a source code syntax change --- which is the whole point of XML source code formatting. Again, I'm pretty sure this is new behavior. Didn't it work before?
And nobody has told me why it will _join_ lines, forcing a line that is longer than the limit!
> Which version of WTP is this? I'm just using the default Eclipse 4.7.0 J2EE package installation.
Created attachment 270002 [details] proposed modification (In reply to Garret Wilson from comment #5) > And nobody has told me why it will _join_ lines, forcing a line that is > longer than the limit! Of all possibilities, a typo in the source that does the calculation.
Path looks good to me.
Committed to master.
Moving to 3.9.3 since didn't make into the 3.9.2 builds.
I still experience faulty behavior on: Eclipse XML Editors and Tools Version: 3.25.0.v202201160258 Eclipse Platform Version: 4.23.0.v20220308-0722 Build id: I20220308-0310 Please reopen the bug.
I confirm that this problem happens again with Eclipse Java with Wild Web Developer tools. Please re-open.
(In reply to Olivier Cailloux from comment #12) > I confirm that this problem happens again with Eclipse Java with Wild Web > Developer tools. Please re-open. This is not where Wild Web Developer, nor where LemminX, bugs get reported. The POM editor is now based on https://github.com/eclipse/lemminx-maven.