Hi everyone.
I am new to XML and am having some difficulties using the XMLUpdater and XQuery. My issue is around updating 3 attributes within an xml element from 3 attributes in an FME list to create multiple children. When I do this for a record which has say 2 items in the list it’s producing 9 children instead of 2, do I need to group my data somewhere in my XQuery?
I’ve attached a sample workbench and data.
I am reading an Excel document, then creating a list of all LCS_Codes and their measures per TAC_Code. I then want this list to form the children of a location element within my XML. So I’d hope to go from something like this:
Input table:
To this output XML text:
<tractionCurrentSection id="M58">
<location>
<part idEl="B077/MSBFA" startPos="0" endPos="149.302"></part>
<part idEl="B077/MSBLO" startPos="0" endPos="133.761"></part>
</location>
However I’m getting this:
<tractionCurrentSection id="M58">
<location>
<part idEl="B077/MSBFA" startPos="0" endPos="149.302"></part>
<part idEl="B077/MSBFA" startPos="0" endPos="133.761"></part>
<part idEl="B077/MSBFA" startPos="0" endPos="149.302"></part>
<part idEl="B077/MSBFA" startPos="0" endPos="133.761"></part>
<part idEl="B077/MSBLO" startPos="0" endPos="149.302"></part>
<part idEl="B077/MSBLO" startPos="0" endPos="133.761"></part>
<part idEl="B077/MSBLO" startPos="0" endPos="149.302"></part>
<part idEl="B077/MSBLO" startPos="0" endPos="133.761"></part>
</location>
</tractionCurrentSection>
I think the above is putting each part of the list to each part of the list, hence me having 9 children instead of 2 for the 3 attributes I’m updating. Is there a way I can tell the Xquery to group by the list entry instead?
XQuery:
<location>{
for $list in fme:get-list-attribute("_list{}.LCS_CODE") for $Startlist in fme:get-list-attribute("_list{}.Start Meterage 1") for $Endlist in fme:get-list-attribute("_list{}.End Meterage 1")
return <part idEl="{$list}" startPos="{$Startlist}" endPos="{$Endlist}" />
}</location>
A bit of a side second question…. In the example outputs from the customer I have the XML for the “part” element will just end /> (below), which is what I have put in the XMLUpdater (<part idEl="{$list}" startPos="{$Startlist}" endPos="{$Endlist}" />) but my output seems to be ></part> after my attributes, does this matter? I’ve been given a specific XSD to follow.
Example desired output
<location>
<part id=”D202/DEBLO” startPos=”0.00” endPos=”158.44”/>
<part id=”D203/DEBLO” startPos=”0.00” endPos=”130.77”/>
<part id=”D204/DEBLO” startPos=”54.98” endPos=”1097.19”/>
</location>
My current output
<location>
<part idEl="B077/MSBFA" startPos="0" endPos="149.302"></part>
<part idEl="B077/MSBLO" startPos="0" endPos="133.761"></part>
</location>
As a bit of background info this is part of a larger project where I have been given a rather massive XSD to map several of our GIS and Excel datasets to, this is just for one particular dataset. As I say I’m totally new to XML and have read through the W3 schools info to get a bit more acquainted but if anyone knows any other FME-XML specific resources it’s appreciated!
Thanks in advance!