Control available styles based on schema

Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
vitorhugovm
Posts: 34
Joined: Fri Jan 26, 2024 3:31 pm

Control available styles based on schema

Post by vitorhugovm »

Hello!

I'm working with Oxygen XML Web Author version 27. The edited files are XML and the schema is provided inside an attribute of the root element.
I have two main styles for viewing files (available on "Choose style..." dialog from main toolbar).
I want to read the attribute from the root element and hide a style option if the current schema cannot be represented by this style.

I tried to use an extension of AuthorCSSAlternativesCustomizer and added it using PluginWorkspaceProvider.getPluginWorkspace().addAuthorCSSAlternativesCustomizer(AuthorCSSAlternativesCustomizer).
I put some logs to test if the extended functions were being called, but nothing happened.
Is there a specific way to add the customizer or a specific place where it must be initialized? Am I looking at the right class?

I also wanted to always open files with a default style option. Currently, the last selected option persists for the current user.

Thanks!
Vitor
cosminef
Site Admin
Posts: 219
Joined: Wed Aug 30, 2023 2:33 pm

Re: Control available styles based on schema

Post by cosminef »

Hello,

For this use case, it is recommended to create two frameworks, one for each style defined as the main style.
By combining several association rules in the Association Rules tab [1], you can configure Oxygen XML Editor/Web Author to recognize a document's type. The editor determines the document's type when it matches at least one of the association rules. In this tab, you can access the Document Type Rule dialog, where you can create association rules that are triggered by any document meeting all the criteria defined within the dialog.
In Oxygen XML Editor, under the CSS subtab [2], you can refer to the main style ("alternate" must be set to "no") for each framework and you can also set a title for each style.
After you have finished editing the frameworks, you can create an archive of them and upload it to Web Author [3]

[1] https://www.oxygenxml.com/doc/versions/ ... s-tab.html
[2] https://www.oxygenxml.com/doc/versions/ ... b-tab.html
[3] https://www.oxygenxml.com/doc/versions/ ... ework.html

Best,
Cosmin
Cosmin Eftenie
www.oxygenxml.com
vitorhugovm
Posts: 34
Joined: Fri Jan 26, 2024 3:31 pm

Re: Control available styles based on schema

Post by vitorhugovm »

Hello Cosmin!

Thanks for the answer.
I would prefer if I could avoid creating new frameworks for my use case.
Is there another way to do this by code using the Java API?

Thanks!
Vitor
cosminef
Site Admin
Posts: 219
Joined: Wed Aug 30, 2023 2:33 pm

Re: Control available styles based on schema

Post by cosminef »

Hello,
Is there another way to do this by code using the Java API?
There is no Java API for this use case, but our initial proposal might benefit you by developing frameworks using the Framework Extension Script File (EXF) [1] [2].
Do you think this approach would be advantageous for you?

Best,
Cosmin

[1] https://www.oxygenxml.com/doc/versions/ ... ratch.html
[2] https://www.oxygenxml.com/doc/versions/ ... cases.html
Cosmin Eftenie
www.oxygenxml.com
vitorhugovm
Posts: 34
Joined: Fri Jan 26, 2024 3:31 pm

Re: Control available styles based on schema

Post by vitorhugovm »

Hi Cosmin!

I tried to use the extension script and it worked pretty well.
I actually really liked the solution, as I don't need another entire framework file as it just extends the existent one and adds or removes some features based on context.

Thanks for the attention!
Vitor
Post Reply