is the next Chiquita
Join Date: Feb 2005
|
I have two objects from two libraries that are incompatible with each other. It happens that both supports writing and reading to/from XML, so I figured I would use XML as the bridge between two objects I need to access.
However, after examining the output of XML generated, it is apparent that they do not use same format, and will refuse to read XML generated by other library. Both XMLs pass the well-formedness test, but fails validation (the validator complains that it couldn't find the root element xml... ). I figured that some people may had same problems and had to automate diff between XMLs. A quick google return me only one useful product and they want dough for it. So I'm coming on here, in hopes that some soul here has same problem and may be able to point me toward a good way to automate the diff and thus translate between two XML into format that is acceptable for both objects. (Though at this point, I question whether this is actually easier to do than just to manually write the codes necessary to interface between the two objects...) |
quote |
Veteran Member
Join Date: May 2004
|
General diffing of XML files from two different schemas is easy:
They're different. XML is a container format, not a data format. It's like saying "I can't play this QuickTime movie!" without knowing what the underlying codec is. In the general case, even with the same schema being used in the two files, a diff becomes a graph isomorphism problem, which scale badly and are a pain to get right. Write the mapper, knowing what you do about the two metamodels being used for the data. It'll be easier. |
quote |
is the next Chiquita
Join Date: Feb 2005
|
One library does provide the functionality to write out the schema without the data, but I don't think that's the case with another library, which makes it one way, I think. Will review the documentation to be 100% sure, but that's a good idea- writing out the schema and and re-write it into the expected format for the other library.
|
quote |
Veteran Member
Join Date: May 2004
|
Consider using an XSLT, in that case - it's what it's for. It will read the one format and emit the other.
|
quote |
is the next Chiquita
Join Date: Feb 2005
|
Perfect, looks like what I need for the job.
Many thanks! |
quote |
Senior Member
Join Date: Nov 2004
|
Quote:
XML does have lots of nice tools though, and more all the time, which allow users to address the compatibility issues with a minimum of extra work. XSLT is a good example in this case, without the XML you would need to write a binary translation engine from scratch---Yuck! |
|
quote |
Veteran Member
Join Date: May 2004
|
Quote:
Quote:
But now I have a suite of XSLTs that can transform the one file format into visualizations (UML, using GraphViz and the dot format), compute fairly complex metrics, and even formats for consumption by other tools in industry and academia. Are they lightning fast? Not always. I had to do some serious work to get one of them down to practical speeds. (Initially the transformation for one 20MB file took over 9 hrs on my MBP... I got it down to under 5 min with some algorithmic changes.) But useful? Flexible? Hell yeah. Banana, one warning: XSLT is a functional programming language first and foremost, not procedural. It is a little... different. Trying to make it act like a procedural language is *possible*, but it's not simple or recommended. It's better to go with the flow and get into the functional mindset, rather than try and beat it to match procedural experience. Last edited by Kickaha : 2008-11-08 at 13:30. |
||
quote |
is the next Chiquita
Join Date: Feb 2005
|
Warning noted. Will do some reading up on what is expected in a functional language- Oodles of fun ahead!
|
quote |
Posting Rules | Navigation |
|
Thread Tools | |