Home Forums DITA and XMetaL Discussion WebHelp Link on Image Not Working Reply To: WebHelp Link on Image Not Working

Derek Read

Reply to: WebHelp Link on Image Not Working

The most logical solution is to place your inside an element, so that you have this in your XML:


That makes the most sence with regard to the DITA markup and available elements. If you do that the DITA OT will also produce the HTML you need:


…and all browsers will take you to that location (usually by opening a new window or tab) when you click on the image.
Note the absense of an id attribute. That is the key here.

One point of clarification as well. This is not a “Webhelp” issue, it affects all HTML-based outputs generated by the DITA OT (Webhelp is just one of the consumers of the HTML generated by the DITA OT).

So, why aren't you getting that result? It must be because you have an id attribute set on your . For any element with an id attribute set on it the DITA Open Toolkit puts before that element in HTML output. It does this blindly without much (or any) regard for the element type or the context (I have not actually read through the XSLT to see which it is). The assumption the DITA OT is making here seems to be that you may want to link to that HTML content from somewhere (or allow someone else on the Internet to link to that content I suppose). This means that if you have this in your XML:


…then the DITA OT will produce something like this:



This is well-intensioned because, in theory, now anyone can link to that first .

However, and unfortunately as you have seen, the major browsers (perhaps all browsers) do not treat such an image as a link (clickable).

Having nested links actually breaks the rules for XHTML 1.0 (the DOCTYPE that the DITA OT claims to be generating HTML to validate against) so that is probably why browsers don't have support for this (though they support lots of other wacky non-standard stuff — go figure). I will follow up with the DITA OT project at SourceForge regarding this particular issue. I can see how this might have been overlooked because you cannot validate a document using the XHTML DTD to catch this issue and it is listed in a fairly obscure section http://www.w3.org/TR/xhtml1/#prohibitions) that was originally written in the 1990s and just carried forward to later specs.

So, that explains why things aren't working for you…

One solution (the easiest) is to manually remove any id attributes that had been previously set for images in files that you had already saved and that you want to treat as links in your output.

However, keep in mind that by default XMetaL Author Enterprise is configured to set id attributes for elements automatically (and this occurs during save for missing id values). You can (and will need to) turn that feature off for the image element in Tools > DITA Options dialog. On the General tab in that dialog you will need to select the Options button next to the “Auto-assign element ids” checkbox and then remove “image” from the list of elements to auto-id. If you can't follow what I just said then have a look in the Help (F1) under the topic “DITA options” which explains the “auto-id” feature.

Of course this would mean that if you wish to have @id set on some elements (to get the default DITA OT output for them or so that you can use them with @conref or possibly other reasons) you would need to manually set an @id for them.

If that is not acceptable then the XSLT that generates the HTML (as part of the DITA Open Toolkit) would need to be modified. You could do that for all cases (try to suppress this surrounding by for all elements) or you might implement some conditional code instead (“is the parent of this image an xref?” type of logic). Alternatively, you could take advantage of the DITA @outputclass and then modify the DITA OT to handle elements with that attribute set to a specific value in your special way.