waider: (Default)
waider ([personal profile] waider) wrote2005-10-09 01:33 pm
Entry tags:

XML question

So, to get the basics out of the way, I hate XML. I'm forced to deal with it for a hack I'm fiddling with right now, though. And having poked this with a stick for the last week, I've finally found the problem: I am sending data formatted as <foo><bar 1><bar 2><bar 3></foo> and the client wants <foo><bar 2><bar 1><bar 3></foo>, i.e. the order of the contained elements turns out to be important. Now, as far as I can tell, the contained elements are not order-dependant; they're essentially attributes of the container (foo) which can logically interact with each other unambiguously regardless of order (one's a default setting, one's a current setting, and one's a timeout value). While I'm happy to cast asparagus on Microsoft for this (for theirs is the client) I'm curious as to whether this is common behaviour or just short-sighted programming?

[identity profile] boutell.livejournal.com 2005-10-09 02:59 pm (UTC)(link)
Interestingly, Perl's XML::Simple can't do order-dependence. Which rules it out entirely for XML as a markup for, let's say, documents. (: (You can use the more hardcore XML modules of course.)
ext_181967: (Default)

[identity profile] waider.livejournal.com 2005-10-09 03:17 pm (UTC)(link)
This is pretty much precisely where I bumped into it. I've got XML::Simple parsing the incoming stuff, but I have to either hand-generate the output or use one of the heavier XML modules. And frankly for the quantity of XML being output it doesn't seem worthwhile to use e.g. SAX.

(Anonymous) 2005-10-09 03:26 pm (UTC)(link)
A simple way to cope with order dependence would be a very welcome addition to XML::Simple IMHO. I did something using the underlying "real" XML stuff, and it wasn't much fun.

But I'm slouching towards Python anyway. tagsfrom10k was a mostly painless coding experience. Although there are some issues with internationalization that I don't get.

ext_181967: (Default)

[identity profile] waider.livejournal.com 2005-10-09 03:44 pm (UTC)(link)
If I cared more about it, perhaps. But I don't, presently. Seems like you could just bolt Tie::IxHash into it and bob's your uncle.

[identity profile] brad.livejournal.com 2005-10-09 06:28 pm (UTC)(link)
XML Schemas can specify the order they want things, yeah.

Perl people thinking that everything's-a-hash often run into this problem. I remember Whitaker fighting XML::Simple too recently while talking to Wells Fargo.
ext_181967: (Default)

[identity profile] waider.livejournal.com 2005-10-09 07:14 pm (UTC)(link)
It had occurred to me that order is certainly a desirable; in this instance, however, I'm calling short-sighted programming because, as I say, there's no ambiguity in processing the contained elements in any order. Of course, that's mainly my view because I'm annoyed it took me so long to figure it out.

[identity profile] bitpuddle.livejournal.com 2005-10-09 10:12 pm (UTC)(link)
One would think that if order mattered, your clients would have specified it in a schema or some-such mechanism.

Regardless, you may be bumping up against limitations in your processing library. Consider python, as its library is pretty robust.

To answer your other question, I'm routinely astounded at the odd decisions made by developers with which we exchange XML. I often think it would be easier to send the clients code to process the messages we plan to exchange. Here. Use this.

I'd rather process XML than binary files, however. For that, I'm grateful.
ext_181967: (Default)

[identity profile] waider.livejournal.com 2005-10-16 11:09 am (UTC)(link)
One would think that if order mattered, your clients would have specified it in a schema or some-such mechanism.
Well, it's a Microsoft protocol. The fact that there's any public documentation at all is something of a surprise to me. The protocol examples - and, indeed, the on-the-wire traffic - specifies namespace URLs which don't work.

Regardless, you may be bumping up against limitations in your processing library. Consider python, as its library is pretty robust.
Nah. The library is robust. It's that it hasn't got a way of preserving order. There's a more complex library to do that, and really for the amount of XML I'm generating it's easier to hand-code it. And really now. Changing the entire language I'm using (which would, incidentally, require me to learn a whole new language AND a library API) just because of some minor failing in the existing library? Seems a bit overkill...