Retrieve AuthorAccess in StylesFilter

Post here questions and problems related to oXygen frameworks/document types.
Isabelle
Posts: 174
Joined: Fri Jan 20, 2017 1:11 pm

Retrieve AuthorAccess in StylesFilter

Post by Isabelle »

Hello,

We use oxygen sdk 27.1.0.1.

We have implemented our own StylesFilter and in the override method
public Styles filter(Styles styles, AuthorNode authorNode)
we need AuthorAccess.
For this, we have coded this :

Code: Select all

URL currentUrl = authorNode.getXMLBaseURL();
WSEditor currentPluginEditorAccess = PluginWorkspaceProvider.getPluginWorkspace().getEditorAccess(currentUrl, PluginWorkspace.MAIN_EDITING_AREA);
WSEditorPage  currentPage = currentPluginEditorAccess.getCurrentPage();

if(currentPage instanceof WSAuthorEditorPage) {
            WSAuthorEditorPage  wsAuthorEditorPage = (WSAuthorEditorPage) currentPage;
            return wsAuthorEditorPage.getAuthorAccess();
} else {
            return null;
}
But when we open a large document, we face a StackOverflowError error :
java.lang.StackOverflowError: null
at java.base/java.net.URLStreamHandler.parseURL(URLStreamHandler.java:326)
at java.base/sun.net.www.protocol.file.Handler.parseURL(Handler.java:67)
at java.base/java.net.URL.<init>(URL.java:703)
at java.base/java.net.URL.<init>(URL.java:569)
at java.base/java.net.URL.<init>(URL.java:516)
at ro.sync.ecss.dom.ib.getXMLBaseURL(Unknown Source)
at ro.sync.ecss.dom.ib.getXMLBaseURL(Unknown Source)
at ro.sync.ecss.dom.ib.getXMLBaseURL(Unknown Source)
at ro.sync.ecss.dom.ib.getXMLBaseURL(Unknown Source)
at ro.sync.ecss.dom.ib.getXMLBaseURL(Unknown Source)
at ro.sync.ecss.dom.ib.getXMLBaseURL(Unknown Source)
at ro.sync.ecss.dom.ib.getXMLBaseURL(Unknown Source)
at com._4dconcept.adam.author.framework.S1000D.style.ADAMStylesFilter.getAuthorAccess(ADAMStylesFilter.java:254)
at com._4dconcept.adam.author.framework.S1000D.style.ADAMStylesFilter.filter(ADAMStylesFilter.java:54)
at ro.sync.ecss.css.db.pe(Unknown Source)
at ro.sync.ecss.css.db.xg(Unknown Source)
at ro.sync.ecss.css.db.q(Unknown Source)
...
For information : ADAMStylesFilter.java:254 refers to URL currentUrl = authorNode.getXMLBaseURL();

Can you explain to me how to retrieve AuthorAccess properly ?

Thanks,
Regards,
Isabelle
Radu
Posts: 9491
Joined: Fri Jul 09, 2004 5:18 pm

Re: Retrieve AuthorAccess in StylesFilter

Post by Radu »

Hi Isabelle,
The StylesFilter does not have access to the current editor for a reason. It may start getting called very early, before the current editor is opened.

In the Javadoc for the StylesFilter class it says:

Code: Select all

 * <p>If your StylesFilter implementation also implements the {@link AuthorExtensionStateListener} API, its "activated" callback will be automatically 
 * called with the corresponding {@link AuthorAccess}.</p>
so this is the proper way to gain access to the AuthorAccess corresponding to it.

But even with using the proper way of retrieving the AuthorAccess, if inside the styles filter you use the authoraccess to try and retrieve the styles for another node, then the same styles filter gets called to compute styles also for that node so you might again end up with a stack overflow.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Isabelle
Posts: 174
Joined: Fri Jan 20, 2017 1:11 pm

Re: Retrieve AuthorAccess in StylesFilter

Post by Isabelle »

Thank you Radu for your quick feedback.

I made an other test.
I have this custom StylesFilter :

Code: Select all

public abstract class CustomStylesFilter implements StylesFilter {

  public CustomStylesFilter () {
  }

