From: James A. <jam...@gm...> - 2009-04-21 12:46:31
|
2009/4/20 Stefan Bodewig <bo...@ap...>: > Well, it turned out that my ideas are not really that big or even > complex. > > I want a single unified type to represent any type of XML data that > any part of XMLUnit2 deals with - where any part is the difference > engine, the validator or the XPath engine. XMLUnit 1.x has many > overloads with Document, String, InputStream and InputSource > parameters and this doesn't really help. > > Together with this unified type we'd need adapters and maybe a > convenient fluent builder. > > For Java it turns out such a unified type already exists: > javax.xml.transform.Source which is used by JAXP's validation API (and > transformations, obviously) and can be used by JAXP's XPath API in a > simple way via SAXSource.sourceToInputSource. The only piece that may > be a bit more complex to implement would be the difference engine but > we can always perform an identity transform with a DOMResult as > target. The same is true for XPath and a SAXResult. > > org.xml.sax.InputSouce could be a choice that would be almost as > compelling, but it looks as if Source was the way forward in JAXP > given the validation API and StAXSource in the newer versions. > > .NET doesn't really have a type like this. XmlReader probably gets > closest but it's a class rather than an interface which may constrict > some things we'd like to do. > > I propose to use something like > > public interface ISource { > XmlReader Reader {get;} > } > > instead and implement that for XmlDocument, Stream and TextReader. > The XMLUnit2 APIs would then look similar in that they'd use > (I)Source. > > The builder I envision is somethng along the lines of > > Input.fromFile("some/path").withEntityResolver(someResolver).build(); > > Comments? > > Stefan > Sounds reasonable. I would love to be able to contribute in terms of (Java) code but I'm a bit swamped for the foreseeable few months. Happy to bounce ideas around though. Cheers, James |