= FM Variables with XSLT =
||'''Version'''||'''Date'''||'''Changes'''||
||1.1||2010-09-09||Note about Automap. Also see "Discussion" page for tips on getting this to work.||
||1.0||2009-06-12||Initial version.||
== Description ==
ePublisher does not provide direct access to Framemaker variables in code. This topic shows how to use XSLT to retrieve the value of a Framemaker variable for use in transformations.
'''Note:''' This works with ePublisher Pro 9.2. It has not been tested with other versions. '''It does NOT work with Automap''' because Automap does not include the variables in the project.cache.
== How it works ==
When ePublisher does a "Scan All Documents" of a Framemaker book or document, it includes the Framemaker variables and values in the '''project.cache'''. The '''getfmvars.xslt''' transformation described below scans the cache and returns the value of a named variable. If it does not find the variables, it returns a default value passed in from the caller.
'''Note:''' Manually do a Scan All Documents (Ctrl+F7) before generating the project to produce an up-to-date cache or the variable is not guaranteed to match what is in the FM file. ePublisher does not do this automatically and there is no way to initiate it in code (at least not that I can find). Also, there is no test for different .fm files in the same book having different values for the same variable.
The '''project.cache''' file is in the data directory. Locate the file like this:
{{{
}}}
Once you have the file, retrieve the value of the variable whose name was passed in as a parameter, like this:
{{{
}}}
=== Calling getfmvars.xslt ===
This example calls the transformation by looking for a variable named ''BookName''. If that variable is not in the cache, it uses ''Default Book Title'' instead:
{{{
...
}}}
Errors are logged when the project cache does not exist, and when the named variable is not in the cache.
=== Code listing for getfmvars.xslt ===
This is the entire code listing for '''getfmvars.xslt''' when used as part of a Dynamic HTML format.
{{{
}}}
----
CategorySolutionsInputFrameMaker CategorySolutionsOutputXmlAndXsl