  @Override
  public Styles filter(Styles styles, AuthorNode authorNode) {
    if (AuthorNode.NODE_TYPE_ELEMENT == authorNode.getType() && ("nodeName".equals(authorNode.getName()))) {
      AuthorElement[] code = ((AuthorElement) authorNode).getElementsByLocalName("code");
      if (code != null && code.length > 0) {
        String infoCode = code[0].getAttribute("infoCode").getValue();
      }
    }

    return styles;
  }

  @Override
  public String getDescription() {
    return null;
  }
}
And I style have a StackOverflowError :
java.lang.StackOverflowError: null
at java.base/java.util.WeakHashMap.hash(WeakHashMap.java:303)
at java.base/java.util.WeakHashMap.get(WeakHashMap.java:402)
at ro.sync.ecss.css.db.qc(Unknown Source)
at ro.sync.ecss.css.db.q(Unknown Source)
at ro.sync.ecss.component.f.g.m(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
I delete all references to AuthorAcces and I still have this issue.
Do you have any idea ?

Thanks,
Regards,
Isabelle
Last edited by Isabelle on Tue Jul 01, 2025 3:56 pm, edited 1 time in total.
Radu
Posts: 9491
Joined: Fri Jul 09, 2004 5:18 pm

Re: Retrieve AuthorAccess in StylesFilter

Post by Radu »

Hi Isabelle,
That looks like a different stack overflow, could you most more content from the stack trace exception? More lines?
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Isabelle
Posts: 174
Joined: Fri Jan 20, 2017 1:11 pm

Re: Retrieve AuthorAccess in StylesFilter

Post by Isabelle »

Here is the full stack trace :
java.lang.StackOverflowError: null
at java.base/java.util.WeakHashMap.hash(WeakHashMap.java:303)
at java.base/java.util.WeakHashMap.get(WeakHashMap.java:402)
at ro.sync.ecss.css.db.qc(Unknown Source)
at ro.sync.ecss.css.db.q(Unknown Source)
at ro.sync.ecss.component.f.g.m(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
...........
But sometimes I have other errors :
java.lang.StackOverflowError: null
at ro.sync.exml.options.Options.nb(Unknown Source)
at ro.sync.exml.options.Options.ob(Unknown Source)
at ro.sync.exml.options.Options.wb(Unknown Source)
at ro.sync.exml.options.Options.getObject(Unknown Source)
at ro.sync.options.k.getBooleanProperty(Unknown Source)
at ro.sync.ecss.conditions.c.c.k(Unknown Source)
at ro.sync.ecss.conditions.y.ead(Unknown Source)
at ro.sync.ecss.conditions.y.rzc(Unknown Source)
at ro.sync.ecss.css.db.qb(Unknown Source)
at ro.sync.ecss.css.db.xg(Unknown Source)
at ro.sync.ecss.css.db.q(Unknown Source)
at ro.sync.ecss.component.f.g.m(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
...........
Radu
Posts: 9491
Joined: Fri Jul 09, 2004 5:18 pm

Re: Retrieve AuthorAccess in StylesFilter

Post by Radu »

Hi Isabella,

Strange, both these stack overflow stack traces seem to stem from the automatic spell checker, it gets in some kind of a loop, I need to think more about this.
But if you uncomment your styles filter API implementation the problem cannot be reproduced correct? Can you come up with the most basic styles filter implementation that I could use on my side to reproduce the problem?

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Isabelle
Posts: 174
Joined: Fri Jan 20, 2017 1:11 pm

Re: Retrieve AuthorAccess in StylesFilter

Post by Isabelle »

Hi Radu,

When I comment the method createAuthorStylesFilter in our CustomExtensionsBundle I still have the issue
java.lang.StackOverflowError: null
at java.base/java.util.WeakHashMap.hash(WeakHashMap.java:303)
at java.base/java.util.WeakHashMap.get(WeakHashMap.java:402)
at ro.sync.ecss.css.db.qc(Unknown Source)
at ro.sync.ecss.css.db.q(Unknown Source)
at ro.sync.ecss.component.f.g.m(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
at ro.sync.ecss.component.f.g.h(Unknown Source)
I can send you the XML file for your test if needed.

Regards,
Isabelle
Post Reply