Solved

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


Badge +5

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

icon

Best answer by debbiatsafe 18 May 2022, 01:42

View original

2 replies

Userlevel 3
Badge +17

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.

Badge +5

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​ !

Reply