Stupid oanda XML



  • So, today I've been struggling with the XML responses from oanda (currency exchange basically). This XML response is so stupid, I don't even know how they've survived for so long. If you only want a single conversion, well, it looks good:

    <RESPONSE>
    <EXPR>USD</EXPR>
    <EXCH>EUR</EXCH>
    <AMOUNT>1</AMOUNT>

    <NPRICES>1</NPRICES>
    <CONVERSION>
    <DATE>Sat, 30 Dec 2000 21:50:03 GMT</DATE>

    <ASK>0.9421</ASK>
    <BID>0.9416</BID>

    </CONVERSION>
    </RESPONSE>

    Not bad, eventhought I don't see how two currencies are part of a response. The problem comes with multiple conversions:

    <RESPONSE>
    <EXPR>USD</EXPR>
    <EXCH>EUR</EXCH>

    <AMOUNT>1</AMOUNT>
    <NPRICES>1</NPRICES>
    <CONVERSION>
    <DATE>Tue, 20 Mar 2001 21:00:00 GMT</DATE>

    <ASK>0.9088</ASK>

    <BID>0.9082</BID>
    </CONVERSION>
    <EXPR>USD</EXPR>
    <EXCH>CAD</EXCH>
    <AMOUNT>1</AMOUNT>
    <NPRICES>1</NPRICES>
    <CONVERSION>
    <DATE>Tue, 20 Mar 2001 21:00:00 GMT</DATE>
    <ASK>0.6389</ASK>
    <BID>0.6384</BID>
    </CONVERSION>
    ...

    </RESPONSE>

    Luckily they offer a CSV service which makes more sense than this. Althought TRWTF is paying 600€ monthly for this.



  • Well, they can't fix it now because hundreds of clients depend on it!

    ... but yeah you ahve to wonder what was going through their engineer's mind. "Should we put EXPR, EXCH, AMOUNT, and NPRICES inside the conversion?" "Nah, good like it is." "But..." "I said 'nah!'"



  • I like XML and find it useful, but my rule is no schema, no XML. If every XML was required to have a validating schema, you wouldn't have garbage like this.


  • Considered Harmful

    @Rick said:

    I like XML and find it useful, but my rule is no schema, no XML. If every XML was required to have a validating schema, you wouldn't have garbage like this.

    <?xml version="1.0" encoding="UTF-8"?>
    <schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified">
    	<element name="RESPONSE">
    		<complexType>
    			<sequence maxOccurs="unbounded">
    				<element name="EXPR" type="string"/>
    				<element name="EXCH" type="string"/>
    				<element name="AMOUNT" type="nonNegativeInteger"/>
    				<element name="NPRICES" type="nonNegativeInteger"/>
    				<element name="CONVERSION">
    					<complexType>
    						<sequence>
    							<element name="DATE" type="dateTime"/>
    							<element name="ASK" type="decimal"/>
    							<element name="BID" type="decimal"/>
    						</sequence>
    					</complexType>
    				</element>
    			</sequence>
    		</complexType>
    	</element>
    </schema>
    


  • @ubersoldat said:

    Not bad, eventhought I don't see how two currencies are part of a response. The problem comes with multiple conversions:

     
    I dont see "two currencies" in the response, I see bid and ask. These are the purchase and selling prices, with the difference between them being the markup that keeps the currency exchange firms in business. This difference is a key indicator you look at when deciding WHO do do your exchanges with.



  • @TheCPUWizard said:

    I dont see "two currencies" in the response, I see bid and ask. These are the purchase and selling prices, with the difference between them being the markup that keeps the currency exchange firms in business. This difference is a key indicator you look at when deciding WHO do do your exchanges with.

    Pedantic Dickweed Man... AWAY!


  • ♿ (Parody)

    @TheCPUWizard said:

    @ubersoldat said:

    Not bad, eventhought I don't see how two currencies are part of a response. The problem comes with multiple conversions:

     
    I dont see "two currencies" in the response, I see bid and ask. These are the purchase and selling prices, with the difference between them being the markup that keeps the currency exchange firms in business. This difference is a key indicator you look at when deciding WHO do do your exchanges with.

    Look more closely at the second example. You've got USD to EUR and USD to CAD. It looks like you have to note the order in which things show up in the XML file. Or not. Who knows?



  • @boomzilla said:

    @TheCPUWizard said:
    @ubersoldat said:

    Not bad, eventhought I don't see how two currencies are part of a response. The problem comes with multiple conversions:

     
    I dont see "two currencies" in the response, I see bid and ask. These are the purchase and selling prices, with the difference between them being the markup that keeps the currency exchange firms in business. This difference is a key indicator you look at when deciding WHO do do your exchanges with.

    Look more closely at the second example. You've got USD to EUR and USD to CAD. It looks like you have to note the order in which things show up in the XML file. Or not. Who knows?

     

     

    It's secuential XML... gotta love it.



  • @Rick said:

    I like XML and find it useful, but my rule is no schema, no XML. If every XML was required to have a validating schema, you wouldn't have garbage like this.

    One time I had to use a e-marketplace product, there was a schema and everything to make it easier to build an order and push it to the market server. But no matter how hard I tried, the server would reject my xml. So I ended up on the phone with their technical support, and they explained to me that what the doc meant by "set the xml value" was that there should be a HTTP POST call where "xml" is the name of a input box where the xml data has been pasted before the form.submit.



  • @ubersoldat said:

    @boomzilla said:

    @TheCPUWizard said:
    @ubersoldat said:

    Not bad, eventhought I don't see how two currencies are part of a response. The problem comes with multiple conversions:

     
    I dont see "two currencies" in the response, I see bid and ask. These are the purchase and selling prices, with the difference between them being the markup that keeps the currency exchange firms in business. This difference is a key indicator you look at when deciding WHO do do your exchanges with.

    Look more closely at the second example. You've got USD to EUR and USD to CAD. It looks like you have to note the order in which things show up in the XML file. Or not. Who knows?

     

    It's secuential XML... gotta love it.

    I took the comment to refer to the XML above it, specifically because the OP stated "The Problems Comes with" immediately before the second sample.



  • @boomzilla said:

    @TheCPUWizard said:
    @ubersoldat said:

    Not bad, eventhought I don't see how two currencies are part of a response. The problem comes with multiple conversions:

     
    I dont see "two currencies" in the response, I see bid and ask. These are the purchase and selling prices, with the difference between them being the markup that keeps the currency exchange firms in business. This difference is a key indicator you look at when deciding WHO do do your exchanges with.

    Look more closely at the second example. You've got USD to EUR and USD to CAD. It looks like you have to note the order in which things show up in the XML file. Or not. Who knows?

     

    Looks more closely at the first example. You've got

    <EXPR>USD</EXPR>
    and
    <EXCH>EUR</EXCH>
    There, two currencies.

     

     


  • ♿ (Parody)

    @immibis said:

    Looks more closely at the first example. You've got

    <EXPR>USD</EXPR>
    and
    <EXCH>EUR</EXCH>
    There, two currencies.

    Uh, yeah, but that's completely missing the point. Those have different tags, so presumably it's pretty clear that you're going from one to the other, based on the definition of the tags themselves.



  • @thistooshallpass said:

    @Rick said:

    I like XML and find it useful, but my rule is no schema, no XML. If every XML was required to have a validating schema, you wouldn't have garbage like this.

    One time I had to use a e-marketplace product, there was a schema and everything to make it easier to build an order and push it to the market server. But no matter how hard I tried, the server would reject my xml. So I ended up on the phone with their technical support, and they explained to me that what the doc meant by "set the xml value" was that there should be a HTTP POST call where "xml" is the name of a input box where the xml data has been pasted before the form.submit.

    See. Different garbage. Not garbage like this.



  • @Rick said:

    @thistooshallpass said:

    @Rick said:

    I like XML and find it useful, but my rule is no schema, no XML. If every XML was required to have a validating schema, you wouldn't have garbage like this.

    One time I had to use a e-marketplace product, there was a schema and everything to make it easier to build an order and push it to the market server. But no matter how hard I tried, the server would reject my xml. So I ended up on the phone with their technical support, and they explained to me that what the doc meant by "set the xml value" was that there should be a HTTP POST call where "xml" is the name of a input box where the xml data has been pasted before the form.submit.

    See. Different garbage. Not garbage like this.

    Ok I'll put it more simply for you: a schema does not prevent a poor usage of xml, just like css does not prevent a poor usage of html.



    A schema is like a ISO certification - it does not mean that the output is good, it only means that the output is consistent and that it has been prepared using specific, well-documented rules. Quality != consistency.



    So your "rule" is great for stability and maintenance, but it does prevent garbage like this.


  • Considered Harmful

    Garbage like this can validate against a schema though.



  • The sequential nature of the XML response suggests to me that this was a ham-fisted conversion to XML from an older mainframey fixed-length format.

    The original probably looked something like this:

    FOOBAR            QUX CONV           USD                                                         EUR             00001        00001                Tue, 20 Mar 2001 21:00:00 GMT             X                                    0.9088           0.9082           C        USD                    CAD              1                                                                       1                      (etc etc with lots and lots of pointless padding)
    

    I have to convert that kind of junk all the time. The fields outside of the CONVERSION elements may have represented record headers, and the CONVERSION fields were the records themselves. The lazy way to XMLize it is just plop it into sequential XML since it's all the same data anyway. I've seen it happen.



  • @boomzilla said:

    @immibis said:
    Looks more closely at the first example. You've got

     

    <EXPR>USD</EXPR>
    and
    <EXCH>EUR</EXCH>

    There, two currencies.

    Uh, yeah, but that's completely missing the point. Those have different tags, so presumably it's pretty clear that you're going from one to the other, based on the definition of the tags themselves.
     

    Presumably, when the OP said he didn't see how two currencies belonged in the response, he meant

    <RESPONSE>
    <EXPR>USD</EXPR>
    <EXCH>EUR</EXCH≫

     Because he was obviously referring to the first example, and those are the only two currencies in it, which also happen to be part of a response.

     


Log in to reply