Accessing document content
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 7
- Joined: Thu Nov 27, 2014 8:17 am
Accessing document content
First I want to say, I know you have examples for this sort of thing. However, I can not find them. I basically downloaded all the jar files for creating the plugin and copied some code I found on the web as well as a plugin that was already installed with my version of oXygen Author (15.2).
What I am trying to figure out is how to access the xml content. Here is snippet of code that I am trying, but it's failing with incompatible types. The variable, editors, is a hashtable that I save off the editors for whatever editors are currently open in the application.
I have a DITA file open in the editor. If you have a location I can go to, to find more examples... I'd be happy to go check it out. I don't think I am able to set up Maven on my current configuration of Eclipse.
What I am trying to figure out is how to access the xml content. Here is snippet of code that I am trying, but it's failing with incompatible types. The variable, editors, is a hashtable that I save off the editors for whatever editors are currently open in the application.
Code: Select all
// Extract the xml page editor
WSXMLTextEditorPage xmlPage = (WSXMLTextEditorPage) editors.get(currentEdit).getCurrentPage();
Object[] values = xmlPage.evaluateXPath("/topic/prolog//othermeta[@name = 'Category Codes']/@content");
I have a DITA file open in the editor. If you have a location I can go to, to find more examples... I'd be happy to go check it out. I don't think I am able to set up Maven on my current configuration of Eclipse.
-
- Posts: 1016
- Joined: Wed Nov 16, 2005 11:11 am
Re: Accessing document content
Post by alex_jitianu »
Hello,
The API you are using (WSXMLTextEditorPage) is intended for when the text page is the active page. I suspect that in your situation the author page is active. You can handle both cases like this:
If needed you can programmatically switch pages but I'm not sure if that is what you want or what you need:
If would be good if you could create the Maven based sample SDK project because it has a lot of sample code.
Best regards,
Alex
The API you are using (WSXMLTextEditorPage) is intended for when the text page is the active page. I suspect that in your situation the author page is active. You can handle both cases like this:
Code: Select all
String currentPageID = editorAccess.getCurrentPageID();
Object[] values = null;
if (EditorPageConstants.PAGE_TEXT.equals(currentPageID) && editorAccess.getCurrentPage() instanceof WSXMLTextEditorPage) {
WSXMLTextEditorPage textPage = (WSXMLTextEditorPage) editorAccess.getCurrentPage();
values = textPage.evaluateXPath("/topic/prolog//othermeta[@name = 'Category Codes']/@content");
} else if (EditorPageConstants.PAGE_AUTHOR.equals(currentPageID)) {
WSAuthorEditorPage authorPage = (WSAuthorEditorPage) editorAccess.getCurrentPage();
values = authorPage.getDocumentController().evaluateXPath("/topic/prolog//othermeta[@name = 'Category Codes']/@content", true, true, true);
}
Code: Select all
editorAccess.changePage(EditorPageConstants.PAGE_TEXT);
Best regards,
Alex
-
- Posts: 7
- Joined: Thu Nov 27, 2014 8:17 am
Re: Accessing document content
Alex,alex_jitianu wrote:Hello,
The API you are using (WSXMLTextEditorPage) is intended for when the text page is the active page. I suspect that in your situation the author page is active. You can handle both cases like this:
If needed you can programmatically switch pages but I'm not sure if that is what you want or what you need:Code: Select all
String currentPageID = editorAccess.getCurrentPageID();
Object[] values = null;
if (EditorPageConstants.PAGE_TEXT.equals(currentPageID) && editorAccess.getCurrentPage() instanceof WSXMLTextEditorPage) {
WSXMLTextEditorPage textPage = (WSXMLTextEditorPage) editorAccess.getCurrentPage();
values = textPage.evaluateXPath("/topic/prolog//othermeta[@name = 'Category Codes']/@content");
} else if (EditorPageConstants.PAGE_AUTHOR.equals(currentPageID)) {
WSAuthorEditorPage authorPage = (WSAuthorEditorPage) editorAccess.getCurrentPage();
values = authorPage.getDocumentController().evaluateXPath("/topic/prolog//othermeta[@name = 'Category Codes']/@content", true, true, true);
}If would be good if you could create the Maven based sample SDK project because it has a lot of sample code.Code: Select all
editorAccess.changePage(EditorPageConstants.PAGE_TEXT);
Best regards,
Alex
Thanks a ton... that seemed to do that trick. I appreciate the help. I will see if I can create a Maven based sample sdk project somewhere. So I can check other examples. Again, thank you!
--
Richard
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)
- ↳ 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