Giter Club home page Giter Club logo

xml-formatter's Introduction

xml-formatter's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

xml-formatter's Issues

Rename default branch to "main"

This issue is pretty self-explanatory. Instead of using the name "master", the default branch should be named "main".

This is consistent with the actions taken by major tech leaders, including GitHub itself, to begin phasing out the use of potentially-harmful terminology in tech.

Enable not validating DTD

In some cases, the internet is not available (e.g. corporate proxy). We then encounter the following kind of errors:

Caused by: java.net.UnknownHostException: www.puppycrawl.com
    at java.net.AbstractPlainSocketImpl.connect (AbstractPlainSocketImpl.java:184)
    at java.net.PlainSocketImpl.connect (PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect (SocksSocketImpl.java:392)
    at java.net.Socket.connect (Socket.java:589)
    at java.net.Socket.connect (Socket.java:538)
    at sun.net.NetworkClient.doConnect (NetworkClient.java:180)
    at sun.net.www.http.HttpClient.openServer (HttpClient.java:463)
    at sun.net.www.http.HttpClient.openServer (HttpClient.java:558)
    at sun.net.www.http.HttpClient.<init> (HttpClient.java:242)
    at sun.net.www.http.HttpClient.New (HttpClient.java:339)
    at sun.net.www.http.HttpClient.New (HttpClient.java:357)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient (HttpURLConnection.java:1220)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0 (HttpURLConnection.java:1156)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect (HttpURLConnection.java:1050)
    at sun.net.www.protocol.http.HttpURLConnection.connect (HttpURLConnection.java:984)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0 (HttpURLConnection.java:1564)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream (HttpURLConnection.java:1492)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity (XMLEntityManager.java:647)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity (XMLEntityManager.java:1304)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity (XMLEntityManager.java:1270)
    at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource (XMLDTDScannerImpl.java:264)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch (XMLDocumentScannerImpl.java:1161)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next (XMLDocumentScannerImpl.java:1045)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next (XMLDocumentScannerImpl.java:959)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next (XMLDocumentScannerImpl.java:602)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next (XMLNSDocumentScannerImpl.java:112)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument (XMLDocumentFragmentScannerImpl.java:505)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse (XML11Configuration.java:842)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse (XML11Configuration.java:771)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse (XMLParser.java:141)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse (AbstractSAXParser.java:1213)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse (SAXParserImpl.java:643)
    at net.revelc.code.formatter.xml.lib.XmlDocumentFormatter.validateWellFormedness (XmlDocumentFormatter.java:115)
    at net.revelc.code.formatter.xml.lib.XmlDocumentFormatter.format (XmlDocumentFormatter.java:77)
    at net.revelc.code.formatter.xml.XMLFormatter.doFormat (XMLFormatter.java:54)
    at net.revelc.code.formatter.AbstractCacheableFormatter.formatFile (AbstractCacheableFormatter.java:47)
    at net.revelc.code.formatter.FormatterMojo.doFormatFile (FormatterMojo.java:530)
    at net.revelc.code.formatter.FormatterMojo.formatFile (FormatterMojo.java:464)
    at net.revelc.code.formatter.FormatterMojo.execute (FormatterMojo.java:344)

Would it be possible to add an option to skip XML validation, as suggested in https://stackoverflow.com/questions/4002885/unknown-host-exception-while-parsing-an-xml-file ?

Release 0.3.0

Version needs bumped to 0.3.0

  • as new feature added for deleteBlankLines
  • as comment behavior changed to properly indent
  • as code has been cleaned up
  • block XXE attacks
  • note: Last release of 0.2.2 was in 2021 so its been a while.

This ticket is more of a communication ticket that this is ready for release and before its released allowing team to discuss if anything else was deemed necessary for the above noted changes before release is cut. Expecting to get this into formatter for 2022-12 eclipse support immediately after.

[enhancement] All keeping comments on same line

I have a use case where I put notes beside property versions as comments for next version to upgrade to.

Example

<xml-formatter.version>0.1.0</xml-formatter.version> <!-- TODO: Bump to 0.1.1 -->

It would be nice to be able to keep this on same line. No xml formatter thus far has been able to do so.

Example property for this.

keepCommentsSameLine=true

What occurs now..

<xml-formatter.version>0.1.0</xml-formatter.version>
<!-- TODO: Bump to 0.1.1 -->

Incorrectly formats XML files with DOCTYPE statements

See RENCI-NRIG/orca5#176

Example diff

-<!DOCTYPE project [
-<!ENTITY deps SYSTEM “ant/deps.xml”>
-<!ENTITY core SYSTEM “ant/core.xml”>
-<!ENTITY packages SYSTEM “ant/packages.xml”>
-<!ENTITY tests SYSTEM “ant/tests.xml”>
-]>

+<!DOCTYPE project> 
+<!--ENTITY core SYSTEM “ant/core.xml”--> 
+<!--ENTITY packages SYSTEM “ant/packages.xml”--> 
+<!--ENTITY tests SYSTEM “ant/tests.xml”-->
+ ]&gt;

