How to display insertattribute value in xml by default

Post here questions and problems related to editing and publishing DITA content.
kpuchaka
Posts: 12
Joined: Wed Sep 29, 2021 7:02 pm

How to display insertattribute value in xml by default

Post by kpuchaka »

Hello Experts,

I m inserting outputclass="partnumber" attribute in my xref element by using below entry in cc_config.xml:

<elementProposals path="xref" possibleElements="NONE">
<insertAttribute name="outputclass" value="partnumber"/>
</elementProposals>

The above one is working fine when i directly insert the <xref> element in my topic and i can see this outputclass="partnumber" in my xml view of the oxygen.

But i m using this <xref> element by using DITA reusbale key and when i insert the DITA key into my topic from DITA Resuable Component window,then it is inserting as <xref> element.In this case I can see outputclass="partnumber" value when i click on "Edit Attributes" of the element but that value is not showing in xml view.When i select that outputclass explicitly in attributes window,then it is selectable and displayed in my xml view.

We need this outputclass bydefault in xml view when <xref> element insert it.

Is there any way where we can achieve this ?how can we refresh this attribute value to make it display in xml by default?

When we insert thru DITA key,the structured would be like :
<xref keyref="SCREW_M2X4"/>

Please throw some pointers..

Regards
Kiran
alex_jitianu
Posts: 1007
Joined: Wed Nov 16, 2005 11:11 am

Re: How to display insertattribute value in xml by default

Post by alex_jitianu »

Hello,

Thank you for reporting this issue. I will record an issue in our internal issue tracking system to find the cause and we will write on this thread when a fix will be released.

Meanwhile, as a workaround, you can use our Java-based API to intercept all fragments being inserted and check if there is a xref without a @outputclass attribute. If one is found, the filter adds the missing attribute. If you want to explore this path, write to us on support@oxygenxml.com and I will give you more details and some code to get you started.

Best regards,
Alex
kpuchaka
Posts: 12
Joined: Wed Sep 29, 2021 7:02 pm

Re: How to display insertattribute value in xml by default

Post by kpuchaka »

Hi Alex,

Thank you so much for your prompt reply..

I would like to try with your workaround of using Java Based API and can you please provide me the step by step approach how to insert this in my oxygen and deployment steps?

Also please provide me the sample code for the same.

P.S:I have also sent an email to support@oxygenxml.com for the same

Thank you.

Regards
Kiran
kpuchaka
Posts: 12
Joined: Wed Sep 29, 2021 7:02 pm

Re: How to display insertattribute value in xml by default

Post by kpuchaka »

Hi Alex,

Your workaround is working and thank you so much for your help..!!

Regards
Kiran
kpuchaka
Posts: 12
Joined: Wed Sep 29, 2021 7:02 pm

Re: How to display insertattribute value in xml by default

Post by kpuchaka »

Hi Alex,

Based on your provided framework SDL,I tried to implement the custom author framework and it is working as expected..

Thank you so much for that..!!

But i m not clear about the classpath tab and extensions tab.Do we have any documentation link where we can find the processor of customization of author frame work?

Is oxygen providing any such document to refer for development purpose? If so, can you please share me the link of that document where it can explain the process of customization ,so that it will be useful for further customizations if i need to do any.

Please do the needful..

Regards
Kiran
alex_jitianu
Posts: 1007
Joined: Wed Nov 16, 2005 11:11 am

Re: How to display insertattribute value in xml by default

Post by alex_jitianu »

Hi Kiran,

I'm glad I could help! Here are some useful links:

https://www.oxygenxml.com/doc/versions/ ... undle.html
https://www.oxygenxml.com/doc/versions/ ... s-tab.html
https://www.oxygenxml.com/doc/versions/ ... h-tab.html

Oxygen offers a number of extension points on which one must set implementation of specific interfaces from our Java-based API. You set these implementations from the Extensions tab. When you want to set a value for such an extension point, Oxygen searches inside the jars specified in the Classpath tab for implementations that match that specific extension point.

In our Maven based SDK sample project there is a module called sample-framework with examples on how you can use our Java-based API for different use cases.

Best regards,
Alex
kpuchaka
Posts: 12
Joined: Wed Sep 29, 2021 7:02 pm

