Skip to main content
Solved

How to fix XML is duplicated with each output data field in XMLTemplater transformer ?

  • May 17, 2022
  • 2 replies
  • 81 views

davidlee
Supporter
Forum|alt.badge.img+8

I use XMLtemplater to design my XML file from Excel, but i have problem with the result:

This result, it coincides with each output data field:

image imageI want to group like this:

imageAnd this is my model FME:

imageAnybody help me, pls !

in my excel file, the fields "table_id" in sheet "table" and "table_id_field" in sheet "fields" are key fields to link these two data tables together

Best answer by debbiatsafe

Hi @davidlee​ 

For your desired output, I would suggest removing the field portion of the TABLE sub-template and moving this to a new sub-template (eg. FIELD). Connect the tables feature type to the TABLE port and the output of Counter to the new FIELD port.

In TABLE, use the following XQuery function after the INFO element       

    ...
    </info>
    <fields>
        {fme:process-features("FIELD","table_id",fme:get-attribute("table_id"))}
    </fields>
</table>  

This function call will execute the FIELD sub-template on all features that entered the transformer though the FIELD input port, and whose table_id attribute is equal to table_id attribute of the TABLE feature being processed.

The output XML should contain 2 table elements with the associated fields for each table as child elements.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

debbiatsafe
Safer
Forum|alt.badge.img+21
  • Safer
  • 648 replies
  • Best Answer
  • May 17, 2022

Hi @davidlee​ 

For your desired output, I would suggest removing the field portion of the TABLE sub-template and moving this to a new sub-template (eg. FIELD). Connect the tables feature type to the TABLE port and the output of Counter to the new FIELD port.

In TABLE, use the following XQuery function after the INFO element       

    ...
    </info>
    <fields>
        {fme:process-features("FIELD","table_id",fme:get-attribute("table_id"))}
    </fields>
</table>  

This function call will execute the FIELD sub-template on all features that entered the transformer though the FIELD input port, and whose table_id attribute is equal to table_id attribute of the TABLE feature being processed.

The output XML should contain 2 table elements with the associated fields for each table as child elements.


davidlee
Supporter
Forum|alt.badge.img+8
  • Author
  • Supporter
  • 32 replies
  • May 18, 2022

Hi @davidlee​ 

For your desired output, I would suggest removing the field portion of the TABLE sub-template and moving this to a new sub-template (eg. FIELD). Connect the tables feature type to the TABLE port and the output of Counter to the new FIELD port.

In TABLE, use the following XQuery function after the INFO element       

    ...
    </info>
    <fields>
        {fme:process-features("FIELD","table_id",fme:get-attribute("table_id"))}
    </fields>
</table>  

This function call will execute the FIELD sub-template on all features that entered the transformer though the FIELD input port, and whose table_id attribute is equal to table_id attribute of the TABLE feature being processed.

The output XML should contain 2 table elements with the associated fields for each table as child elements.

I see, it works perfectly, thank you so much @debbiatsafe​ !