createXQueryUpdateTransformer API

Post here questions and problems related to oXygen frameworks/document types.
NicoAMP
Posts: 97
Joined: Tue Mar 06, 2018 2:07 pm
Contact:

createXQueryUpdateTransformer API

Post by NicoAMP »

Hello,

As I can read in release note for v23 (https://www.oxygenxml.com/xml_editor/whatisnew23.0.html) the API for creating XSLT and XQuery transformers (using the XMLUtilAccess interface) can no longer be used to create processors for Saxon Professional Edition (PE) or Saxon Enterprise Edition (EE).

So I have a problem, because I have an action in my framework using ro.sync.ecss.extensions.commons.operations.JSOperation operation with the following script to chain XQueryUpdate scripts. It doesn't work anymore because I use createXQueryUpdateTransformer.

Code: Select all

function doOperation(){
  //get current framework path
  frameworkDir = authorAccess.getUtilAccess().expandEditorVariables("${frameworkDir}", null);
  
  //desactivate tracking change if necessary
  myReviewController = authorAccess.getReviewController();
  trackingChangesState = myReviewController.isTrackingChanges();
  if(trackingChangesState){
    myReviewController.toggleTrackChanges();
  }

  //step 1
  performXQueryUpdate(frameworkDir + "/actions/step1.xq");
  
  //step 2
  performXQueryUpdate(frameworkDir + "/actions/step2.xq");
  
  //step 3
  performXQueryUpdate(frameworkDir + "/actions/step3.xq");
  
  
  //activate tracking change if necessary  
  if(trackingChangesState){
    myReviewController.toggleTrackChanges();
  }

 }
 
 function performXQueryUpdate(xqueryPath){
          // Create an XQuery update enable processor.
         queryTransformer  = authorAccess.getXMLUtilAccess().createXQueryUpdateTransformer(
             new Packages.javax.xml.transform.stream.StreamSource(new Packages.java.io.FileInputStream(xqueryPath)), 
             null);        
         // Create a special author model source.
         s = new Packages.ro.sync.ecss.dom.wrappers.mutable.AuthorSource(authorAccess);
         writer = new Packages.java.io.StringWriter();
         result = new Packages.javax.xml.transform.stream.StreamResult(writer);        
         queryTransformer.transform(s, result);
 }
I think that a workaround can be :
- create a ro.sync.ecss.extensions.commons.operations.XQueryUpdateOperation operation for each steps
- create a ro.sync.ecss.extensions.commons.operations.ExecuteMultipleActionsOperation operation to chain them

What do you think about this workaround?

Thanks
Nicolas Delobel
AmeXio
nicolas.delobel at group.amexio.net
Radu
Posts: 8991
Joined: Fri Jul 09, 2004 5:18 pm

Re: createXQueryUpdateTransformer API

Post by Radu »

Hi Nicolas,

You can probably try to build those "XQueryUpdateOperation" in the Javascript and see how that goes.
Or switch to using XSLT to process the content.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
NicoAMP
Posts: 97
Joined: Tue Mar 06, 2018 2:07 pm
Contact:

Re: createXQueryUpdateTransformer API

Post by NicoAMP »

Hi Radu,

Thanks for these informations.

Could you say me if it's possible, in javascript, to call/execute a specific custom action using his ID?
If yes, could you provide me a sample?

Thanks.
Nicolas Delobel
AmeXio
nicolas.delobel at group.amexio.net
Radu
Posts: 8991
Joined: Fri Jul 09, 2004 5:18 pm

Re: createXQueryUpdateTransformer API

Post by Radu »

Hi Nicolas,

You can do that using our APIs:

Code: Select all

	  Object action = authorAccess.getEditorAccess().getActionsProvider().getAuthorExtensionActions().get("action.id.defined.in.framework");
	  authorAccess.getEditorAccess().getActionsProvider().invokeAction(action);
but there is a problem, an action does not take parameters, an action already knows what do do depending on the caret position and on the parameters which have already been configured in its Author operations.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
NicoAMP
Posts: 97
Joined: Tue Mar 06, 2018 2:07 pm
Contact:

Re: createXQueryUpdateTransformer API

Post by NicoAMP »

Hi Radu,

Thanks a lot for your help.

I created 3 author actions corresponding to my 3 XQuery Update steps and I call them in javascript with their ID:

Code: Select all

function doOperation(){
    
  //desactivate tracking change if necessary
  myReviewController = authorAccess.getReviewController();
  trackingChangesState = myReviewController.isTrackingChanges();
  if(trackingChangesState){
    myReviewController.toggleTrackChanges();
  }
  
  //step 1
  performAction("xquery-update-step1");
  
  //step 2
  performAction("xquery-update-step2");
  
  //step 3
  performAction("xquery-update-step3");
  
  
  //activate tracking change if necessary  
  if(trackingChangesState){
    myReviewController.toggleTrackChanges();
  }

 }
 
 function performAction(actionID){
        // Create an action
        myAction = authorAccess.getEditorAccess().getActionsProvider().getAuthorExtensionActions().get(actionID);
	authorAccess.getEditorAccess().getActionsProvider().invokeAction(myAction);
 }
Nicolas Delobel
AmeXio
nicolas.delobel at group.amexio.net
Radu
Posts: 8991
Joined: Fri Jul 09, 2004 5:18 pm

Re: createXQueryUpdateTransformer API

Post by Radu »

Hi Nicolas,

I'm glad this works for you.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply