How to create a new button in oxygen and on click that button need to insert the tags and current date?

Post here questions and problems related to oXygen frameworks/document types.
venkatesh
Posts: 7
Joined: Mon Sep 25, 2023 7:31 am

How to create a new button in oxygen and on click that button need to insert the tags and current date?

Post by venkatesh »

Hi,

I want to create new button in oxygen and if user click that button insert the tags and current date and scenarios as mentoined below

Scenarios :
Case 1 :
User clicks button in Oxygen, prolog , change history list and change item elements appears change completed with current date and time and change summary appears , user adds modification

Case 2:
If prolog element already exists:
user clicks the button and change -history list added with change item and change completed with curretn date and time and change summary and user adds modifications

Case 3:
If prolog element and change history list already exist:
user clicks the button and change item is added with change completed with current date and time and change summary and user adds modifications
Thanks
Venkatesh
Radu
Posts: 9041
Joined: Fri Jul 09, 2004 5:18 pm

Re: How to create a new button in oxygen and on click that button need to insert the tags and current date?

Post by Radu »

Hi Venkatesh,
What type of XML vocabulary are you editing? Is it DITA XML or something else?
What you want looks similar to what our free Prolog Updater add-on for DITA XML content does:
https://www.oxygenxml.com/doc/versions/ ... dater.html
Only that our prolog updater updates the prolog automatically when the content is saved.
Our prolog updater add-on is implemented as an open source Oxygen Java plugin:
https://github.com/oxygenxml/oxygen-dit ... ater-addon

Coming back to what you requested, if the end user is edited the XML content in the Author visual editing mode and you want this for DITA XML topics, you can extend the DITA framework customization and add your own custom Author actions to the toolbar, menus:
https://blog.oxygenxml.com/topics/custo ... etion.html

Each custom Author action can have multiple activation xpath expression, each expression with a custom operation which can be invoked when that Xpath expression is evaluated to true:
https://www.oxygenxml.com/doc/versions/ ... ialog.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
venkatesh
Posts: 7
Joined: Mon Sep 25, 2023 7:31 am

Re: How to create a new button in oxygen and on click that button need to insert the tags and current date?

Post by venkatesh »

Hi Radu,
I am using DITA XML
I will refer the attached links and try to implement them

Thanks
Venkatesh
venkatesh
Posts: 7
Joined: Mon Sep 25, 2023 7:31 am

Re: How to create a new button in oxygen and on click that button need to insert the tags and current date?

Post by venkatesh »

Hi Radu,
Prolog Updater: https://www.oxygenxml.com/doc/versions/ ... dater.html ,
https://github.com/oxygenxml/oxygen-dit ... ater-addon
I have tried with prolog updater addon this method not satisfying the current requirement.

Adding a Custom Author Action to the Content Completion Window :
https://blog.oxygenxml.com/topics/custo ... etion.html
I have tried with Adding a Custom Author Action, from this I am able to create three separate buttons for each scenario.
Now I want to merge or create one specific button that button should include all three scenarios.

or Is there any way to include if else conditions in InsertFragmentOperation?
Thanks,
Venkatesh
Radu
Posts: 9041
Joined: Fri Jul 09, 2004 5:18 pm

Re: How to create a new button in oxygen and on click that button need to insert the tags and current date?

Post by Radu »

Hi Venkatesh,
I have tried with prolog updater addon this method not satisfying the current requirement.
Ok.
I have tried with Adding a Custom Author Action, from this I am able to create three separate buttons for each scenario.
Now I want to merge or create one specific button that button should include all three scenarios.
Great, now we need to reduce the three actions you created to one action which does three things, depending on the context.
As I previously told you each custom Author action can have multiple activation xpath expression, each expression with a custom operation which can be invoked when that Xpath expression is evaluated to true:
https://www.oxygenxml.com/doc/versions/ ... ialog.html
So an Author action when customized can have multiple XPath activation contexts, in each of these contexts calling a different Author operation.
I'm attaching two screenshots showing how I recently configured for our needs an action which has 4 activation contexts and inserts content in the prolog or if the prolog is missing inserts the prolog with the content inside it:
Screenshot 2023-10-03 at 13.36.17.png
Screenshot 2023-10-03 at 13.36.17.png (226.75 KiB) Viewed 1304 times
Screenshot 2023-10-03 at 13.36.25.png
Screenshot 2023-10-03 at 13.36.25.png (245.81 KiB) Viewed 1304 times
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
venkatesh
Posts: 7
Joined: Mon Sep 25, 2023 7:31 am

Re: How to create a new button in oxygen and on click that button need to insert the tags and current date?

Post by venkatesh »

Hi Radu,
I am able to write the xpaths expression for three scenarios, but when i am trying to execute the three scenarios it's working fine for up to only two scenarios and third scenario not working.
I'm attaching two screenshots for three scenarios and please review and suggest me where i am wrong?
1.Case
Screenshot 1.png
Screenshot 1.png (67.36 KiB) Viewed 1274 times
2.Case
Screenshot 2.png
Screenshot 2.png (67.66 KiB) Viewed 1274 times
3.Case
Screenshot 3.png
Screenshot 3.png (67.15 KiB) Viewed 1274 times

