Page 1 of 1

Variables for document template

Posted: Fri May 10, 2019 3:12 pm
by antoterrence
We have a custom bookmap template that contains references to collections or reusable components. Templates sit in a fixed folder. However, the referenced reusable files are in a variable path. When the user creates a new bookmap using the custom bookmap template, the references are broken. Is there a way to use a variable for the file path?

Re: Variables for document template

Posted: Mon May 13, 2019 2:42 pm
by Radu
Hi,

Inside the DITA Map template's XML content you can use Oxygen editor variables which will be automatically expanded when the end user creates a new file based on the template.
For example you could use something like:
https://www.oxygenxml.com/doc/versions/ ... ables.html

Code: Select all

<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "map.dtd">
<map>
    <title>ABC</title>
    <topicref href="${makeRelative(${currentFileURL}, ${pdu}/reusables/reusable.dita)}"/>
</map>
But there is a potential problem, when you use File->New to create a new DITA Map based on the new file template there is a "Save as" field with a checkbox next to it. If the checkbox is checked by the end user and they decide the place on disk where to place the DITA Map and its name, then Oxygen will know how to expand the "${currentFileURL}" editor variable. But if the end user unchecks the "Save as" checkbox Oxygen will create an untitled DITA Map and will no longer know how to expand the "${currentFileURL}" editor variable because the end user has chosen not to save it to disk when creating the content from the new file template.
So you would need to instruct the end user to always use the "Save as" field when creating a new DITA Map from the template and specify a location for the newly created DITA Map.

Regards,
Radu

Re: Variables for document template

Posted: Mon May 13, 2019 3:23 pm
by antoterrence
Thank you. I got this to work. In some cases, the expanded path is an absolute path and not a relative path. That will cause potential portability issues.