Giter Club home page Giter Club logo

Comments (10)

bodewig avatar bodewig commented on August 26, 2024

If you are using .NET Framework, then over there might have been the better place. :-) - The issue itself most probably applies to the Java version as well, so all is fine, I just wanted to make sure you know there is a dedicated tracker for the .NET version.

I assume the Trim in NormalizeWhitespace is what is causing problems for your use-case. Of course it would be possible to add NormalizeXMLWhitespace and StripXmlWhiteSpace methods to Nodes that would "trim" more selectively. And we could add corresponding (I)Source implementations and even add new flags to InputBuilder. I wouldn't be opposed to that.

In practice you can write such a NormalizeXMLWhitespace in your own code and apply that to your DOM based ISource yourself outside of XMLUnit if you want to test the concept first.

from xmlunit.net.

bodewig avatar bodewig commented on August 26, 2024

@Arithmeticus I believe 6e334a4 provides what you are asking for. It would be good if you could give it a try.

from xmlunit.net.

bodewig avatar bodewig commented on August 26, 2024

Actually, Java's trim works quite different from the C# one, it only removes control characters and space, so this issue only applies to XMLUnit.NET. That's why I'm going to transfer it.

from xmlunit.net.

bodewig avatar bodewig commented on August 26, 2024

this is now #39

from xmlunit.net.

bodewig avatar bodewig commented on August 26, 2024

didn't mean to close this one, I thought it was the one over in the Java project, sorry.

from xmlunit.net.

Arithmeticus avatar Arithmeticus commented on August 26, 2024

Thanks. I had posted on the java section, because it looked like that's where the party was. I'll give your suggestions a try.

from xmlunit.net.

Arithmeticus avatar Arithmeticus commented on August 26, 2024

Preliminary note, before more substantive comments. I managed to get the new XmlWhitespaceStrippedSource() object to work. It was challenging, because of gaps in the documentation. Note dead link: http://www.xmlunit.org/api/net/master/Org.XmlUnit.Builder/Input.html (host page https://github.com/xmlunit/user-guide/wiki/Providing-Input-to-XMLUnit#inputbuilder).

I see https://www.xmlunit.org/api/net/2.9.2/Org.XmlUnit.Input/index.html but the documentation there seems incomplete.

In the end I got it to work, but it took more time than I would have liked, and for anyone else trying to get their code to work, here's my approach:

string pathA = "D:\\bugs\\28724\\space_test_a.xml";
string pathB = "D:\\bugs\\28724\\space_test_b.xml";
ISource Benchmark = Input.FromFile(pathB).Build();
XmlWhitespaceStrippedSource BenchmarkStripped = new XmlWhitespaceStrippedSource(Benchmark);
ISource Test = Input.FromFile(pathA).Build();
XmlWhitespaceStrippedSource TestStripped = new XmlWhitespaceStrippedSource(Test);
Diff xmlDiffBuilder;
xmlDiffBuilder = DiffBuilder.Compare(TestStripped).WithTest(BenchmarkStripped).Build();

The new object works as expected, even though that wasn't what I was hoping to get. See next post.

from xmlunit.net.

Arithmeticus avatar Arithmeticus commented on August 26, 2024

Before submitting the ticket I had avoided the modified flavors of -Source objects, primarily because documentation was confusing, and I wasn't certain what I was going to get loaded up. Therefore I was looking at post-build methods such as NormalizeWhitespace(), which doesn't permit the strict XML definition for whitespace. I think a XmlNormalizeWhitespace() counterpart method, analogous to the adjustment you've made here, would be helpful.

That said, in figuring out the new class, I learned to appreciate the input -Source variants. If you're happy with the approach taken with XmlWhitespaceStrippedSource, then WhitespaceNormalizedSource would also need a XmlWhitespaceNormalizedSource counterpart. (That's the option I really wanted.)

For the purposes of documentation, it would be good to signal to users that the activity performed by -StrippedSource is a proper subset of the activity performed under -NormalizedSource. To some, "stripped" may sound harsher than "normalized" and imply a more drastic operation.

from xmlunit.net.

bodewig avatar bodewig commented on August 26, 2024

Many thanks for the feedback @Arithmeticus . I consider the user's guide the primary documentation, so maybe https://github.com/xmlunit/user-guide/wiki/Providing-Input-to-XMLUnit would have been given better guidance - or not.

If you feel the documentation is not adequate please help us improving it. Sometimes it is difficult to know what is lacking from the docs when you are too familiar with the code.

I'll add XmlWhitespaceNormalizedSource and additional methods to the builder if this helps.

from xmlunit.net.

bodewig avatar bodewig commented on August 26, 2024

OK, the builder has been adjusted and I've tried to clarify the docs a bit more. Also I've added more extensive content to the user guide.

from xmlunit.net.

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.