Unwanted behavior: Author converts hyphens in the topic file name to underscores in the id

Post here questions and problems related to editing and publishing DITA content.
Graham Hannington
Posts: 49
Joined: Mon Jun 13, 2016 11:23 am

Unwanted behavior: Author converts hyphens in the topic file name to underscores in the id

Post by Graham Hannington »

Historically (sorry, I can't cite a specific Oxygen XML Author version), when I duplicated a DITA topic and saved the duplicate with a new file name, such as prodx-intro.dita (note the hyphen in the file name), Author automatically set the root element id attribute value to the file name without the file extension. For example: id="prodx-intro". I liked that.

However, when generating the id attribute, Author 26.1 replaces hyphens in the file name with underscores. For example: id="prodx_intro". I don't like that.

I know how to "revert" this unwanted behavior:
  1. Select Options > Preferences > DITA > Topics
  2. Under New Topics: "Use the title to generate the file name", which is selected by default, change the value of "Replace non-alphanumeric characters" from an underscore (_) to a hyphen (-).
Note: "Use the file name as the value of the root ID attribute" is selected by default.

I'm bothering writing about this for a few reasons, including:
  • I don't like this fix. It feels like a hack. It doesn't feel right to me to change a suboption of "Use the title to generate the file name" to change the generated id attribute value when, in my case, I'm manually specifying the file name.
  • I'm wondering if this change in behavior is due to a change in the "proprietary" DITA framework I'm using rather than a change in Author itself. I'm using Author to edit DITA topics that use organization-specific DITA DTDs. That organization used to supply an installation of Author precustomized for those DTDs. However, recently, that organization changed to supplying a separate, cut-down version of those customizations that now have to be applied post-install. Possibly related: when I select Refactoring > XML Refactoring, I now no longer see "Change topic ID to file name" as a refactoring operation for DITA topics with these organization-specific DTDs.
Is there a different, "cleaner" (non-hack-y) customization that I can make to revert this unwanted "new" behavior?
Radu
Posts: 9299
Joined: Fri Jul 09, 2004 5:18 pm

Re: Unwanted behavior: Author converts hyphens in the topic file name to underscores in the id

Post by Radu »

Hello Graham,
Indeed in Oxygen 26.1 we had a change in behavior in this regard as before Oxygen 26.1 the generated IDs would always contain "_" inside them and we had users who wanted to be able to control them to be "-" hyphen instead. Maybe we should have added a separate setting, I added an internal issue based on your report, pasting the issue ID below for future reference:
EXM-55055 Duplicate DITA topic - default ID generation settings changed
If we fix the issue in a future version we will update this forum thread.
In the meantime you can use the setting you discovered.
However, recently, that organization changed to supplying a separate, cut-down version of those customizations that now have to be applied post-install. Possibly related: when I select Refactoring > XML Refactoring, I now no longer see "Change topic ID to file name" as a refactoring operation for DITA topics with these organization-specific DTDs.
The lack of this specific XML refactoring is probably related to the fact you have a custom DITA framework which no longer ships it, this being a separate problem than the generation of the ID value you mentioned above.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Graham Hannington
Posts: 49
Joined: Mon Jun 13, 2016 11:23 am

Re: Unwanted behavior: Author converts hyphens in the topic file name to underscores in the id

Post by Graham Hannington »

Radu wrote: Tue Nov 26, 2024 1:34 pm Indeed in Oxygen 26.1 we had a change in behavior in this regard [...] Maybe we should have added a separate setting, I added an internal issue based on your report
Thanks for the confirmation/clarification and for creating that internal issue. Just my opinion: yes, I think a separate setting would be "cleaner".
The lack of this specific XML refactoring is probably related to the fact you have a custom DITA framework which no longer ships it
Yes, I wasn't sure about that, thanks for the advice.

Very helpful, detailed response as always, Radu. Thank you!
Post Reply