Share Variable Definitions Across Targets

This forum is for Single-Sourcing your Flare content to multiple outputs.

Share Variable Definitions Across Targets

Postby doloremipsum on Mon Aug 26, 2019 4:00 pm

My documentation Flare projects include a large (and ever growing) number of variables which are stored in a Global project and shared via import files. Each variable has multiple definitions (mostly product names/codes which are different for the different companies we write for). The targets (also an ever growing number) are stored in the child projects because each target is used to produce multiple TOCs and therefore needs to be changed frequently.

The problem here is that if I update a secondary variable definition (i.e. not the default one) in the Global project, the update does NOT automatically carry through to the targets stored in my child projects. If variable set and target are edited in the same place, the Flare analyzer works its magic to update the target definition; but if they are not, the definition does not change even when the variable set is imported. I have to go through every target in multiple projects and update them, which almost defeats the purpose of having alternative variable definitions at all.

With some poking around, I found that the issue lies in how secondary variable definitions are encoded in the XML for targets. If the target in question only uses the defaults for variables, the XML is simply <Variables></Variables>. So at build time Flare goes and checks the default variable definitions and inserts them.

But if you use the dropdown menu in the Target Editor to select a secondary variable definition, you get this:
Code: Select all
<Variables>
    <Variable name="ProductA">ProductA Alternative Name</Variable>
</Variables>

See the issue? It's hard-coded in as if I had just typed something into the target editor. That means that at build time Flare never checks the variable set at all - it just looks at whatever was last set in the target.

Ideally I would like the XML code in the target to look for the definition in the variable set rather than a hard-coded name (e.g. <variable name="productA" definition="2">), and I've submitted a feature request to that effect. But in case that isn't forthcoming, I'd like an automated way of keeping all of these targets synchronised with the variable set.

I toyed with the idea of using XInclude and writing some kind of pre-build command to take the variable definitions from somewhere else (e.g. a target in the Global project) and overwrite the current target before it builds, but I think that's probably a little beyond my capacity. Does anyone have any other suggestions along those lines?
doloremipsum
Propeller Head
 
Posts: 22
Joined: Mon Aug 26, 2019 2:11 pm

Re: Share Variable Definitions Across Targets

Postby doc_guy on Tue Aug 27, 2019 4:22 pm

When you look at the XML source of the target file, you see the Variables section that you described. If you remove all contents from the variables section and just leave this:

Code: Select all
<Variables></Variables>


That should solve your problem.

What happens is this: If there is a variable set in a target, that overrides what is set in the Variable set, whether it is imported or not. If you don't want to have it overridden in a target, then you don't set it in the target.

However, the target editor doesn't have a good way of showing you whether the variable definition is being overridden by that target. So you have to open the file in the text editor and check for the <Variables> element.

By default, targets don't have anything set for variables. They will always have the definition set by the variable set. If you have content in your target's <Variables> element, that means that at some point, somebody came into the target settings and changed a setting for that variable.

So, basically, your solution is to open the target files in the code editor, and remove any content in the <Variables> element and save the file.

The next time you build that target, you will see that the variable name comes from the variable set, not the target.
User avatar
doc_guy
Propellus Maximus
 
Posts: 1947
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West

Re: Share Variable Definitions Across Targets

Postby doloremipsum on Wed Aug 28, 2019 1:24 pm

Yes - as I did mention in my original post, that is fine when you want to use the default variable definition in your target. But I have added alternative definitions to my variables, and I would like the target to reference those rather than the default definition. Instead, when I select those alternative definitions using the target editor, the definition is hard-coded into the XML.
doloremipsum
Propeller Head
 
Posts: 22
Joined: Mon Aug 26, 2019 2:11 pm

Re: Share Variable Definitions Across Targets

Postby Dave Lee on Thu Aug 29, 2019 1:39 am

Report it as a bug.
It works if you update the variable definition in a single project (if you update the variable definition, it updates it in the target too), but it doesn't work if you reimport a variable set that you've changed.

I use project imports quite a lot, and I've noticed that when you reimport files, Flare doesn't seem to recognise that there are new files in the project. For example, if I reimport some files and then click build, Flare still thinks the target is up-to-date, when clearly that is wrong. So it may be the case that when you reimport the variable set, Flare doesn't recognise this file as being updated, and doesn't trigger the process to update the variable in the target.
Dave Lee
Master Propellus Maximus
 
Posts: 5641
Joined: Mon Mar 05, 2007 8:33 am
Location: UK


Return to Single-Sourcing

Who is online

Users browsing this forum: No registered users and 4 guests