How to disable reference resolver

Having trouble installing Oxygen? Got a bug to report? Post it all here.
manojdcoder
Posts: 67
Joined: Thu Oct 29, 2020 12:01 am

How to disable reference resolver

Post by manojdcoder »

There are times a user may want to open a document (topic, concept, or map etc.,) in editor without resolving any references (xrefs, conrefs, mapref etc.,) The document could have 100s or references and it could take forever to resolve all the references, by disabling reference resolvers user can load the document almost instantly.

I added a pseudo class to the root element from WebappEditingSessionLifecycleListener.editingSessionStarted(String sessionId, AuthorDocumentModel documentModel), which will help in identifying that the document would not have to resolve any references.

Xrefs are resolved from Author CSS using oxy_getSomeText (frameworks\dita\css\core\-topic-related-links-xref.css). It was easy override this behavior using the pseudo class.

But maprefs / conrefs seem to be resolved by DITAMapRefResolver/ DITAConRefResolver.
I tried to override DITAMapRefResolver.hasReferences(AuthorNode node), return false if the pseudo class is present in root element.
But it appears this method is called upon initial load even before WebappEditingSessionLifecycleListener.editingSessionStarted(String sessionId, AuthorDocumentModel documentModel) where the pseudo class is added. Also do not seem to have access to URL Query Parameters from this method.

Any suggestions?

Sample map

Code: Select all

<map>
	<mapref href="one.ditamap"/>
	......
	<mapref href="key.ditamap"/>
</map>
manojdcoder
Posts: 67
Joined: Thu Oct 29, 2020 12:01 am

Re: How to disable reference resolver

Post by manojdcoder »

I see there is expand.map.refs.in.author.page option but don't see a way to enforce it only for a particular editor session rather than globally for all users / editor sessions.

And even when expand.map.refs.in.author.page is set to false in options.xml, I see multiple hits on URL handle, one for each mapref in the sample. Apparently the option is enforced only while rendering not when loading/parsing the map.
Last edited by manojdcoder on Tue Feb 13, 2024 4:12 pm, edited 1 time in total.
Bogdan Dumitru
Site Admin
Posts: 142
Joined: Tue Mar 20, 2018 5:28 pm

Re: How to disable reference resolver

Post by Bogdan Dumitru »

Hello,

Yes, the listeners WebappEditingSessionLifecycleListener and AuthorPreloadProcessor are invoked after resolving references (after DITAMapRefResolver.hasReferences(AuthorNode node) is invoked).

To add a listener that's invoked before DITAMapRefResolver.hasReferences you can use ro.sync.ecss.extensions.api.AuthorExtensionStateListener that's created by ExtensionsBundle.createAuthorExtensionStateListener().
If you extend DITAExtensionsBundle, wrap the original AuthorExtensionStateListener somewhat like this:

Code: Select all

  @Override
  public AuthorExtensionStateListener createAuthorExtensionStateListener() {
    AuthorExtensionStateListener wrappedObject = super.createAuthorExtensionStateListener();
    return new AuthorExtensionStateListener() {

      @Override
      public String getDescription() {
        return wrappedObject.getDescription();
      }

      @Override
      public void activated(AuthorAccess authorAccess) {
        wrappedObject.activated(authorAccess);
        // TODO: Your code HERE.
      }

      @Override
      public void deactivated(AuthorAccess authorAccess) {
        wrappedObject.deactivated(authorAccess);
      }
    };
  }
  
Regarding "expand.map.refs.in.author.page" notice that this is an Author Mode Option (options.xml), not a Loading Option that can be specified as a URL parameter.
Bogdan Dumitru
http://www.oxygenxml.com
Post Reply