My question is: if a new attribute appears in my source data (for example, atrr_1), is FME able to automatically add a corresponding field like this in the template:
Or do I need to manually edit the template each time a new attribute is added?
Page 1 / 1
Hi @francisco_1988 ,
I think it would be possible if there were a naming convention for attribute names to distinguish new attributes and others.
Can you determine if an attribute is a new one according to its name? If you can, how?
>Addition] Alternatively, it might be possible to create XML <field> element for every attribute regardless of whether it's new one or not, if you could keep only attributes to populate into the destination XML.
Hi @francisco_1988 ,
I think it would be possible if there were a naming convention for attribute names to distinguish new attributes and others.
Can you determine if an attribute is a new one according to its name? If you can, how?
No.
Addition] Alternatively, it might be possible to create XML <field> element for every attribute regardless of whether it's new one or not, if you could keep only attributes to populate into the destination XML.
Could you give me an example of your approach?
See the attached workspace example.
My approach is to use a combination of AttributeExploder and an XQuery expression implemented in XMLTemplater. Assuming that you can keep only required attributes to be populated into the destination XML document.
You need to learn about XQuery language. Good luck!
See the attached workspace example.
My approach is to use a combination of AttributeExploder and an XQuery expression implemented in XMLTemplater. Assuming that you can keep only required attributes to be populated into the destination XML document.
You need to learn about XQuery language. Good luck!
Sensational approach! Last question, I promise. In your approach, you used the AttributeExploder. By default, it works with two columns: Attribute and Value. Let's say my dictionary now contains three attributes: name, type, and description. How would this approach look then?
See the attached workspace example.
My approach is to use a combination of AttributeExploder and an XQuery expression implemented in XMLTemplater. Assuming that you can keep only required attributes to be populated into the destination XML document.
You need to learn about XQuery language. Good luck!
I’m not sure if I expressed myself clearly, but assuming my file has three fields: name, description, and type, how would the approach using the AttributeExploder work? Since its output is based on only two columns. I tried removing the AttributeExploder and noticed that the XMLTemplater didn’t recognize my fields: name, description, and type. In your approach, is it only possible to work with lists?Another thing I didn’t understand is why, in my example, it’s saving each record of my table with a unique XML.?
The screenshot in your original question illustrates that you are attempting to convert name and value of each input attribute to values of <name> and <description> elements for each <field>.
I therefore assumed the input dataset should look like this:
However, in you shared Excel dataset, the actual source dataset has three attributes called "name", "type", and "description", as in:
Since the presumption about shcema of input feature in the original question was wrong, the solution would be completely different. AttributeExploder would be unnecessary.
To find an appropriate solution, I would recommend you to firstly learn the XMLTemplater Help, especially the Configuration/Parameters/Sub-Templates section.
The screenshot in your original question illustrates that you are attempting to convert name and value of each input attribute to values of <name> and <description> elements for each <field>.
I therefore assumed the input dataset should look like this:
However, in you shared Excel dataset, the actual source dataset has three attributes called "name", "type", and "description", as in:
Since the presumption about shcema of input feature in the original question was wrong, the solution would be completely different. AttributeExploder would be unnecessary.
To find an appropriate solution, I would recommend you to firstly learn the XMLTemplater Help, especially the Configuration/Parameters/Sub-Templates section.
Your first approach was essential for my process! I just removed the Attribute Explorer and kept the ListBuilder. Thank you very much for your collaboration.
Good to hear you got a solution.
For what it's worth, in your case, using sub template might be easier, as I suggested in my last comment.
To find an appropriate solution, I would recommend you to firstly learn the XMLTemplater Help, especially the Configuration/Parameters/Sub-Templates section.