I have a method which compares two XML documents (via streams) and writes the output to a Writer. The end result is that I want to then parse this into an in memory DOM document without creating an intermediary string, file or in memory structure.
My problem is that I can't figure out how to push the data from my writer into say a SAXHandler to create my DOM document.
I have it setup right now to just write the result to stdout (Note i1 and i2 are InputStream's for my original documents which I am comparing):
BufferedReader inputReader1 = new BufferedReader(new InputStreamReader(i1));
BufferedReader inputReader2 = new BufferedReader(new InputStreamReader(i2));
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
(new XMLCompare()).compare(inputReader1, "",inputReader2, "", writer);
So instead of writing the result of compare() to stdout I want to build a DOM document with it. Any suggestions?
Thanks!