Skip to main content

Dear all,

I am at my wit's end here.

In this article:

https://knowledge.safe.com/articles/1207/reading-c...

the XMLFlattener transformer is shown. I have made a workflow with the xml from the article as input file for an XMLFlattener to create feature paths at the node 'shipto'. The input file is valid XML. The output of the flattener however is only a _creation_instance attribute with a value of 0.

As a test I fed the XML as an XML Reader. Instantly it translates the xml children in the correct feature attributes.

What in the world is going wrong here?

I have been searching for 3 hours or more, tried the XMLFragmenter but the results are the same.

Thanks for any suggestion!

The workflow and the xml source file is included here

Pim Verver

I ran your workspace as-is and I got one feature containing the "shipto" section with name/address/city/country.

I then modified the "Elements to match" to just "shiporder" and then I also got the "item" sections:

To me it seems to work as it should, or am I missing something?


I ran your workspace as-is and I got one feature containing the "shipto" section with name/address/city/country.

I then modified the "Elements to match" to just "shiporder" and then I also got the "item" sections:

To me it seems to work as it should, or am I missing something?

Could it be that you've forgotten to manually expose the attributes introduced by the XMLFlattener?


Hello @david_r, it seems I am missing something. I've got the FME Database edition, latest build, and I still got nothing. Is it an FME setting maybe?I can type in manually the attribute names to expose them, but isn't that a kind of weird? In real life I have an XML-file waiting, with lots of different elements that I cannot predict. And isn't it the functionality of the XMLFlattener to just extract the elements and turn them into feature attributes. In the XMLReader it happens just as I expect it to be...Any suggestions are highly appreciatedKind regards,Pim
Hello @david_r, it seems I am missing something. I've got the FME Database edition, latest build, and I still got nothing. Is it an FME setting maybe?I can type in manually the attribute names to expose them, but isn't that a kind of weird? In real life I have an XML-file waiting, with lots of different elements that I cannot predict. And isn't it the functionality of the XMLFlattener to just extract the elements and turn them into feature attributes. In the XMLReader it happens just as I expect it to be...Any suggestions are highly appreciatedKind regards,Pim

No, it's not weird that you have to expose the attributes manually, it's as expected :-)

The reader will actually parse the XML file when you create it and then assume that the incoming file will always have the same schema. The XMLFlattener, on the other hand, does not look at the XML file until you run the workbench, so the attributes won't be known until run-time.


Oh okey, that seems logical. So if I don't want to analyse all possible elements/attributes and define and expose them beforehand, the only way to go is the XML reader?

By the way, I have defined some elements/attributes as exposed attributes. They are there in the output but without any values. There's still something wrong with my workflow, my settings or my mind ...

I'll try again tomorrow. Thxs again.

Pim


With a fresh mind I got it working with manually adding the attributes. Thank you @david_r!


With a fresh mind I got it working with manually adding the attributes. Thank you @david_r!

Excellent! You're welcome.


Reply