Add Attributes at File Creation

Are you missing a feature? Request it's implementation here.
thedantanner
Posts: 19

Add Attributes at File Creation

Thu Nov 30, 2017 2:04 am

It would be very convenient (for me anyway) to be able to add certain attributes when creating new files in Oxygen. For example, all of our .XML and .ditamaps files include the attributes: product, revision, and language. We also use custom ID's for each file. Currently, we either have to enter these attributes manually, or generate the files with a tool we've set up in Access. I like having all of my tools in one place, so it would be cool if Oxygen allowed you to set these attributes from the NEW dialog box instead (or a subsequent dialog box that appears after the NEW dialog box).
Radu
Posts: 5129

Re: Add Attributes at File Creation

Thu Nov 30, 2017 10:20 am

Hi,

You can define your own DITA new file templates:

http://blog.oxygenxml.com/2015/12/sharing-new-custom-file-templates-for.html

and the XML content of each new file template can contain inside Oxygen-specific editor variables which are automatically expanded by Oxygen when a file gets created:

https://www.oxygenxml.com/doc/versions/19.1/ug-editor/topics/editor-variables.html

One of the useful editor variables is called ${ask} and it allows you to ask the end user for a certain value which will get expanded in place of the editor variable.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
thedantanner
Posts: 19

Re: Add Attributes at File Creation

Thu Nov 30, 2017 8:06 pm

This is a very helpful feature. Thanks for pointing me in the right direction.

I have created my custom extension which seems to be working exactly as the blog described.

The part where I'm getting in over my head is with the editor variables. I did follow the link you provided, but since I'm still pretty new to all of this, it was a little too broad for me to understand how to apply to my specific need. So perhaps you could offer a little guidance by explaining how to set up one particular customization?

For example... When I select file... new... and then select my "custom task", I give it a file name, chose the save directory, and press OK. At that point, if possible, I'd like Oxygen to ask me to enter the "product" attribute.

I appreciate your constant assistance.

Dan
Radu
Posts: 5129

Re: Add Attributes at File Creation

Mon Dec 04, 2017 11:31 am

Hi Dan,

If you created in your custom framework a "customTask.dita" which has your custom DITA task contents, inside it you can use editor variables like for example:

Code: Select all

<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="task_${id}">
    <title>${caret}</title>
    <shortdesc></shortdesc>
    <prolog>
        <author>${ask('Author name?', generic)}</author>
    </prolog>
    <taskbody>
        <context>
            <p></p>
        </context>
        <steps>
            <step>
                <cmd></cmd>
            </step>
        </steps>
    </taskbody>
</task>


There are various editor variables in the task file template contents above and they will all get expanded, most of them automatically, for example the ${caret} will signify the initial location of the caret after the file is opened in Oxygen.
But the $ask editor variable will ask you a question, receive the answer from you and use that content to populate the template file.

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 0 guests