Change behavior of "DITA/ReuseKeys" action

Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
ArthurP
Posts: 25
Joined: Mon Dec 11, 2023 3:10 pm

Change behavior of "DITA/ReuseKeys" action

Post by ArthurP »

Hi,

I'm trying to add an index-see-also element with a keyref attribute in a glossentry topic using the "DITA/ReuseKeys" action.
The keyref attribute is correctly inserted but, it's inserted as an inline bold element with a xref child.
Example from your "try it" Webauthor version https://www.oxygenxml.com/oxygen-xml-we ... n%22%7D%5D

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE glossentry PUBLIC "-//OASIS//DTD DITA Glossary//EN" "glossary.dtd">
<glossentry id="flowers.genus">
    <glossterm>Genus</glossterm>
    <glossdef>A low-level taxonomic rank used in the classification of living and fossil organisms.
        Other well-known taxonomic ranks are domain, kingdom, phylum, class, order, family, and
        species, with <term>genus</term> fitting between family and species. The scientific name of
        a genus may be called the generic name: it is always capitalized.</glossdef>
    <prolog>
        <metadata>
            <keywords>
                <indexterm>test <b><xref keyref="perennial"/></b></indexterm>
            </keywords>
        </metadata>
    </prolog>
</glossentry>
I would like to change the inserted element as "index-see" or "index-see-also". Is there a way to customize the default behavior/action ?

Code: Select all

<keywords>
    <indexterm>test <index-see-also keyref="perennial"/></indexterm>
</keywords>
Thanks
mihaela
Posts: 519
Joined: Wed May 20, 2009 2:40 pm

Re: Change behavior of "DITA/ReuseKeys" action

Post by mihaela »

Hello,

The only way to change the element that is inserted when a DITA key is selected is by creating a plugin that uses an AuthorDocumentFilter[1] to update the fragment before it is inserted in the document.
See the javadoc of the filter class about implementation details and also check the AuthorDocumentController [2] API class if you need methods to create or serialize an AuthorDocumentFragment [3].

We have a sample plugin that uses an AuthorDocumentFilter, maybe you can use it as a starting point:
https://github.com/oxygenxml/web-author ... g-comments

Please let us know if you need further assistance.

[1] https://www.oxygenxml.com/InstData/Edit ... ilter.html
[2] https://www.oxygenxml.com/InstData/Edit ... tFragment)
[3] https://www.oxygenxml.com/InstData/Edit ... gment.html

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
ArthurP
Posts: 25
Joined: Mon Dec 11, 2023 3:10 pm

Re: Change behavior of "DITA/ReuseKeys" action

Post by ArthurP »

Hi Mihaela,

Sorry for the delayed response.
I don't do Java so it might be hard to try your solution. Is there any Javascript possibility ?

Regards,
arthur
mihaela
Posts: 519
Joined: Wed May 20, 2009 2:40 pm

Re: Change behavior of "DITA/ReuseKeys" action

Post by mihaela »

Hello,

A possibility, if you use a custom framework that extends DITA, is to create [1] and register [2] another action with the same id ("DITA/ReuseKeys").
Your custom action should delegate to the original on all the existing methods [3].
On actionPerformed, after delegating to original action you could invoke an operation [5] [6] that renames the inserted element from xref to your element in the callback method (make sure that you cal the callback received as parameter when the rename operation ends).
Please let us know if you need more details about this approach.

[1] https://www.oxygenxml.com/maven/com/oxy ... ction.html
[2] https://www.oxygenxml.com/maven/com/oxy ... on__anchor
[3] https://www.oxygenxml.com/maven/com/oxy ... ction.html
[4] https://www.oxygenxml.com/maven/com/oxy ... ed__anchor
[5] https://www.oxygenxml.com/maven/com/oxy ... on__anchor
[6] https://www.oxygenxml.com/InstData/Edit ... mmary.html

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
ArthurP
Posts: 25
Joined: Mon Dec 11, 2023 3:10 pm

Re: Change behavior of "DITA/ReuseKeys" action

Post by ArthurP »

Hello Mihaela,

We are using a custom framework so we will try your suggestion, thanks!
I will let you know if I need some help or precision to implement this.

Regards,
arthur
Post Reply