Skip to main content
Solved

XML Templater - Xquery Loop through List Variable

  • April 12, 2019
  • 2 replies
  • 82 views

Forum|alt.badge.img+1

I am creating an XMLtemplate that loops through all the id\\value pairs in a list and creates an XMLelement for each.

I got the looping working after reading through some of @takashi's post replys, but the $i variable is not getting passed correctly into the fme:get-attribute function on the list number. Am I going about this wrong? Is there a different way that I need to call the variable inside the function?

 

<update_transaction object="ObjectNameHere">

{for $i in (1 to xs:integer({fme:get-attribute("_Result_count")}))

return (

<attribute_value name="{fme:get-attribute("Inspection.Results.Result{$i}.id")}">{fme:get-attribute("Inspection.Results.Result{$i}.Value")}</attribute_value>

)

}

</update_transaction>

 

 

Best answer by bhornung

I fixed it using xquery concatenation ||

<attribute_value name="{fme:get-attribute("Inspection.Results.Result{"||$i||"}.id")}">{fme:get-attribute("Inspection.Results.Result{"||$i||"}.Value")}</attribute_value>

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

Forum|alt.badge.img+1
  • Author
  • 7 replies
  • April 12, 2019

I currently am getting this when I run the Templater:

 

<?xml version="1.0" encoding="UTF-8"?>

 

<task format="sw_standard 1.0">

 

<task_attributes>

 

<assigned_to/>

 

<date/>

 

<priority>Normal</priority>

 

<reference_id>FileName Without Time Stamp</reference_id>

 

<sender/>

 

<title>Filename + _TM</title>

 

<type>Maintenance</type>

 

</task_attributes>

 

<properties/>

 

 

<data>

 

<update_transaction object="BuildThisInAttributeManager">

 

 

<attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/>

 

 

 

</update_transaction><update_transaction object="BuildThisInAttributeManager">

 

 

<attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/><attribute_value name=""/>

 

 

 

</update_transaction>

 

</data>

 

</task>

Forum|alt.badge.img+1
  • Author
  • 7 replies
  • Best Answer
  • April 12, 2019

I fixed it using xquery concatenation ||

<attribute_value name="{fme:get-attribute("Inspection.Results.Result{"||$i||"}.id")}">{fme:get-attribute("Inspection.Results.Result{"||$i||"}.Value")}</attribute_value>