cancel
Showing results for 
Search instead for 
Did you mean: 

Issue handling XML structure with graphical tool

Former Member
0 Kudos

Hey all,

I have an issue while trying to map an XML Structure because i can define the order of the data

I'm currently getting a response from a service in this format

<response>

<exchangefrom>

<exchangeto>

<value>

<days>

<convert_data>

<date>

<ask>

<bid>

</convert_data>

</response>

- if "exchangeto" is more than one currency i will get multiple responses in this format

example:

<exchangefrom>usd

<exchangeto>eur_cad

Response:

<response>

<exchangefrom>usd <= begin first data

<exchangeto>eur

<value>x

<days>x

<convert_data>

<date>x

<ask>x

<bid>x

</convert_data>

<exchangefrom>usd <== begin second data

<exchangeto>cad

<value>y

<days>y

<convert_data>

<date>y

<ask>y

<bid>y

</converty_data>

</response>

- On the other side if days > 1 i will get multiple convert_data segment according to the amount of days (starting date + value)

<response>

<exchangefrom>usd

<exchangeto>eur

<value>1

<days>1

<convert_data></convert_data>

<exchangefrom>usd

<exchangeto>cad

<value>1

<days>2

<convert_data></convert_data>

<convert_data></converty_data>

</response>

the problem is that exchangefrom,exchangeto,value and cdays are 0.unbounded so i get all the data mixed in the XML, i know just by looking that a first extructure being at "from" and ends with a new "from" (having their corresponding convert_data item segments)

But i simply can make a correct map since all is at the same level!

so most of the times any map logic i try to create doesn't cover all the possibilities in graphical map

I was trying to use "Splitbyvalue - each" but i can't group the last two convert_data, since i don't have any key to tell the map that the last two belong to one set of values, getting one 1 convert_data per exchange value..

- Should i try to check other tool like XSLT to handle correctly the XML? or there's any way to process that with graphical tool?

Any ideas?

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Alexis,

I somehow doubt that your structure is very useful when you get more than one currency.

From my point of view the structure should look like this:

<response> 1

<item> 0..n

<exchangefrom>

<exchangeto>

<value>

<days>

<convert_data> 0..n

<date>

<ask>

<bid>

</convert_daa>

</item>

</response>

or maybe like this:

<response> 1

<exchangefrom attribute=value > 0..n

<exchangeto> 1

<value> 1

<days> 1

<convert_data> 0..n

<date>

<ask>

<bid>

</convert_data>

<exchangefrom>

</response> 1

Maybe the structure you quote is technically correct but how will you (or the software handling your output) ever be able to sort out which value belongs to which convert_data for instance??

You say that the data always comes in the same order but a parser like DOM will never be able to sort the fields anyway. You'd have to work with a tricky SAX parser or just read the values row by row. And what if the order changes? With a proper structure you'd have no problems in that case but with your construction you'd be lost.

With one of the structures I suggest you'd get no problems with the graphical mapping.

If you still have to use the structure you posted you better use XSLT...

Regards

Karsten

Answers (0)