Re: How to display insertattribute value in xml by default

Post by kpuchaka »

Hi Alex,

Thank you so much for your prompt reply and help so far..!!

I just setup the project in my local and able to update the AuthorDocumentFilter class to insert outputclass based on our requirement. Now I want to check the possibility of using this same framework for another purpose.

We have one reference key map which contains all the reusable keys like below:
<topicgroup keyscope="Parts-In">
<keydef href="GUID-7566B055-F44F-4DFD-B501-AA95E5906C57" keys="12NC14" navtitle="UCM TOP STD FILTER /800B"/>
</topicgroup>

When we open this map in oxygen, then all the above keys were displayed in right side "DITA Reusable Components" window(see the attached document).
Then our technical authors will create userdefined keys in another map with the help of above created keys which are displaying in "DITA Reusable Components" window.
Sample of user defined keys map is below:
<topicref keydef="Parts-In.12NC14" keys="STS_TOP_FILTER" />

After complete the "User defined keys map" authoring,authors will check-in the map and during the checkin or before the checkin of the map, they wanted to validate all the keys mentioned in "DITA Reusable Components" window were addressed in their "User Defined Keys" map or not.

So is there any API method available to read the no.of keydef elements count in right side "DITA Reusable Components" window and also authoring "User Defined Keys" map xml file?If so,then we can match the actual count of keydef elements with "User Defined Key" map keydef values and if it is not same, then we can inform authors that "all the keys were not replaced.." some thing like this message.

Is the above scenario is possible? If so, can you please help me about that API?And also can we trigger that message during checking the "User defined keys" map?

If you think any other solution for this requirement, please advise me.
sample userdefined keys.PNG
sample userdefined keys.PNG (175.28 KiB) Viewed 2926 times
Please do the needful..!!

P.S:If you want me to move this to different thread, then I can create new thread next time.

Regards
Kiran
alex_jitianu
Posts: 1007
Joined: Wed Nov 16, 2005 11:11 am

Re: How to display insertattribute value in xml by default

Post by alex_jitianu »

Hi Kiran,

The DITAAccess.getKeys(URL) API will give you all the keys presented in the DITA Reusable Components view. Unfortunately, you'll need to parse "User Defined Keys" map yourself and build a data structure with the defined keys and their binding. You can implement such an action in your framework customization through an Author Action added on the toolbar, for example. This action must invoke a custom author operation . Inside the Java code of this custom operation is where you get the keys and compare them.

Best regards,
Alex
kpuchaka
Posts: 12
Joined: Wed Sep 29, 2021 7:02 pm

Re: How to display insertattribute value in xml by default

Post by kpuchaka »

Hi Alex,

Hope you are doing well..!!

I just tried to analyse the approach what you suggested to read the "User Defined Keys" map but i m struggling to read the complete xml file of that map into context.

I believe i need to do it under doOperation() method of custom author operation.

Do we have any inbuilt method to retrieve the complete xml of user defined key map, so that I can read the keydef elements to compare.
ex:authorAccess.getDocumentController()(??)

Can you please throw some pointers for above issue?

Please do the needful..!!

Regards
Kiran
alex_jitianu
Posts: 1007
Joined: Wed Nov 16, 2005 11:11 am

Re: How to display insertattribute value in xml by default

Post by alex_jitianu »

Hi Kiran,

Yes, you need to write the code in the doOperation() method which is called when the user clicks the action. As I understand Oxygen has no knowledge of this "user defined keys map" location so it's up to you to located it and parse it. The API does offer some helpful methods, but you will have to use the SAX API to parse and extrat data from the map. For example:

