Page 1 of 1

Framework Customization: Hide Elements (Tags) in AuthorView using Stylesfilter.

Posted: Mon Sep 19, 2022 5:18 pm
by Stevee
Hi,
i want to hide several XML-Tags ( and their children) , from the AuthorView.

I used the following approach:
In a Stylesfilter, i check for the AuthorNode which i want to hide. I then use the according Styles object which i receive in the filter Method and do

Code: Select all

styles.setProperty(Styles.KEY_DISPLAY, "none");
I aussme this sets the CSS-Property display to value none, which i would expect that this hides the Element.
But it seems that setting this property has no effect at all.

If i use

Code: Select all

styles.setProperty(Styles.KEY_VISIBILITY, "hidden");
the Tags get invisibile, but of course the Element still takes its space in the Layout.

Does someone know how i can hide Elements completly from AuthorView, including that they dont need any space in the Layout?

Greetings
Stevee

Re: Framework Customization: Hide Elements (Tags) in AuthorView using Stylesfilter.

Posted: Mon Sep 19, 2022 5:51 pm
by Stevee
Sorry, i forgot to add some additional Information about my used Oxygen Version:
I am using:
<oXyygen/> XML Author 23.1 , build: 2021030206
Eclipse Plugin.

Re: Framework Customization: Hide Elements (Tags) in AuthorView using Stylesfilter.

Posted: Tue Sep 20, 2022 8:36 am
by Radu
Hi Steeve,

I tried this on my side:

1) An XML document looking like this:

Code: Select all

<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="topic_vfq_mbq_x5b">
    <title>T</title>
    <prolog>
        <author>hidden</author>
        <resourceid/>
    </prolog>
    <body>
        <p>para</p>
    </body>
</topic>
2) With the StylesFilter implementation I attempt to hide its entire "prolog":

Code: Select all

new StylesFilter() {
      
      @Override
      public String getDescription() {
        return "abc";
      }
      
      @Override
      public Styles filter(Styles styles, AuthorNode authorNode) {
        if("prolog".equals(authorNode.getName())) {
          styles.setProperty(Styles.KEY_DISPLAY, ro.sync.ecss.css.CSS.NONE);
        }
        return styles;
      }
    }
and this seems to work for me. That "ro.sync.ecss.css.CSS.NONE" is equivalent to the literal "none" that you are using.
Can you try something similar on your side? Does your StylesFilter's "filter" method actually get called?
How did you set up the StylesFilter on your side?

Regards,
Radu

Re: Framework Customization: Hide Elements (Tags) in AuthorView using Stylesfilter.

Posted: Fri Sep 23, 2022 11:20 am
by Stevee
Hi Radu,

thanks for your reply.

My code gets called. If i set another CSS-Property like the visibility - hidden, that works, and the style is applied to the authorNode that i expect that it has to.

My Stylesfilter Method looks like this:

Code: Select all

    @Override
    public Styles filter(Styles styles, AuthorNode authorNode) {

        if (authorNode.getType() == AuthorNode.NODE_TYPE_ELEMENT) {
            if (shouldHideElement(authorNode)) {   //Determines if a element should be visibile 

                styles.setProperty(Styles.KEY_DISPLAY, "none");
                // styles.setProperty(Styles.KEY_VISIBILITY, "hidden");  //This would take effect if it is not a comment. 
            }

        }
        return styles;
    }
I also checked for other Styling Information. There is a CSS-Associated with the Document that is currently in editing (and for which the Stylesfilter is applyed for), but even if i remove the CSS-Files from the Document that does not work.

If i use the CSS-Property (display:none) directly in an associated CSS-File, it works.

Re: Framework Customization: Hide Elements (Tags) in AuthorView using Stylesfilter.

Posted: Fri Sep 23, 2022 1:47 pm
by Radu
Hi,

Can you also answer the questions I asked in my previous post:

Does your StylesFilter's "filter" method actually get called?
- Maybe here you can add some logging in the "if" clause like "System.err.println(authorNode);" to see if the node is actually matched by your "shouldHideElement" method.

How did you set up the StylesFilter on your side?

Regards,
Radu