Home Forums DITA and XMetaL Discussion Publish of ditamap changes topicref href=…xml scope="external" to href=…html Reply To: Publish of ditamap changes topicref href=…xml scope="external" to href=…html

Derek Read

Reply to: Publish of ditamap changes topicref href=…xml scope="external" to href=…html

OK, I see the issue. The code that the DITA OT uses to generate the TOC file is what is putting in the link that you don't want and it appears to be due to lack of any special handling when it encounters a link to a *.xml filetype inside a . Additional code would need to be added to the DITA OT to handle this use case, possibly with the inclusion of some additional attribute in the to identify this as a special topicref when producing the TOC (I have not thought through the exact details and they might be driven by the underlying existing code).

If you modify the href value and the filename so that it is “example-txt-file.txt” this should become a little more clear. It handles it properly in this case, so the confusion would seem to be simply the *xml file extension. If you really need the DITA OT to support this scenario I would suggest you submit a defect here describing the issue: http://sourceforge.net/tracker/?group_id=132728&atid=725074

You would also need to contend with what will happen when the reader clicks on such a link in their browser (or whatever software they are using to view the HTML). Depending on the content in the XML file, in some cases the browser might render the XML itself (usually in the forum of a “node tree”, or perhaps as the XML source), in some browsers it might complain there is no DTD (if you include a DOCTYPE), or it might attempt to pass the file to another application to open it. I'm not sure what you would expect. If the intention is to allow people to copy the XML for use elsewhere what will end up on the clipboard may also differ depending on how it is being rendered.

It might be more predictable to link to another file type that contains the same XML content. Perhaps TXT is sufficient for your purpose (if that is merely to allow someone to view the content of the file)? What a web browser does in that case (when it encounters a file with a TXT extension) may also differ from browser to browser.

You might try these options as well:

Move the link into a DITA topic
1) Create a that links to a regular DITA topic.
2) Inside the DITA topic include an that links to your XML file and optionally includes an appropriate amount of content inside or around the to describe what the link is to and what it contains. In this case the DITA OT does not alter the link (it will continue to point the the *.xml file). In this case you are left with the issue of what a particular browser does when someone clicks on a link to an XML file (as discussed above).

Include the source of the XML inside a topic
1) Create a to a regular DITA topic.
2) Inside the topic include the full text of the XML document. You may include this inside various elements intended for this purpose, perhaps makes the most sense. To avoid the need to escape characters inside the XML and include it verbatim you may wish to place it within a CDATA section inside the element.
Example of what the DITA source XML might look like:


The DITA OT generates this when producing HTML from the DITA above:

<?xml version="1.0"?>
<!DOCTYPE foo PUBLIC "-//ORG//MY DOCTYPE//EN" "schemaname.dtd">



…which ends up looking like this in a browser after all the entities have been interpreted: