Generate @id based on child title?

Are you missing a feature? Request its implementation here.
shudson310
Posts: 156
Joined: Sat Feb 26, 2005 12:09 am
Location: USA
Contact:

Generate @id based on child title?

Post by shudson310 »

I found a way to set the ID options (framework -> ID Options), but haven't found a way to set the ID based on the value from a title child element.

For example, if I have:

Code: Select all

<section>
<title>Configuring the radio</title>
<p>blah</p>
</section>
I want to configure the Generate IDs to use the ${localName}_{$childTitle} such that the following is generated:

Code: Select all

<section id="section_ConfiguringTheRadio>
<title>Configuring the radio</title>
<p>blah</p>
</section>
If a new section is being inserted (and thus no title yet), the author could be prompted for the title, which would insert the <title> element and populate the @id appropriately.
Scott Hudson
Staff Content Engineer
Site: docs.servicenow.com
Radu
Posts: 9018
Joined: Fri Jul 09, 2004 5:18 pm

Re: Generate @id based on child title?

Post by Radu »

Hi Scott,

We do not have such functionality, especially that new elements are usually inserted with an empty title (or no title at all) and somehow the ID usually needs to be generated when the title is not available. Also the title may be modified in time... should the ID be regenerated also?

About this remark:
If a new section is being inserted (and thus no title yet), the author could be prompted for the title, which would insert the <title> element and populate the @id appropriately.
You can create a custom Author action which inserts the <section> element using editor variables. We have an editor variable called ${ask} which shows a message dialog to the end user allowing them to input some text. In Oxygen 20.1 which we plan to release in a couple of days you will have the ability to ask the end user for the title and then use it in multiple places in the inserted XML fragment. A problem I see is that for the ID you need to further process the title, remove spaces, lowercase letters, etc. We have another editor variable called xpath_eval which may be useful for this https://www.oxygenxml.com/doc/versions/ ... ables.html. After Oxygen 20.1 is released I will try to maybe put together a few steps in a blog post and update this issue.

Another approach is to create an Author action based on a Javascript code which uses our API to insert an XML fragment, like:

https://github.com/oxygenxml/javascript ... bute-value

Once you have a custom Author action, you can decide to replace the content completion window item which inserts a <section> with the action.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply