Generate @id based on child title?

Are you missing a feature? Request it's implementation here.
shudson310
Posts: 130
Location: USA

Generate @id based on child title?

Mon Jun 11, 2018 9:09 pm

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
Content Strategist
Jeppesen
Site: jeppesen.com
Radu
Posts: 5760

Re: Generate @id based on child title?

Tue Jun 12, 2018 8:49 am

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/20.0/ug-editor/topics/editor-variables.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-sample-operations/tree/master/ask-for-attribute-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

Return to “Feature Request”

Who is online

Users browsing this forum: No registered users and 2 guests