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

Post here questions and problems related to editing and publishing DITA content.
protl
Posts: 13
Joined: Mon Dec 18, 2017 10:52 pm

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

Post 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?
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

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

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
protl
Posts: 13
Joined: Mon Dec 18, 2017 10:52 pm

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

Post by protl »

Thanks Radu! Your suggestion to use an individual KEYDEF element for each condition works well.
Post Reply