Comments (10)
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.
@Arithmeticus I believe 6e334a4 provides what you are asking for. It would be good if you could give it a try.
from xmlunit.net.
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.
this is now #39
from xmlunit.net.
didn't mean to close this one, I thought it was the one over in the Java project, sorry.
from xmlunit.net.
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.
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.
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.
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.
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)
- Nuget.org package HOT 11
- Download Zip and Build HOT 2
- Create and clarify milestones and roadmap HOT 4
- Assembly version conflict in XMLUnit.NUnit3.Constraints HOT 11
- NetStandard support HOT 33
- Elements with different namespace prefix are detected as DIFFERENT instead of SIMILAR HOT 3
- Assembly version conflict HOT 3
- Wrong Constraint resolve HOT 2
- NodeFilter should apply to more nodes
- Use XXE save configurations by default, in particular don't fetch remote DTDs
- bug in get xpath of node HOT 4
- want to ignore sequence if child node have attribute HOT 7
- Release files HOT 6
- Ignoring the sequence of child nodes doesn't work HOT 3
- xml diffwith whitespaces HOT 7
- System.Xml.XmlException with undeclared prefix HOT 2
- Inputs created from XmlDocument with "PreserveWhitespace = true" generate unexpected differences. HOT 7
- Support for NUnit4 HOT 4
- XMLUnit 2.10.0 doesn't work with NUnit 4.x HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xmlunit.net.