Multiline comments repeatedly indent

Describe the bug
With certain multi-line comments, indentation happens with every execution on the formatter-maven-plugin.

Versions (OS, Maven, Java, and others, as appropriate):

  • Affected version(s) of this project: 0.3.0
  • OS, Java and Maven version:
Apache Maven 3.9.5 (57804ffe001d7215b5e7bcb531cf83df38f93546)
Maven home: /home/jperkins/apps/maven
Java version: 17.0.8, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-17-openjdk-17.0.8.0.7-1.fc38.x86_64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "6.5.7-200.fc38.x86_64", arch: "amd64", family: "unix"

To Reproduce
Add some generic XML and add a multi-line comment that ends with --> after a tag. Example XML:

<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

    <display-name>RESTEASY-1103</display-name>

    <context-param>
        <param-name>resteasy.document.secure.processing.feature</param-name>
        <param-value>true</param-value>
    </context-param>
    <!--context-param>
                                        <param-name>resteasy.document.secure.disableDTDs</param-name>
                                        <param-value></param-value>
                                    </context-param-->
    <context-param>
        <param-name>resteasy.document.expand.entity.references</param-name>
        <param-value>false</param-value>
    </context-param>

    <servlet>
        <servlet-name>Resteasy</servlet-name>

        <servlet-class>
            org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
        </servlet-class>
        <init-param>
            <param-name>jakarta.ws.rs.Application</param-name>
            <param-value>org.jboss.resteasy.utils.TestApplication</param-value>
        </init-param>
    </servlet>

    <servlet-mapping>
        <servlet-name>Resteasy</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>

</web-app>

Note the commented out segment re-indents with every execution of the formatter-maven-plugin. If you change the comment from </context-param--> to </context-param> -->, in other words don't use the ending > as the tag delimiter, it seems to fix it.

Expected behavior
The indentation should only happen once, if at all.

Additional context
You can see the results or reproduce it with this PR resteasy/resteasy#3874. Note that it also seems to be stripping some leading spaces in the XML comments. That's easier to workaround though.

Configuration Option to delete the empty lines in XML files ?

Empty lines are not deleted from the xml document. I tried to look around the settings to find a configuration option to delete new lines/extra new lines from the xml document. Is there anything available?

Versions (OS, Maven, Java, and others, as appropriate):

  • Affected version(s) of this project: [e.g. 1.10.0] 2.15.0
  • OS: [e.g. CentOS 7.5] MacOS BigSur
  • Others: Tried on JDK1.8, 11 with Maven 3.8.1

To Reproduce
Steps to reproduce the behavior (or a link to an example repository that reproduces the problem):

Sample XML file:

<root>

  <node1> text </node1>


  <node2>text2</node2>


</root>

Expected behavior

<root>
  <node1> text </node1>
  <node2>text2</node2>
</root>

Add slf4j api usage to this project

Today this repo is using system out which is horrible design solution. It is further only used by the formatter-maven-plugin and the slf4j-api is already present there. Further maven uses slf4j-api as well. So rather than be flagged in code with bad usage, lets just add the api and fix the issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.