Page 1 of 1

How to insert reusable contents to multiple dita maps

Posted: Wed Mar 24, 2021 12:41 pm
by catherine
Hi, Dear Oxygen Support
Is there a way to set reusable contents, and apply the contents to multiple dita maps?

For now, we are developing a version of our product documentation.
The firmware version is variable during the development period.
For the topics that mention the firmware version, we use the text "20.3.0.X".

In this issue, can we set a reusable content to refer to firmware version, and insert the reusable contents to multiple dita maps?

When the firmware version is confirmed, we only change one place and apply to multiple places.

Is that possible?

Thanks and Regards

Catherine

Re: How to insert reusable contents to multiple dita maps

Posted: Wed Mar 24, 2021 1:56 pm
by Radu
Hi Catherine,

I might not understand exactly the entire use case.
Did you try to create a topic containing reusable DITA elements, place it in a common folder and add content references to it in various places? Or similarly create a small DITA submap containing reusable keys again referenced in multiple main DITA Maps? Did you encounter any difficulty in doing so?

Regards,
Radu

Re: How to insert reusable contents to multiple dita maps

Posted: Thu Mar 25, 2021 3:22 pm
by catherine
Hi, Radu
I thought that the keys defined in the reusable ditamap can be used directly in multiple places.
I was wrong.
As you mentioned, I need to insert the reusable ditamap as a sub ditamap in multiple main ditamaps, so that I can reuse the keys.

I corrected my usage, now it works. Thanks for your information, Radu.

One more question, is there any way to reuse keys for the name of dita file?

I have a dita file named "v20.3.0.X.dita".
Is there any way that I can use a key to control the file name.
When the text of the key changes, the name of the dita file changes automatically.

Best Regards,
Catherine

Re: How to insert reusable contents to multiple dita maps

Posted: Thu Mar 25, 2021 3:41 pm
by Radu
Hi Catherine,

How about if you define a key for the "v20.3.0.X.dita":

Code: Select all

<topicref href="v20.3.0.X.dita" keys="whats-new"/>
and you refer to that topic using keyref in all other places?
In this way, depending on how you define the "whats-new" key all references would change in the published output.
For example the main "v20.3.ditamap" would do:

Code: Select all

<topicref href="v20.3.0.X.dita" keys="whats-new"/>
<mapref href="commonDITAMap.ditamap"/>
but the DITA Map for another version would map the "whats-new" key to another href.

Or you can do things like this:

Code: Select all

<topicref href="v20.3.0.X.dita" keys="whats-new" product="v1"/>
<topicref href="v20.3.1.X.dita" keys="whats-new" product="v2"/>
and remove when publishing either one or the other key definition using a DITAVAL filter file.

Regards,
Radu

Re: How to insert reusable contents to multiple dita maps

Posted: Fri Mar 26, 2021 4:42 am
by catherine
Hi, Radu
I am sorry for my unclear description, and I guess you misunderstood my requirements.

I want to set a variable for the dita file name.
For example, [Variable-A].dita, when the [Variable-A] is set to 20.3.0.20, the dita file name changes to 20.3.0.20.dita automatically, is that possible?

If it is impossible to be achieved, is there any way to change the output file name for the dita file.
For example, the dita file is "20.3.0.X.dita", after we generate webhelp, the dita file can be changed to "20.3.0.20.html".
Any way we can control that?

Thanks,
Catherine

Re: How to insert reusable contents to multiple dita maps

Posted: Mon Mar 29, 2021 11:57 am
by Radu
Hi Catherine,

Please see some answers below:
For example, [Variable-A].dita, when the [Variable-A] is set to 20.3.0.20, the dita file name changes to 20.3.0.20.dita automatically, is that possible?
No. Not out of the box anyway.
If it is impossible to be achieved, is there any way to change the output file name for the dita file.
For example, the dita file is "20.3.0.X.dita", after we generate webhelp, the dita file can be changed to "20.3.0.20.html".
How about if you set the @copy-to attribute in the DITA Map like:

Code: Select all

<topicref href="20.3.0.X.dita" copy-to="20.3.0.20.dita"/>
?

Regards,
Radu

Re: How to insert reusable contents to multiple dita maps

Posted: Thu Apr 01, 2021 9:35 am
by catherine
Thanks, Radu
That's cool.
But it seems don't solve my problem as the value of @copy-to attribute cannot be set to a variable.

Best Regards,
Catherine

Re: How to insert reusable contents to multiple dita maps

Posted: Thu Apr 01, 2021 10:40 am
by Radu
Hi Catherine,

You can define XML entities in the DOCTYPE declaration of the DITA Map like for example:

https://github.com/oxygenxml/userguide/ ... fs.ditamap

Code: Select all

<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "map.dtd" [
<!ENTITY version "1.1">
]>
and then use XML entity references in attribute values like:

Code: Select all

<topicref href="&version;"/>
DITA kind of discourages the use of XML entities but they are the only way in which you can reuse content in attribute values.

Regards,
Radu