Plugin development - XPath on current document.

Having trouble installing Oxygen? Got a bug to report? Post it all here.
calvados
Posts: 22
Joined: Wed Jul 30, 2008 12:46 am

Plugin development - XPath on current document.

Post by calvados »

Hi there,

I was wondering how it would be possible to programatically perform an XPath query on the currently open document that has not yet been saved.

Thanks,

Cal.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Plugin development - XPath on current document.

Post by sorin_ristache »

Hello,

In the current version (Author version 10.0) running an XPath query in a custom extension is not possible. It would be possible if the nodes of the Author document were exposed in the Author API but that is an enhancement for a future version.


Regards,
Sorin
calvados
Posts: 22
Joined: Wed Jul 30, 2008 12:46 am

Re: Plugin development - XPath on current document.

Post by calvados »

Hi Guys,

As my development of Author Extensions continues, I'm repeatedly being limited in what I can do due to the lack of xPath functionality in the api.

- Do you guys have a planned release version in which I might expect xPath functionality on the current document from my java author extensions?
- Do you have any further suggestions about how I may achieve the same functionality within the current scope of the 10.0 api?

I'm currently using an overly complex system of start and end node offsets and temporary <marker/> tags to navigate around the document.

Any help, or an estimated release version and date would be greatly appreciated.

Thanks for your continuing help and attention with this matter.

Cal.
iulian_velea
Posts: 63
Joined: Fri Dec 12, 2003 6:34 pm
Contact:

Re: Plugin development - XPath on current document.

Post by iulian_velea »

As Sorin noted in his post, currently there is no API available for executing an XPath query from your extension.
You probably are familiar with the current API for navigating in the AuthorDocument and the other functionality we are providing for executing various operations on the document.
The main classes that should be looked at in my opinion are:

Code: Select all

ro.sync.ecss.extensions.api.AuthorAccess
and

Code: Select all

ro.sync.ecss.extensions.api.AuthorDocumentController
It would be helpful if you could describe what you need to do more exactly.

Best wishes,
Iulian
calvados
Posts: 22
Joined: Wed Jul 30, 2008 12:46 am

Re: Plugin development - XPath on current document.

Post by calvados »

Hey Iulian,

What I'm trying to do is grab the children of a node as a "snippet" of XML text. For example, to get the "snippet" children of "clause" given the source:

Code: Select all


<clause>
<num/>
<text id='123'>three <item id='456'>nuts</item></text>
</clause>
I would want a string that reads

Code: Select all

"<num/><text id='123'>three <item id='456'>nuts</item></text>"
I have scoured both the AuthorAccess and AuthorDocumentController API's to no avail. A query like this would be very simple to execute with xPath.

Is this functionality scheduled to be released in an future version of oXygen?...and if so, is there an anticipated release date?

I have many more scenario's in which xPath functionality would be required to perform the tasks I need to complete, and I'm desperate to find a solution to this problem.

Thanks for your help.

Cal.
calvados
Posts: 22
Joined: Wed Jul 30, 2008 12:46 am

Re: Plugin development - XPath on current document.

Post by calvados »

Anybody?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Plugin development - XPath on current document.

Post by sorin_ristache »

Hello,
calvados wrote:Is this functionality scheduled to be released in an future version of oXygen?...and if so, is there an anticipated release date?
This functionality is scheduled for version 10.1 which will be released probably in February 2009.
calvados wrote:I have many more scenario's in which xPath functionality would be required to perform the tasks I need to complete, and I'm desperate to find a solution to this problem.
If you cannot wait until Oxygen version 10.1 you can execute an XPath expression on a DOM tree that you can build by wrapping each node of the Author document in a DOM node. The nodes of the Author document can be obtained with methods of classes ro.sync.ecss.extensions.api.AuthorAccess and ro.sync.ecss.extensions.api.AuthorDocumentController. For example you can find the root of the Author document with the methods AuthorAccess.getDocumentController(), AuthorDocumentController.getNodeAtOffset(), AuthorNode.getParent() (you can call getParent() recursively) and AuthorElement.getContentNodes(). The AuthorNode objects from the Author document that represent XML elements of your document (for example <num/>, <text id='123'>three <item id='456'>nuts</item></text>, etc) are also AuthorElement objects so you can call AuthorElement.getContentNodes() to find the child nodes and wrap them in DOM nodes.


Regards,
Sorin
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Re: Plugin development - XPath on current document.

Post by Dan »

Hello Cal,
We have this functionality under development as we speak. Write to support to obtain the download link to a beta version of oXygen 10.1.

Best regards,
Dan
Post Reply