Skip to main content
Hi all,

 

 

I'm working with the  XMLTemplater and would like to know if it's possible to conditionally process subtemplates.

 

 

ie if attr1 = "a" then {fme:process-template("X")} else {fme:process-template("Y")}
Hi,

 

 

I think you can use this syntax.

 

-----

 

{if(fme:get-attribute("attr1") eq "a") then {fme:process-template("X")} else {fme:process-template("Y")}}

 

-----

 

 

Takashi
Thank you, that did exactly what I needed. Where did you find the syntax?
I found this description and example in the help doc of the XMLTemplater ;)

 

---

 

A common use case is to write out an XML element only if a feature attribute has a value. To do this, an if-then-else statement is used. The following example writes out the displayName element only if the feature contains a display_name attribute, and value of the attribute is not an empty string.

 

 

<road>

 

{ if( fme:has-attribute("display_name") and 

 

      not(fme:get-attribute("display_name") eq "") )

 

then <displayName>{fme:get-attribute("display_name")}</displayName>

 

else ()

 

}

 

</road>

Reply