by wil421 · 7y ago · 0 comments
> However, we’ve created another problem in the form of inconsistency: some user properties are represented as element attributes, others as child elements.
Exactly. I’ve seen XML with element attributes and child elements all over the pace. No rhyme or reason for any of it. It’s especially bad in older systems.
I pushed hard at my last job for the SOA team to build REST/JSON web services. Oracle sold them a product to bridge the gap and they got End Of Life announcements 6 months later! Glad I’m gone.
See this link on stack exchange[1].
[1] https://stackoverflow.com/questions/17604071/parse-xml-using...
> //Gets Street name xmlDoc.getElementsByTagName("street")[0].childNodes[0].nodeValue;
I’d much prefer something like jsonObj.address[0].street;. Personally I like to work with objects over parsing documents trees.
> XML, on the other hand, optimizes for document tree structures, by cleanly separating node data (attributes) from child data (elements).
Unfortunately, there appear to be some implementation issues here. You have to create a string version of your data to store them in attributes.
So, you lose a bit of context in the conversion.
Such as:
`<Document text="true" />`
Is the text attribute the word _true_ or a boolean _true_. Without referencing some other piece of code or definition there is no way to know.
Whereas in JSON, this wouldn't be necessary, as you can simply remove the quotes and infer that it is not a string, but a boolean.
Technically, there are REST/JSON equivalents, but I don't see them actually used much in the wild - so much of the time with REST APIs you are stuck with whatever half-baked, out-of-date documentation that somebody may or may not have written, or just randomly poking at it through trial and error to discover how it works.
Sometimes even getting a sample of the expected JSON format can be hard. If you’re not versioning you’re APIs you can break everything if the schema changes.
I used to debate this with the SOA manager. Swagger looks ok but never dealt with it in production or saw it in the wild with our customers.
When you are hacking systems together for large/old enterprises the water gets muddy fast.