Skip to main content
Question

How can I reformat xml data to form a m:m table?


Forum|alt.badge.img
I am reading xml data with FME 2014 and attempting to rebuild a relational database model. I have an xml object "element " which has an m:m relationship with object "type". The xml looks like this...

 

 <element id="194070" >   <types>     <type id="445"/>     <type id="643"/>   </types> </element>
 

 

I can flatten the xml and recreate a table which looks like this...

 

 

 element.id | type.id.1 | type.id.2 194070          445         643
 

 

But in order to build a association table for the m:m relationship I need this;

 

 

 element.id | type.id 194070          445 194070          643
 

 

Can anyone offer a way to create this association table ?

 

 

3 replies

takashi
Influencer
  • August 5, 2014
Hi,

 

 

If you read the XML document by the XML reader with Feature Paths option (Elements to Match: element), the reader feature type will configure a list attribute named "types.type{}.id". Then, you can use the ListExploder on the list "types.type{}" to create the required data structure.

 

 

Takashi

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • August 5, 2014
You can Xquery the xml for "element" and send its childs to a list.

 

If you explode this list you get your m:m table.

Forum|alt.badge.img
Genius!

 

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings