Page 1 of 1
Dynamically change a chunk of content within a conref?
Posted: Wed Nov 29, 2023 9:18 pm
by gchale3rd
I created a series of DITA task topics that explain how to create different configuration items in our portal. There are some steps that are the same for all types of configurations. I documented these reusable steps in a collection file and inserted them into the task topics using a conref.
There is one reusable step in which I would like to cite the configuration based on the topic in which the conref is used. Is it possible to dynamically change the configuration type cited in the conref based on the configuration type associated with the topic? Consider the following example steps that would be referenced in task topics for three different types of configurations: proxy, SAML, and container.
- In the Comment field, enter the reason for creating the proxy.
- In the Comment field, enter the reason for creating the SAML.
- In the Comment field, enter the reason for creating the container.
The only solution I have come up with is to put the reusable step content minus the configuration type in a <ph> element. For example:
Code: Select all
<ph id="configuration_reason">In the <uicontrol>Comment</uicontrol> field, enter the reason for creating the</ph>
In each task topic, I would conref the <ph> element into the appropriate step and add the configuration type as static text after the conref. For example:
Code: Select all
<step>
<cmd><ph conref="../_common/t_coll_config_tool.dita#t_coll_config_tool/configuration_reason"/> proxy.</cmd>
</step>
I appreciate your thoughts.
I am using Oxygen XML Editor 25.1.
Re: Dynamically change a chunk of content within a conref?
Posted: Thu Nov 30, 2023 12:33 pm
by Radu
Hi,
I think what you want would be possible if you used DITA key scopes with key refs and content key references.
The DITA Map would look like this:
Code: Select all
<topicref href="myTask.dita" keyscope="ks">
<keydef keys="variableSuffix">
<topicmeta>
<keywords>
<keyword>prefix</keyword>
</keywords>
</topicmeta>
</keydef>
<keydef keys="reusableSteps" href="reusableSteps.dita"/>
</topicref>
with "reusableSteps.dita" looking like:
Code: Select all
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="reusableSteps">
<title></title>
<taskbody>
<steps>
<step id="reused">
<cmd>some content here <ph keyref="variableSuffix"/></cmd>
</step>
</steps>
</taskbody>
</task>
and the "myTask.dita" containing a
Code: Select all
<step conkeyref="reusableSteps/reused"/>
But this might in a way complicate things also make things more difficult for translations as it's best to translate entire block elements and not to translate individual texts which end up being concatenated together.
Regards,
Radu
Re: Dynamically change a chunk of content within a conref?
Posted: Thu Nov 30, 2023 8:34 pm
by gchale3rd
Thank you Radu. I will experiment with your suggestion.
Re: Dynamically change a chunk of content within a conref?
Posted: Tue Dec 05, 2023 3:03 am
by gchale3rd
I tried using the key scope you suggested. Instead of each topic displaying the keyword defined in its corresponding <topicref> element, all of the topics display the key word that was defined in the first <topicref> element.
Here is the example you provided for the map. I expanded this example by adding two additional <topicref> elements.
Code: Select all
<topicref href="myTask1.dita" keyscope="ks">
<keydef keys="variableSuffix">
<topicmeta>
<keywords>
<keyword>prefix1</keyword>
</keywords>
</topicmeta>
</keydef>
<keydef keys="reusableSteps" href="reusableSteps.dita"/>
</topicref>
<topicref href="myTask2.dita" keyscope="ks">
<keydef keys="variableSuffix">
<topicmeta>
<keywords>
<keyword>prefix2</keyword>
</keywords>
</topicmeta>
</keydef>
<keydef keys="reusableSteps" href="reusableSteps.dita"/>
</topicref>
<topicref href="myTask3.dita" keyscope="ks">
<keydef keys="variableSuffix">
<topicmeta>
<keywords>
<keyword>prefix3</keyword>
</keywords>
</topicmeta>
</keydef>
<keydef keys="reusableSteps" href="reusableSteps.dita"/>
</topicref>
When I run the transformation scenario, the conkeyrefs in all three topics use the keyword prefix1, which is the keyword defined in the <topicref> element for the first topic. I was hoping to see prefix2 used in the conkeyref in topic2 and prefix3 used in the conkeyref in topic3.
I used the same @keyscope value in all three <topicref> elements. I also used the same @keys value in the <keydef> element containing the keyword.
Let me know if you have any thoughs.
Re: Dynamically change a chunk of content within a conref?
Posted: Tue Dec 05, 2023 10:10 am
by Radu
Hi,
I used the same @keyscope value in all three <topicref> elements.
You should try to use a different key scope value for each of these topicrefs, something like ks1, ks2, ks3. Otherwise the behavior will be as if all three are from the same key scope "ks" and the conkeyref will resolve to a single target in a key scope context.
If that does not work, maybe you can zip a small example and send it to us (
support@oxygenxml.com) and I can try to take a look at it.
https://www.oxygenxml.com/dita/1.3/spec ... copes.html
Key references in each key scope are resolved using the effective key definition that is specified within its own key scope.
Regards,
Radu
Re: Dynamically change a chunk of content within a conref?
Posted: Thu Dec 07, 2023 1:25 am
by gchale3rd
Using a unique @keyscope attribute value for each <topicref> element resolved the issue. I expanded by test by defining a second keyword (in a second <keydef> element within each key scope. That enabled be to substitute a second keyword in a different conkeyref within each topic. Thank you for your help Radu.
Re: Dynamically change a chunk of content within a conref?
Posted: Thu Dec 07, 2023 10:07 am
by Radu
Hi,
I'm glad this works for you!
Regards,
Radu