Join subset of (row) cells collected with a findNodesByXPath

Post here questions and problems related to oXygen frameworks/document types.
Bruno.Ballarin
Posts: 24
Joined: Thu Aug 07, 2014 3:40 pm

Join subset of (row) cells collected with a findNodesByXPath

Post by Bruno.Ballarin » Wed Feb 27, 2019 8:59 pm

Hi,

(environment: Dita Framework customization, Oxygen Author 19.1)

I am trying to find a method within a doOperation that would join a subset of adjacent table cells belonging to the same row.

The subset of cells could be the result of a authorAccess.getDocumentController().findNodesByXPath() operation.

Only the left-most cell of the selection has content, the other cells are empty.

If there is no predefined method, I could try to delete the empty <entry> elements (deleteNode() mehtod) and set the namest and nameend properties of the remaining <entry> (setAttribute() method).

By the way, is there a more friendly way of editing JSOperation JavaScript content than through the interface provided with the Custom Action Editor?
I tried as an alternative to directly edit the dita.framework but not friendly either due to the xml interpretation of some special characters.

Cheers,

Bruno

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

Re: Join subset of (row) cells collected with a findNodesByXPath

Post by Radu » Thu Feb 28, 2019 10:07 am

Hi Bruno,

Please see some answers below:
If there is no predefined method, I could try to delete the empty <entry> elements (deleteNode() mehtod) and set the namest and nameend properties of the remaining <entry> (setAttribute() method).
It's not trivial to implement a join operation. You need to take into account that each cell may have content and that content needs to be merged with the content of the other cells.
If your tables adhere to the CALS table specification maybe you could use directly the "ro.sync.ecss.extensions.commons.table.operations.cals.JoinRowCellsOperation". Otherwise you can contact us (support@oxygenxml.com) and we can give you the source code for our Join Row Cells Operation as it was in Oxygen 19.1.
By the way, is there a more friendly way of editing JSOperation JavaScript content than through the interface provided with the Custom Action Editor?
I tried as an alternative to directly edit the dita.framework but not friendly either due to the xml interpretation of some special characters.
Actually it is. I quote from our user's manual:

https://www.oxygenxml.com/doc/versions/ ... soperation
You can call functions defined inside a script called commons.js from your custom script content so that you can use that external script file as a library of functions. Note that this commons.js file must be placed in the root of the framework directory (for example, [OXYGEN_INSTALL_DIR]/frameworks/dita/commons.js) because that is the only location where Oxygen XML Editor will look for it.
So your JSOperation defined in the Author action would have it's script parameter something like this:

Code: Select all

function doOperation(){doOperationCommon();}
and it would call the doOperationCommon() function defined in the commons.js which could be edited separately.

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

Bruno.Ballarin
Posts: 24
Joined: Thu Aug 07, 2014 3:40 pm

Re: Join subset of (row) cells collected with a findNodesByXPath

Post by Bruno.Ballarin » Fri Mar 01, 2019 12:33 pm

Thank you Radu.

Moving the JSOperation functions defined in the Author actions to an [OXYGEN_INSTALL_DIR]/frameworks/dita/commons.js library helps a lot for fast and convenient editing/debugging :-).

As per the merge of consecutive cells on a single table row, since the cells themselves are built by the script and known to be empty, except the most left cell of the merge, I could use this code (simple un-parameterized example for merging cells 28 and 29 of a 32 columns CALS table):

Code: Select all

myCellRange = authorAccess.getDocumentController().findNodesByXPath("/topic/body/table[1]/tgroup/tbody/row[2]/entry", true, true, true);
authorAccess.getDocumentController().setAttribute("namest", new Packages.ro.sync.ecss.extensions.api.node.AttrValue("col3"), myCellRange[28]);
authorAccess.getDocumentController().setAttribute("nameend", new Packages.ro.sync.ecss.extensions.api.node.AttrValue("col2"), RegBitMapAcronymCells[28]);
authorAccess.getDocumentController().deleteNode(myCellRange[29]);

Post Reply