Skip to main content

Hello I have a process in which I use FME to take a name from a Table, create a URL (like this "https://SERVER.XX_WFS_NAME?service=WFS&REQUEST=GetCapabilities") out of the name and download the coontent (XML) of that URL. Then a table is built out of that with 3 columns Name, URL and XML and ~300 rows. What I would like now is instead of one Excel file with 300 rows I would like to have 300 XML files preferablly with the tablename for each XML file as filename.

I am quite new to FME so I tried out several writers but maybe you have a solution for me. An I currently use FME Workbench 2017 on Win10.

Cheers

Hannes

Hi @dpuser,

Fanouts can only be performed on attribute values so you will need to convert the attribute names into attribute values for this to work so the AttributeExploder will be your friend here. The AttributeExploder will create value pairs (attribute name and attribute value) for every attribute on a feature which will allow you to store the attribute names as values.

From here, you could just write the XML after using a Tester to filter for _attr_name = xml|name|url... or if you want to make things a bit more dynamic (in case the excel file ever changes), you could take advantage of the FeatureReader's Schema Feature and do this using a FeatureJoiner - FeatureMerger in 2017 where the exploded features are the Requester and the schema features are the Supplier.

This way there is no need to filter out unwanted features (i.e. feature that store format attributes) as this method will join/merge on matching attribute name. Just use an AttributeManager to remove unwanted, add an XML writer, and set the fanout parameter under the writer in the Navigator.

Input

Output

In my example. I use a Counter to help set the filenames but since you have an attribute with the filename you can simply set the fanout parameter to be @value(name).xml. You should be able to run the workspace as is and the output(s) will be created in the same directory as the template.

Hope that helps!

p.s. I also attached a 2017 template for your convenience.

Fanout_Example_2017.fmwt

Fanout_Example_2020.fmwt


Hi @dpuser,

Fanouts can only be performed on attribute values so you will need to convert the attribute names into attribute values for this to work so the AttributeExploder will be your friend here. The AttributeExploder will create value pairs (attribute name and attribute value) for every attribute on a feature which will allow you to store the attribute names as values.

From here, you could just write the XML after using a Tester to filter for _attr_name = xml|name|url... or if you want to make things a bit more dynamic (in case the excel file ever changes), you could take advantage of the FeatureReader's Schema Feature and do this using a FeatureJoiner - FeatureMerger in 2017 where the exploded features are the Requester and the schema features are the Supplier.

This way there is no need to filter out unwanted features (i.e. feature that store format attributes) as this method will join/merge on matching attribute name. Just use an AttributeManager to remove unwanted, add an XML writer, and set the fanout parameter under the writer in the Navigator.

Input

Output

In my example. I use a Counter to help set the filenames but since you have an attribute with the filename you can simply set the fanout parameter to be @value(name).xml. You should be able to run the workspace as is and the output(s) will be created in the same directory as the template.

Hope that helps!

p.s. I also attached a 2017 template for your convenience.

Fanout_Example_2017.fmwt

Fanout_Example_2020.fmwt

Hi Chris, thank you for your answer. Sadly I didn't get yout method to work on my Problem. I am new to FME and have not much experience, maybe that is the problem. However I made a screenshot in which you can see what I have so far. The Inspector shows you a table and what I would like is to have an XML file for each row. The "Datensatzname" should be the filname and the "GetCapabilities" should be the XML file itself.


Hi Chris, thank you for your answer. Sadly I didn't get yout method to work on my Problem. I am new to FME and have not much experience, maybe that is the problem. However I made a screenshot in which you can see what I have so far. The Inspector shows you a table and what I would like is to have an XML file for each row. The "Datensatzname" should be the filname and the "GetCapabilities" should be the XML file itself.

Hi @dpuser,

Ah I see what you are doing. Why not just save the XML directly to a file from the HTTPCaller? If you set the Save Response Body to File and set the output filename to be <path>\\@Value(<filename attribute>).xml it should simplify things. This will result in the same thing as a regular fanout using a writer.

If you want to transform the XML prior to writing it, you can still use the download to attribute method, but you might want to use a text file writer. Since the XML is stored in an attribute, you simply need to set the text line data attribute in the text file writer feature type to the attribute containing the XML (i.e. GetCapabiliies). and then set the fanout in the navigator to be @Value(name).xml to fanout.

 

Hope that helps.

HTTPCall_Fanout_Example.fmwt


Hi @dpuser,

Ah I see what you are doing. Why not just save the XML directly to a file from the HTTPCaller? If you set the Save Response Body to File and set the output filename to be <path>\\@Value(<filename attribute>).xml it should simplify things. This will result in the same thing as a regular fanout using a writer.

If you want to transform the XML prior to writing it, you can still use the download to attribute method, but you might want to use a text file writer. Since the XML is stored in an attribute, you simply need to set the text line data attribute in the text file writer feature type to the attribute containing the XML (i.e. GetCapabiliies). and then set the fanout in the navigator to be @Value(name).xml to fanout.

 

Hope that helps.

HTTPCall_Fanout_Example.fmwt

Thank you, that worked perfect just as I needed it!


Reply