Code: Select all

<topic id="topic_kr1_gmr_zyb">
        <title>Topic Added</title>
        <prolog>
            <change-historylist id="topic_obt_j4r_zyb">
                <change-item>
                    <change-completed>2023-10-04 3:35</change-completed>
                    <change-summary/>
                </change-item>
            </change-historylist>
        </prolog>
    </topic>
Case 3:
In Case 3 Need to get only below code

Code: Select all

<change-item>
 <change-completed>2023-10-04 3:35</change-completed>
  <change-summary/>
   </change-item>
Thanks
Venkatesh
Radu
Posts: 9041
Joined: Fri Jul 09, 2004 5:18 pm

Re: How to create a new button in oxygen and on click that button need to insert the tags and current date?

Post by Radu »

Hi Venkatesh,
So focusing on the third XPath activator, it is something like this:

Code: Select all

ancestor-or-self:: *[contains @class, ' topic/change-historylist"')]
This means that the action will have the xpath context enabled and call the operation only when the caret position is inside the "change-historylist" element or a descendant of it. Is this what you want?
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
venkatesh
Posts: 7
Joined: Mon Sep 25, 2023 7:31 am

Re: How to create a new button in oxygen and on click that button need to insert the tags and current date?

Post by venkatesh »

Hi Radu,
Yes this action will have the xpath context enabled and inside this "change-historylist" is already present in this scenario.
i want to add only below part

Code: Select all

 <change-item>
 <change-completed>2023-10-04 3:35</change-completed>
  <change-summary/>
   </change-item>
this xpath expression i have tried but it's not working.
ancestor-or-self::*[contains(@class, ' topic/topic ')][*[contains(@class, ' topic/prolog')]][*[contains(@class, ' topic/change-historylist')]][*[contains(@class, ' topic/change-item')]]
ancestor-or-self:: *[contains(@class, ' topic/change-historylist')]
Thanks
Venkatesh
Last edited by venkatesh on Thu Oct 05, 2023 8:22 am, edited 1 time in total.
Radu
Posts: 9041
Joined: Fri Jul 09, 2004 5:18 pm

Re: How to create a new button in oxygen and on click that button need to insert the tags and current date?

Post by Radu »

Hi Venkatesh,

The activation XPath in this case should look like this (I will write it on multiple lines just to show its structure more clearly:

Code: Select all

ancestor-or-self::*[contains(@class, ' topic/topic ')][
    *[contains(@class, ' topic/prolog')][
       *[contains(@class, ' relmgmt-d/change-historylist ')][
        *[contains(@class, ' relmgmt-d/change-item ')]       
    ]    
   ]
]
Here is some advice:
1) When you place the caret inside a DITA XML element in Oxygen, you can look in the "Attributes" view to see the default value for the "class" attribute. For example the "change-historylist" has the default class value "+ topic/metadata relmgmt-d/change-historylist " so I'm matching in the XPath expression the last token "relmgmt-d/change-historylist" from the list of values.
2) If you open a DITA topic in Oxygen containing some content like this:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="getting_started">
  <title>Getting Started</title>
  <prolog>
    <change-historylist>
      <change-item>
        <change-completed />
      </change-item>
    </change-historylist>
  </prolog>
  <body>
    <p>CARET_HERE</p>
  </body>
</topic>
and place the caret in that paragraph, you can use Oxygen "XPath" toolbar or "XPath/XQuery Builder" view to run an XPath expression and test it against the opened topic. In this way you can refine your XPath expressions until they start working and then you can use them in the framework customization.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
venkatesh
Posts: 7
Joined: Mon Sep 25, 2023 7:31 am

Re: How to create a new button in oxygen and on click that button need to insert the tags and current date?

Post by venkatesh »

Hi Radu,

I am able develope the history button based on sceanrios as mentoined above, but in change-person i need to get the full-name of logged person?
As of now I am able to get the user.name using this code <change-person>${system(user.name)}</change-person>.

Is there any system-properties to get the fullname of user?
Attachments
Screenshot (389).png
Screenshot (389).png (253.82 KiB) Viewed 509 times
Radu
Posts: 9041
Joined: Fri Jul 09, 2004 5:18 pm

Re: How to create a new button in oxygen and on click that button need to insert the tags and current date?

Post by Radu »

Hi,
There is this specific editor variable:
${author.name} - Expands to the current author name that is set in the Review preferences page.
https://www.oxygenxml.com/doc/ug-editor ... ables.html
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
venkatesh
Posts: 7
Joined: Mon Sep 25, 2023 7:31 am

Re: How to create a new button in oxygen and on click that button need to insert the tags and current date?

Post by venkatesh »

Hi Radu,

Thanks For your reply, i will refer the link

Thanks & Regards
Venkatesh


,
Post Reply