Code: Select all

  public void doOperation(AuthorAccess authorAccess, ArgumentsMap args)
    throws AuthorOperationException {
    XMLReader reader = authorAccess.getXMLUtilAccess().newNonValidatingXMLReader();
    reader.setContentHandler(new ContentHandlerAdapter() {
      @Override
      public void startElement(String uri, String localName, String name, Attributes atts)
          throws SAXException {
        if ("keydef".equals(localName)) {
          // A key was identified. Store it in a data structure.
        }
      }
    });
    reader.parse("file://path.to.the.user.keys.map");
If you can't detect automatically the "file://path.to.the.user.keys.map" you can present an input dialog to the user and he will paste the URL. In Oxygen, there is Copy Location action in the contextual menu presented on the tab of an editor. They could use this action to get the URL.

Best regards,
Alex
kpuchaka
Posts: 12
Joined: Wed Sep 29, 2021 7:02 pm

Re: How to display insertattribute value in xml by default

Post by kpuchaka »

Hi Alex,

Thank you so much for your prompt reply. I was able to read my "user defined keys map" xml content to my context and below method did that magic:

InputStream stream=authorAccess.getEditorAccess().createContentInputStream();

I just wrote my own logic to read the above stream and did the job.

Now I m facing another issue that my DITA Reusable Component Window is not automatically refresh to pull the latest keys unless author has to clear history and re-open the Map object again. So with this problem, even if we read all the keys from reference map and comparing with "user defined keys" map ,that is not getting accurate because my DITA Reusable Component window is not automatically refresh and pulling the latest updated keys .

Is there any way where we can automatically pull and refresh the DITA Reusable Component window with latest keys when there is any change in my reference map without re-opening the map again ?

I believe this is a bug with my current oxygen version 21.1 and if so, has it addressed in the latest version?

Do you recommend any workaround for this problem for now?
image.png
image.png (205.07 KiB) Viewed 2572 times
Please help me in this regard..

Regards
Kiran
alex_jitianu
Posts: 1007
Joined: Wed Nov 16, 2005 11:11 am

Re: How to display insertattribute value in xml by default

Post by alex_jitianu »

Hello Kiran,

If the files from the root map's hierarchy change within Oxygen, Oxygen will automatically update the view. How is this change triggered. I see an SDL entry in the menu bar, are these root maps from the SDL CMS?
On the right side of the DITA Reusable Components' toolbar there is a settings button, with a cog icon. It presents a drop down menu with a Reindex action that should detect changes.

Best regards,
Alex
kpuchaka
Posts: 12
Joined: Wed Sep 29, 2021 7:02 pm

Re: How to display insertattribute value in xml by default

Post by kpuchaka »

Hi Alex,

Yes, these rootmaps are coming to SDL CMS from other PLM SQL application. There is "oxygen authoring bridge" provided by SDL to communicate b/w oxygen and SDL. The menu item what you are seeing in image is that only. We have dedicated SDL product vendors to support of application issues and we are in regular touch with them about any SDL related issues.

Do you think the sync is not happening due to that "oxygen authoring bridge" problem? Do you think SDL can help in this?

Btw, I have already tried with that re-index option in "settings" button of the DITA Reusable Component window but that is not working.

Do you see any specific triggerpoint?

Regards
Kiran
alex_jitianu
Posts: 1007
Joined: Wed Nov 16, 2005 11:11 am

Re: How to display insertattribute value in xml by default

Post by alex_jitianu »

Hi Kiran,
Now I m facing another issue that my DITA Reusable Component Window is not automatically refresh to pull the latest keys unless author has to clear history and re-open the Map object again.
I just try to understand how these keys change so I can deduce why is DITA Reusable Component not detecting the change. Do you perform an update/checkout and new versions of the map are downloaded from SDL?
If you go to Window->Show View and choose the Open/Find Resource to present the view with the same name. In it there is a Reindex action. Please try it it and let me know if afterwards the DITA Reusable Components view presents the proper keys.

Best regards,
Alex
kpuchaka
Posts: 12
Joined: Wed Sep 29, 2021 7:02 pm

Re: How to display insertattribute value in xml by default

Post by kpuchaka »

Hi Alex,

Thank you for your time. I have tried the below option suggested by you but there is no result and latest keys were not loaded automatically.
We had a discussion with SDL team and we observed that when there is new version of keys map was created, then DITA Reusable Component window is not updating because the new version of the file is not downloading to oxygen local path automatically unless we re-open the rootmap again. This is due to some issue in Authoring bridge and we requested SDL team to look into that base code.

But when there is no new version of keys map(means if we update the keys map on same version which was already downloaded to oxygen local path) then those changes is updating upon author can deselect the rootmap(select the empty value in dropdown) and again re-select the rootmap(select the rootmap GUID) from the Rootmap dropdown available on left side of the oxygen(see attached image) then it is getting refreshed and latest keys are displaying in DITA Reusable Component Window.
de-select the rootmap and keys were disappear from DITA Reusable Component window
image.png
image.png (122.3 KiB) Viewed 2489 times
Re-select the rootmap and appear the keys with updated values(means refreshed the map)
Picture2.jpg
Picture2.jpg (24.87 KiB) Viewed 2489 times
We can think about this as current workaround at least to proceed further.
Now the question is:
Is there any way where we can read and get the control of that rootmap from that drop down and perform deselect and re-select automatically thru program by using any API methods? If so then I m planning to perform this in any of the author action so that author can see the latest keys always.

Please throw some pointers..

Regards
Kiran
alex_jitianu
Posts: 1007
Joined: Wed Nov 16, 2005 11:11 am

Re: How to display insertattribute value in xml by default

Post by alex_jitianu »

Hi Kiran,

From an Oxygen Workspace Access plugin you can use ro.sync.exml.workspace.api.options.GlobalOptionsStorage.setGlobalObjectProperty(String, Object) to set ro.sync.exml.options.APIAccessibleOptionTags.KEYS_CONTEXT_MAP. You could set it to an empty map (null might also work, especially if there is no map opened in the DITA Maps Manager) then back to the proper map.

If you don't already have a Workspace Access plugin, there's a good starting point project available on GitHub.

Best regards,
Alex
kpuchaka
Posts: 12
Joined: Wed Sep 29, 2021 7:02 pm

Re: How to display insertattribute value in xml by default

Post by kpuchaka »

Hi Alex,

Thank you for your email. I have started the development of below approach and pause it suddenly because we observed that the deselect and reselect the rootmap from the dropdown(as I explained previously) is not working always.

Whichmeans,this behaviour is not consistent and oxygen is not pulling the latest revision to local system always when we de-select and re-select the rootmap. We have no clue why it is behaving inconsistently and don't know any configurations needs to be adjusted.

We had a discussion with SDL Tridion Docs vendor and they told us that it is not SDL side and oxygen has to look into this. But as I told you earlier, we are using Oxygen Authoring bridge provided by SDL to communicate b/w oxygen and SDL CMS and when we open the rootmap from SDL Tridion Docs menu then it is always pulling the latest data of the reference keys map and we can see the latest keys in DITA Reusable Component Window.
image.png
image.png (35.8 KiB) Viewed 2363 times
But our users are preferring to de-select and re-select the rootmap from drop down instead of opening the rootmap always from SDL Tridion Docs menu.

Why it is not refreshing the local copy of the file and is there any way you can find to perform this auto refresh?

We are upgrading the oxygen to 23.1 version from 21.1 and will test this auto refresh of DITA Reusable Component Window issue will address or not.

Is it a bug in oxygen? If so, is there any workaround?

Please do the needful.

Regards
Kiran
alex_jitianu
Posts: 1007
Joined: Wed Nov 16, 2005 11:11 am

Re: How to display insertattribute value in xml by default

Post by alex_jitianu »

Hello Kiran,

If the context map set in the DITA Maps Manager is <Current Map>, Oxygen will listen for save, timestamp change events happening to the map and will reload the keys. Whenever an editor is saved, if that editor is the context map, Oxygen will reload the keys. So there are certain events that trigger a reload.
when we open the rootmap from SDL Tridion Docs menu then it is always pulling the latest data of the reference keys map and we can see the latest keys in DITA Reusable Component Window.
This Open... action opens the map in the main editor area or the DITA Maps Manager. So if the map stays open in an Oxygen editor, then the keys are refreshed? It might be related with the listeners I've mentioned above. When an editor gets activated we check its timestamp for example and we could detect a change and reload the keys.
What if you always keep the keys map open in either the main editing area or the DITA Maps Manager? Do the keys reload?
Why it is not refreshing the local copy of the file and is there any way you can find to perform this auto refresh?
The SDL bridge decides when to reload the local version of the keys map so Oxygen has no way of knowing it changed. That's why I suggested to use the Java API and toggle the APIAccessibleOptionTags.KEYS_CONTEXT_MAP option. Of course, you would need to know when to call this API, when the map changes as a result of a SDL action.

Best regards,
Alex
Post Reply