Solved

Reading XML as output from ZipExtractor


Badge +4

Using a HTTPcaller I downloaded a Zipfile which contains a XML. Using a FeatureReader I retrieved the path of the XML file. Furthermore the FeatureReader was used to read this XML using 'path_windows' as attribute which contains the XML file. However, I got stuck there.

 

In case I read the XML directly using a XML reader it works perfectly.

See the attached screenshot for my workflow.

icon

Best answer by nielsgerrits 6 May 2021, 15:38

View original

5 replies

Userlevel 6
Badge +34

Are you sure the file is still there? Because you are using FeatureCaching, you can remove the extracted zip using the explorer without workbench knowing it.

Badge +4

Are you sure the file is still there? Because you are using FeatureCaching, you can remove the extracted zip using the explorer without workbench knowing it.

Hi niels, yeah I see it popping up in my explorer when running the workspace. Maybe it has to do with my settings of the 2nd FeatureReader (reading XML). I clicked 'Feature Types to Read' and got an error.

 

Error FME XML reader 

However, reading the same XML with a seperate XML reader works fine:

 

Reading XML with XML reader

Userlevel 6
Badge +34

Hi niels, yeah I see it popping up in my explorer when running the workspace. Maybe it has to do with my settings of the 2nd FeatureReader (reading XML). I clicked 'Feature Types to Read' and got an error.

 

Error FME XML reader 

However, reading the same XML with a seperate XML reader works fine:

 

Reading XML with XML reader

This should really work. The error is because the Dataset is an attribute instead of a value, so it can't scan for a schema, so you can't choose from scanned featuretypes.

Did you set the FeatureReaders OutputPorts to Single Output Port?

Badge +4

Okay, hence it is not possible to read XML in the middle of a workflow ?

I set my FeatureReaders to SingleOutput port but that does not make a difference.

Userlevel 6
Badge +34

Okay, hence it is not possible to read XML in the middle of a workflow ?

I set my FeatureReaders to SingleOutput port but that does not make a difference.

It depends 😃 If your schema is fixed, it is perfectly doable:

  • In the FeatureReader XML reader, select a sample file in Dataset.
  • In the Parameters, select the elements to match. (Assuming you use Feature Paths.)
  • Set Output Ports to Single Output Port. *
  • Test if this works as expected.
  • Now change FeatureReader XML reader Dataset to path_windows.

* You can choose to set Output Ports to One per Feature Type, but then you need to select the sample file every single time you make a change to the FeatureReader, to populate the outputports. And that quickly becomes annoying in my book.

 

Another way of dynamically processing XML is to use a Text Reader (Read Whole File at Once = Yes) and process the attribute with the XML using XMLFragmenters.

Reply