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

Feature Request: Integrate/Add XML Linting #140

Closed
JLLeitschuh opened this issue Sep 7, 2017 · 14 comments
Closed

Feature Request: Integrate/Add XML Linting #140

JLLeitschuh opened this issue Sep 7, 2017 · 14 comments
Assignees

Comments

@JLLeitschuh
Copy link
Member

Many projects have large XML files (for spring or even for checkstyle configuration).

I haven't found a good java based XML formatter but if anyone knows of one it would be great to add.

@nedtwigg
Copy link
Member

nedtwigg commented Sep 8, 2017

I'm not aware of one, but you could make one by reading an XML file into memory, then writing it back out.

@fvgh
Copy link
Member

fvgh commented Sep 10, 2017

I think just reading and writing back is not really so easy.
For once, I would expect some formatting options (tabs, line length, num. attributes per row, ...). Not to forget good formatting of comments an opt-out for for PCDATA.
Next thing would be the robustness. This includes the handling of unfinished XML documents and the treatment of invalid characters (zero bytes and so forth).
I started long time ago with the Eclipse XML formatter. For several reasons I postponed it. One drawback is of course the size, due to its dependencies on the Eclipse framework. But its configuration options are good and its robustness is according to my previous tests flawless.
I never came across a good platform independent alternative.
If nobody has a better alternative or sees other drawbacks, I would volunteer to finish my first attempts on this subject. I was quite busy in the past months, but I should now be able to finalize this work within the next 3 weeks.

@nedtwigg
Copy link
Member

Just an aside, eclipse is working on publishing its releases on maven. Right now we have _ext/eclipse-jdt and _ext/greclipse. I'd be happy to add _ext/eclipse-xml, but those projects are a lot more work than cases where we can just add a dependency to lib-extra. Once eclipse is on mavencentral, it should get a lot easier. If you build _ext/eclipse-xml to scratch your own itch, I'm all for it! But just a heads up that it might be easier in a month or two (no idea when they'll finish).

@fvgh
Copy link
Member

fvgh commented Sep 10, 2017

We could already start with org.eclipse 3.6, which is available on maven central, couldn't we?
I started off with it, but found that there is not a reliable update in process.
That was one reason why I postponed it and the other one was the remaining amount of dependencies (the XML formatter seems to have been a sidekick of the ANT script editor).
Hence I am not sure whether the dependency to lib-extra is really a good idea. Leaving greclipse aside for a moment, sine I am not so sure how the development will continue, we would in the first place support Eclipse for Java and XML. But for users not interested in Eclipse formatters, it might be annoying to download all the dependencies.
My idea was to keep the _ext approach (but without building fat jars) and continue load them (and their dependencies) on demand.

@nedtwigg
Copy link
Member

Good plan!

@fvgh fvgh self-assigned this Sep 10, 2017
@fvgh
Copy link
Member

fvgh commented Sep 24, 2017

@nedtwigg I am afraid my memory on the subject was not very complete. I assumed that the ANT XML and its XmlFormatter is the right choice. But actually the WTP-WST DefaultXMLPartitionFormatter is the one with all the advanced configuration options.
Whereas ANT XML is available in Maven Central and working, for the WST only an old version is provided and most of its dependencies can not be resolved.
I think from the programming point, there is not that much overhead if I use the P2 approach.
I definitely think we should aim for the WST. I am not sure about the schedule of the Eclipse maven release and most of all I am not sure how fast all plugins will apply the approach.
So if you are happy to publish another "fat-jar" for Spotless, I would provide it.

@nedtwigg
Copy link
Member

Publishing another fat-jar sounds great.

@mores
Copy link

mores commented Jul 24, 2018

I am looking to format all JSF code files ( *.xhtml ) with a consistent indent using either tabs or spaces. Does that fall under this request ?

@fvgh
Copy link
Member

fvgh commented Jul 25, 2018

Yes. The Eclipse WTP can do that.

@mores
Copy link

mores commented Jul 25, 2018

What is the holdup on merging in #241 ? I assume that is what is needed for me to format my JSF *.xhtml using spotless.

@fvgh
Copy link
Member

fvgh commented Aug 6, 2018

@mores Sorry that I cannot spend as much time on the project as I would like to...
About your question: The XML support has a long history. Basically we found that all Eclipse formatters do not work properly without an underlying OSGI infrastructure. I provided a slim OSGI implementation stripping out everything that is not required for formatting. But there are still some issues to be solved for Spotless integration. I think it will take another 2-3 weeks till everything is sorted out...

@fvgh
Copy link
Member

fvgh commented Sep 4, 2018

Provided an example for XML formatting. Feedback is welcome.

@fvgh fvgh mentioned this issue Sep 4, 2018
@fvgh
Copy link
Member

fvgh commented Sep 15, 2018

Fixed with #293.

@fvgh fvgh closed this as completed Sep 15, 2018
@Bikraji
Copy link

Bikraji commented Jun 16, 2024

Guys, where can I find the configurations or examples for xml formatting.

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

5 participants