Page 1 of 1

If an html type of KEYDEF has more than one possible values, can you configure the href attribute to match the URL?

Posted: Fri Jan 05, 2018 4:29 am
by protl
My Oxygen project has a .ditamap file that contains the reusable variables for my project. Each variable is defined as a KEYDEF value, and we use different KEYWORD values, with a condition applied, to supply the variable value for different outputs. For example:

Code: Select all


<keydef keys="productNameLong">
<topicmeta>
<keywords>
<keyword product="product-1">Product One</keyword>
<keyword product="product-2">Product Two</keyword>
</keywords>
</topicmeta>
</keydef>
In some cases, the KEYDEF is a placeholder for a URL that we want to select when inserting a link (DITA menu > Link > Web Link, Key option), and it has this format:

Code: Select all


<keydef keys="pdn-ma-page" href="https://pdn.pega.com/products/pega-marketing" format="html" scope="external">
<topicmeta>
<linktext>https://pdn.pega.com/products/pega-marketing</linktext>
</topicmeta>
</keydef>
Question: Is it possible to format an "html" type KEYDEF (like the one shown above) so that both the "href" attribute and "linktext" value can vary, based on the transformation? For example, could I apply the conditional attribute "product" to the LINKTEXT element (e.g., <linktext product="product-1">) to vary the link text, and then somehow also use this same value for the "href" attribute?

Re: If an html type of KEYDEF has more than one possible values, can you configure the href attribute to match the URL?

Posted: Fri Jan 05, 2018 11:00 am
by Radu
Hi,

You could try something like:

Code: Select all


      <linktext><ph product="prod1">https://pdn.pega.com/products/pega-marketing2</ph><ph product="prod2">https://pdn.pega.com/products/pega-marketing2</ph></linktext>
or redefine completely the key:

Code: Select all

<keydef keys="pdn-ma-page" href="https://pdn.pega.com/products/pega-marketing"
format="html" scope="external" product="product1">
<topicmeta>
<linktext>https://pdn.pega.com/products/pega-marketing</linktext>
</topicmeta>
</keydef>

<keydef keys="pdn-ma-page" href="https://pdn.pega.com/products/pega-marketing2"
format="html" scope="external" product="product2">
<topicmeta>
<linktext>https://pdn.pega.com/products/pega-marketing2</linktext>
</topicmeta>
</keydef>
Regards,
Radu

Re: If an html type of KEYDEF has more than one possible values, can you configure the href attribute to match the URL?

Posted: Fri Jan 05, 2018 7:07 pm
by protl
Thanks Radu! Your suggestion to use an individual KEYDEF element for each condition works well.