Get the Content of a ELementNode
Are you missing a feature? Request its implementation here.
-
- Posts: 53
- Joined: Tue Aug 23, 2005 12:00 pm
Get the Content of a ELementNode
I understand from the JavaDoc that Content represent the text nodes of an element represented by AuthorElement. How do you get to this Content i have been searching in the provided source code but con't find anything.
In fact the implementation class ro.sync.ecss.A.B shows no state containing a Content instance. So there must be some other way...?
Tx.,
In fact the implementation class ro.sync.ecss.A.B shows no state containing a Content instance. So there must be some other way...?
Tx.,
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Get the Content of a ELementNode
Post by sorin_ristache »
Hello,
To get the text content of an element you have to use a code fragment like the following:
In a future version we will make the text content available in a simple way.
Regards,
Sorin
To get the text content of an element you have to use a code fragment like the following:
Code: Select all
try {
AuthorDocumentController documentController = authorAccess.getDocumentController();
AuthorDocumentFragment documentFragment = documentController.createDocumentFragment(element, true);
Content content = documentFragment.getContent();
String string = content.getString(0, content.getLength());
string = string.replaceAll("\0", "");
} catch (BadLocationException e) {
// Exception handling here
}
Regards,
Sorin
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Get the Content of a ELementNode
Post by sorin_ristache »
It is a fragment of the tree of the current Author document. You can edit this fragment in your Author extension component but this does not modify the Author document that you see in the Author editor panel. The fragment is only a copy of some nodes from the Author document tree.
Regards,
Sorin
Regards,
Sorin
-
- Posts: 53
- Joined: Tue Aug 23, 2005 12:00 pm
Re: Get the Content of a ELementNode
Sorin,
I am looking for a way of providing dialogs to edit some complex types. How can you in an easy way update the content?
(this is editing an XML element like
I am looking for a way of providing dialogs to edit some complex types. How can you in an easy way update the content?
Code: Select all
AuthorDocumentFragment authorDocumentFragment = authorAccess.getDocumentController().createDocumentFragment(abbrElement, false);
Content content = authorDocumentFragment.getContent();
String abbreviation = content.getString(0, content.getLength());
AttrValue whole = abbrElement.getAttribute("whole");
String wholeValue = whole!=null ? whole.getValue() : null;
AttrValue footnote = abbrElement.getAttribute("whole");
boolean footnoteValue = footnote!=null ? Boolean.valueOf(footnote.getValue()) : true;
AbbreviationDialog dialog = AbbreviationDialog.prompt(abbreviation, wholeValue, footnoteValue);
if (dialog.isOk()){
// update the element
}
Code: Select all
<abbreviation whole="Abcfef" footnote="true">ABC</abbreviation>
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Get the Content of a ELementNode
Post by sorin_ristache »
You update the content of the current document edited in the Author mode with the methods delete, createDocumentFragment and insertFragment of the AuthorDocumentController object that you get with a call authorAccess.getDocumentController() where authorAccess is a parameter received by your Author extension.
Regards,
Sorin
Regards,
Sorin
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ 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