How to get list of attributes which can be added to selected tag

Having trouble installing Oxygen? Got a bug to report? Post it all here.
SmitaPatil
Posts: 93
Joined: Mon Aug 08, 2022 2:32 pm

How to get list of attributes which can be added to selected tag

Post by SmitaPatil »

Hi Team,
Is there any method using which I can check what are all attribute I can add for selected element and what attributes are required for given element.
Please let me know if there any methods to get it.

Thanks,
Smita
mihaela
Posts: 515
Joined: Wed May 20, 2009 2:40 pm

Re: How to get list of attributes which can be added to selected tag

Post by mihaela »

Hello,

To get the list of available attributes for a specific node you can use the following API: ro.sync.ecss.extensions.api.AuthorSchemaManager.whatAttributesCanGoHere(WhatAttributesCanGoHereContext).
To create the context to be passed to the previous method, use the ro.sync.ecss.extensions.api.AuthorSchemaManager.createWhatAttributesCanGoHereContext(AuthorElement) API.

The whatAttributesCanGoHere method returns a list of ro.sync.contentcompletion.xml.CIAttribute.
You can find if one attribute is required by using the ro.sync.contentcompletion.xml.CIAttribute.isRequired() method.

Please let us know if you need more information.

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
SmitaPatil
Posts: 93
Joined: Mon Aug 08, 2022 2:32 pm

Re: How to get list of attributes which can be added to selected tag

Post by SmitaPatil »

Hi,
Thank you so much.


Thanks,
Smita
Last edited by SmitaPatil on Fri Sep 02, 2022 8:45 am, edited 1 time in total.
SmitaPatil
Posts: 93
Joined: Mon Aug 08, 2022 2:32 pm

Re: How to get list of attributes which can be added to selected tag

Post by SmitaPatil »

Hi Team,
can you please tell is there any method to remove attribute of selected element and also modify it.

Thanks,
Smita
mihaela
Posts: 515
Joined: Wed May 20, 2009 2:40 pm

Re: How to get list of attributes which can be added to selected tag

Post by mihaela »

Hello,

The ro.sync.ecss.extensions.api.AuthorDocumentController API class contains methods for modifying the Author document, so here is the place were you can first search when you need a method to modify or remove an element or an attribute.

These are the methods that you need now: ro.sync.ecss.extensions.api.AuthorDocumentController.setAttribute(String, AttrValue, AuthorElement) and ro.sync.ecss.extensions.api.AuthorDocumentController.removeAttribute(String, AuthorElement)

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
SmitaPatil
Posts: 93
Joined: Mon Aug 08, 2022 2:32 pm

Re: How to get list of attributes which can be added to selected tag

Post by SmitaPatil »

Hi Team,

Thank you.
the method which you have suggested required attribute name.
Actually I wanted to remove all attributes of the element where cursor is present.
Please let me know if something is present to achieve this with caretoffset and element name.

Thanks,
Smita
mihaela
Posts: 515
Joined: Wed May 20, 2009 2:40 pm

Re: How to get list of attributes which can be added to selected tag

Post by mihaela »

Hello,

From ro.sync.ecss.extensions.api.node.AuthorElement you can get all the attributes and then use the ro.sync.ecss.extensions.api.AuthorDocumentController.removeAttribute(String, AuthorElement) API that I mentioned earlier, for each attribute, to remove it.

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
Post Reply