List of attributes for a node
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 35
- Joined: Fri Nov 11, 2011 10:34 am
List of attributes for a node
Post by maxim.kovalev »
How can I get a list of attributes for a node?
I found this way. Get a node on the spot where the cursor is positioned. The following is a AuthorNode AuthorElement. And call the AuthorElement.getAttributeAtIndex(i);
However, this method returns only attributes that are installed. And how can you get a complete list of attributes that are possible for this node (as in panel attributes).
I found this way. Get a node on the spot where the cursor is positioned. The following is a AuthorNode AuthorElement. And call the AuthorElement.getAttributeAtIndex(i);
However, this method returns only attributes that are installed. And how can you get a complete list of attributes that are possible for this node (as in panel attributes).
-
- Posts: 515
- Joined: Wed May 20, 2009 2:40 pm
Re: List of attributes for a node
Hi Maxim,
To find all the possible attributes for a node you have to get the WhatAttributesCanGoHereContext from the document schema manager and then ask the schema manager what attributes are available in this context.
The following code sample list the names of all attributes available for the element at caret position:
Regards,
Mihaela
To find all the possible attributes for a node you have to get the WhatAttributesCanGoHereContext from the document schema manager and then ask the schema manager what attributes are available in this context.
The following code sample list the names of all attributes available for the element at caret position:
Code: Select all
int caretOffset = authorAcess.getEditorAccess().getCaretOffset();
AuthorDocumentController controller = authorAcess.getDocumentController();
// Get the node at caret position
AuthorNode node = controller.getNodeAtOffset(caretOffset);
if (node instanceof AuthorElement) {
AuthorSchemaManager authorSchemaManager = controller.getAuthorSchemaManager();
// From schema manager get the current context
WhatAttributesCanGoHereContext context = authorSchemaManager.createWhatAttributesCanGoHereContext((AuthorElement) node);
// Find the list of all possible attributes for the current context
List<CIAttribute> possibleAttrs = authorSchemaManager.whatAttributesCanGoHere(context);
if (possibleAttrs != null) {
for (CIAttribute ciAttribute : possibleAttrs) {
System.out.println("Attr: " + ciAttribute.getName());
}
}
}
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
http://www.oxygenxml.com
-
- Posts: 35
- Joined: Fri Nov 11, 2011 10:34 am
Re: List of attributes for a node
Post by maxim.kovalev »
Cool, thanksmihaela wrote:Hi Maxim,
To find all the possible attributes for a node you have to get the WhatAttributesCanGoHereContext from the document schema manager and then ask the schema manager what attributes are available in this context.
The following code sample list the names of all attributes available for the element at caret position:
Regards,Code: Select all
int caretOffset = authorAcess.getEditorAccess().getCaretOffset();
AuthorDocumentController controller = authorAcess.getDocumentController();
// Get the node at caret position
AuthorNode node = controller.getNodeAtOffset(caretOffset);
if (node instanceof AuthorElement) {
AuthorSchemaManager authorSchemaManager = controller.getAuthorSchemaManager();
// From schema manager get the current context
WhatAttributesCanGoHereContext context = authorSchemaManager.createWhatAttributesCanGoHereContext((AuthorElement) node);
// Find the list of all possible attributes for the current context
List<CIAttribute> possibleAttrs = authorSchemaManager.whatAttributesCanGoHere(context);
if (possibleAttrs != null) {
for (CIAttribute ciAttribute : possibleAttrs) {
System.out.println("Attr: " + ciAttribute.getName());
}
}
}
Mihaela
Return to “DITA (Editing and Publishing DITA Content)”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service