auto-generate DITA topic id from its file name

Post here questions and problems related to editing and publishing DITA content.
mstrubberg
Posts: 48
Joined: Sat Jan 26, 2013 6:07 pm

auto-generate DITA topic id from its file name

Post by mstrubberg »

I want to auto-generate the topic id from the file name. I tried applying this value on a DITA concept template id=c_${cfn} but it did not return the result I wanted.
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: auto-generate DITA topic id from its file name

Post by alex_jitianu »

Hi,

Unfortunately you can't use file based editor variables inside a file template. But I have added a feature request to support them too. Meanwhile, as an workaround, you could create an author action that changes the ID attribute value.

To create an author action you'll have to go to page Preferences->Document Type Association, then select the DITA frameworks and press Edit. In the opened configuration dialog first select the Author tab and then the Actions tab. Click on the new action located in the bottom right corner and the action configuration dialog is presented. I've attached a screenshot with how you could configure this action. Basically, the action will identify the topic ancestor and use ${cfn} editor variable as the new value for the ID. You can refine the XPath expression that identifies the element with the ID attribute in any way that you like.

Image


You can refine the XPath expression that identifies the element with the ID attribute in any way that you like.

Afterwards, just put this action on the toolbar and manually invoke it after the topic is opened in author mode. You'll have to use the Toolbar tab to configure the toolbar. You can also associate a shortcut to the action so that it's easier to use.

More information about how to create a new author action can be found at http://www.oxygenxml.com/doc/ug-editor/ ... olbar.html.
mstrubberg
Posts: 48
Joined: Sat Jan 26, 2013 6:07 pm

Re: auto-generate DITA topic id from its file name

Post by mstrubberg »

Thanks, This worked great.
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: auto-generate DITA topic id from its file name

Post by Radu »

Hi,

Just to update this thread, starting with Oxygen 15.0 new file templates can use editor variables related to the file which will get created like ${cfn}.
The only limitation in the standalone version is that this will not work when using the File->New action or toolbar button. But it will work when creating a new file from the Project view or when creating a new topic directly from the DITA Maps Manager view.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Eddie
Posts: 106
Joined: Wed Dec 18, 2013 3:07 am

Re: auto-generate DITA topic id from its file name

Post by Eddie »

Hello,

I'm just curious to know if there has been any further changes in this area.
As with the OP, we have a rule that the topic id should be the same as the file name, and we've recently had some objections from manual writers arguing that it's too much trouble and it's not a DITA requirement anyway.

I got the first workaround to work fine, but could not work out the second one.
Also, if you did get both workarounds to work, would they not clash with each other?

Cheers,

Eddie.
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: auto-generate DITA topic id from its file name

Post by alex_jitianu »

Hello Eddie,

There are no new additions regarding this support. If you get both workarounds to work, they will not clash with each other as they'll have the same effect: synchronize the ID with the file name. If you want we can try and figure out why the second workaround isn't working. Have you changed your DITA templates to contain the ${cfn} editor variable and are you creating new topics based on these templates? What action are you using to create the new topics? Like Radu mentioned, the File->New wont work...

Best regards,
Alex
Eddie
Posts: 106
Joined: Wed Dec 18, 2013 3:07 am

Re: auto-generate DITA topic id from its file name

Post by Eddie »

Hello Alex,

Thanks for the reply.
My mistake: I have oXygen 16 and 17 installed. I had 17 open, but was editing the template file of 16.
It's working fine now and it's just what we need.

Just out of interest, why doesn't changing the template work when you create from File->New?

Cheers,

Eddie.
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: auto-generate DITA topic id from its file name

Post by alex_jitianu »

Hello Eddie,

When you use File->New, the newly created topic is untitled until the first save event. Because of that, when the editor variable expanding is done, we don't have a file name for ${cfn}. Perhaps if we were to perform an additional expanding on the first save event we would catch this situation too...

Best regards,
Alex
Post Reply