IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

Flatten XML structure with set -> text Options · View
Julian
Posted: Thursday, June 11, 2015 2:46:47 PM
Rank: Newbie

Joined: 6/11/2015
Posts: 8
Location: UK
Hi. I have an XML structure which I need to "flatten" to text / CSV.

I am struggling over getting a set within that structure to extract into fields in a line, rather than separate lines. This is due to restrictions regarding existing systems.

I am attempting this in Mapforce / Flextext ( I have Altova Missionkit Ent Ed.).

I say I'm struggling, but actually I've not managed anything close yet, and any help in getting me in the right direction would be greatly appreciated.

I have attached a simplified example XML, XSD and the desired output.

File Attachment(s):
Qex1.xml (2kb) downloaded 269 time(s).
Qex1.xsd (2kb) downloaded 313 time(s).
Qex1.csv (1kb) downloaded 238 time(s).


vlad
Posted: Thursday, June 11, 2015 3:30:40 PM
Rank: Advanced Member

Joined: 12/13/2005
Posts: 2,856
Location: Mauritius
This mapping is doing most of your job and should give you a good idea how to do the rest.

Important note: I have let MapForce create a schema automatically, because XML file is not valid according to the XSD you have provided here, and this makes MapForce it difficult/impossible to process your file correctly.


vlad attached the following image(s):
Capture.PNG

Julian
Posted: Thursday, June 11, 2015 4:21:21 PM
Rank: Newbie

Joined: 6/11/2015
Posts: 8
Location: UK
Vlad! Thanks for replying so quickly.

That solution looks great - something in there that I've not done before. I have applied the logic to my full scenario and it looks as though it works... I did not have an error using my XSD btw.. incidental anyway, as I will of course use the full XSD from my actual live files.

So, I come up with this output from the illustrated MFD...

123456,ABC123,NP22AB001,1,4,$77,Outer door skin,1234567890128,
123456,ABC123,NP22AB001,2,10,$84,Locking assembly,1234567890128,
123456,ABC123,NP09KX002,3,18,$14,Cross member,1234567890128,BLU-SUMMER

Thank you SO MUCH.

Julian


Julian attached the following image(s):
Qex1.JPG

vlad
Posted: Thursday, June 11, 2015 4:30:32 PM
Rank: Advanced Member

Joined: 12/13/2005
Posts: 2,856
Location: Mauritius
Just a short note: you may want to create a user defined function to avoid copying the logic three times
Julian
Posted: Thursday, June 11, 2015 4:47:57 PM
Rank: Newbie

Joined: 6/11/2015
Posts: 8
Location: UK
Thanks for the tip vlad.
Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.