Skip to main content

Hallo! I want to set a global variable in an subtemplate which i can get from another subtemplate, is there any function possible ? Its like a gett- and sett-function.

Thanks for answers.

What are the "subtemplates"? Do you mean different two workspaces?

 

 


yes two different subtemplates (workspaces). Also how to define a variable in one workspace.


yes two different subtemplates (workspaces). Also how to define a variable in one workspace.

You can define a global variable with the VariableSetter.

 

However, the scope of a global variable is within the workspace which contains the variable definition, and its value exists only while the workspace is running.

 

I don't think there is a way to directly refer a variable defined in a workspace from another workspace.

 

 


yes two different subtemplates (workspaces). Also how to define a variable in one workspace.

Yeah but how can i set a variable into a template ? And how could i set the variable higher into a loop or something. (everything inside a template)

 

 


yes two different subtemplates (workspaces). Also how to define a variable in one workspace.

If i define a variable before i input that into my template, how can i access to that variable ?

 

 

i tried it with " b="$aVariable" ", but he show allways an error.

 


yes two different subtemplates (workspaces). Also how to define a variable in one workspace.

You can retrieve the value of a global variable defined by a VariableSetter only through the VariableRetriever. See the help to learn more.

 

 


yes two different subtemplates (workspaces). Also how to define a variable in one workspace.

But in an subtemplate (number 1) i can not set an variable where i can access on that value from an other subtemplate (number 2) ?

 

 

in subtemplate 1 i want to set the value in which road i be with an Value (1,2,3,...) and in subtemplate 2 i want to check if I'm in road 1 or 2 and so on to get the right nodes from my lanes.

 


yes two different subtemplates (workspaces). Also how to define a variable in one workspace.

As I mentioned before, the scope of a global variable is only within the workspace which contains the variable definition. There is no way to access a global variable in the first workspace from the second workspace.

 

You probably would have to consider other approach rather than global variables, in order to achieve your goal. We could think of a solution if you would explain the conditions and the requirements specifically.

 


yes two different subtemplates (workspaces). Also how to define a variable in one workspace.

Additionally, I would recommend you to use standard FME terms. "template" is not equal to "worksapce". "subtemplate" is not clear.

 

See also here: FME Terminology

 

 


yes two different subtemplates (workspaces). Also how to define a variable in one workspace.

The template is structured in "Root Template" and "Sub Template" and also "Geometry Template". And i want to set a variable in my sub template "ROAD" and get it in my sub template "GEOMETRY". (shown in the picture)

 

 


yes two different subtemplates (workspaces). Also how to define a variable in one workspace.

That was another story. "templates" - XML template expressions written in the XMLTemplater transformer won't be called "workspaces".A variable defined in an XML template expression cannot be accessed from any other XML template expression, even though the two expressions are sub templates belonging to an identical XMLTemplater transformer.

 


yes two different subtemplates (workspaces). Also how to define a variable in one workspace.

Okay if that is impossible to get one variable from one subtemplate to an other i have to go an other way to create an .xml structure. Which other possible way's could i go to create an xml file with a defined structure ?


Reply