Coder Social home page Coder Social logo

Comments (4)

Ekryd avatar Ekryd commented on July 26, 2024

I believe that I need to check the XML framework that I use to see this specific behaviour 👀

from sortpom.

Ekryd avatar Ekryd commented on July 26, 2024

Wow! You found a bug in the plugin. Great Job!

When I get the XML from the SAXReader, I get the XML tags and the empty whitespace between the tags. In order to identify the empty lines I use a regex: [\t ]*\r?\n?[\t ]* that unfortunately also identified your two spaces. Your text was removed and you got the empty tag.

I have changed the regex to the following: [\t ]*(\r|\n|\r\n)[\t ]* which solves your problem. but if somebody has the need to set a newline as text in an XML tag with xml:space="preserve" they will encounter the same problem.

Currently, I'm seeing if I get the SAXParser to only return XML tags and any text that is directly wrapped by those tags.

from sortpom.

create-issue-branch avatar create-issue-branch commented on July 26, 2024

Branch issue-402-XML_tag_with_xml_space=_preserve_containing_only_spaces_should_not_be_collapsed created!

from sortpom.

Ekryd avatar Ekryd commented on July 26, 2024

@ivangreene, I released new version of the plugin 3.4.1, that should solve this issue. Please try it out and tell me if it solves your problem.

I added a test that should test several whitespace cases combined with preserve:
https://github.com/Ekryd/sortpom/blob/master/sorter/src/test/resources/PreserveContent_input.xml
https://github.com/Ekryd/sortpom/blob/master/sorter/src/test/resources/PreserveContent_output.xml
https://github.com/Ekryd/sortpom/blob/master/sorter/src/test/java/sortpom/sort/LineSeparatorTest.java#L39

from sortpom.

Related Issues (20)

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.