ID assignment and indexing via Plugin or Authormode Action

Post here questions and problems related to oXygen frameworks/document types.
AndreasM
Posts: 10
Joined: Fri Nov 02, 2018 12:31 pm

ID assignment and indexing via Plugin or Authormode Action

Post by AndreasM » Mon Nov 05, 2018 6:16 pm

Hello
we are currently developing a custom author-mode framework for a project that includes large amounts of "TEI-esque" XML Datasets (e.g. for persons or places). I have come pretty far working with the built-in functions and existing plugins but have reached a point at which I might need to dive deeper.

Researchers will be adding new data to an existing database using the author-mode in Oxygen. We need to manage ID assignment and indexing.

At the point of creating a new file from a template(eg. for a new person),
1. Oxygen should get an ID from a server-side JSON file and
2, prompt the User ( via a Popup Window) to enter the name of the person
3, The ID and name should then be written into the respective elements/attributes within the XML file and into the filename
4. and both (ID and Name) be sent back to the server for indexing purposes.

I am currently looking at the sample-plugins from the SDK (workspace-access in particular) Would that be the right approach to implementing this? Could this also be done with the JS Operations from author mode? (My JS skills are more robust than my JAVA skills)
Any ideas at how to best approach this would be much appreciated.

Thank you
Andreas

Radu
Posts: 6507
Joined: Fri Jul 09, 2004 5:18 pm

Re: ID assignment and indexing via Plugin or Authormode Action

Post by Radu » Wed Nov 07, 2018 8:41 am

Hi Andreas,

There is a sample JavascrOxygen XML plugin called "customEditorVariables" here which expands a custom Oxygen editor variable to a custom value:

https://github.com/oxygenxml/wsaccess-j ... le-plugins

More about how such a Javascript-based plugin works:
https://www.oxygenxml.com/doc/versions/ ... in-js.html

and in a new file template you can use Oxygen editor variables, for example an editor variable called ${customID} which will get expanded by Oxygen when the new file template is used:

https://www.oxygenxml.com/doc/versions/ ... lates.html

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

AndreasM
Posts: 10
Joined: Fri Nov 02, 2018 12:31 pm

Re: ID assignment and indexing via Plugin or Authormode Action

Post by AndreasM » Thu Nov 15, 2018 2:53 pm

First of all, thanks for the answer!
I've been looking into the custom editor variables JS plugin.
Is there a way to make http requests from within the plugin (to get the ID from a server file) ?

Radu
Posts: 6507
Joined: Fri Jul 09, 2004 5:18 pm

Re: ID assignment and indexing via Plugin or Authormode Action

Post by Radu » Thu Nov 15, 2018 4:57 pm

Hi,

Sure, you can create an URL for the server path you want to connect to and then use the Java URL API to retrieve content from it.
An example below with sending a ZIP to a certain URL:

https://github.com/oxygenxml/wsaccess-j ... sAccess.js

The difference in your case would be that you would set the method to "connection.setRequestMethod("GET") and then call "connection.getInputStream()".

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

AndreasM
Posts: 10
Joined: Fri Nov 02, 2018 12:31 pm

Re: ID assignment and indexing via Plugin or Authormode Action

Post by AndreasM » Thu Nov 29, 2018 7:58 pm

Thanks for the answer.
Got a working plugin now that gets the correct ID from our server when a new file is created :)

Post Reply