Quantcast
Channel: PTC Community: Message List - Arbortext
Viewing all articles
Browse latest Browse all 3717

Re: What ACL command(s) can I use to modify a table after insert it using tbl_insert() command?

$
0
0

Well, on closer inspection, it seems the OASIS (CALS) table model doesn't support inserting a table title using tbl_table_title_insert(). (The documentation mentions this, but I overlooked it earlier.) Maybe this is because a DITA table can have a wrapper (<simpletable>) that doesn't support the <title> element.

 

Anyway, it looks like you may have to use a direct DOM table structure approach to this problem. For the <title> and <desc>, find the container <table> element and use the usual insert_tag command or insert() function. For example, to insert a new element into a table (at the wrapper level), something like this should work (where the caret is inside the table:

 

function add_table_element(name, text) {

     local oid = oid_caret();

     while (oid_valid(oid) && (oid_name(oid) != "table")) {

          oid = oid_parent(oid);

     }

     goto_oid(oid);

     insert("<" . name . ">" . text . "</" . name . ">");

}

 

You would need to add some error checking (if caret is not inside table, if the requested element already exists, etc.), and make sure you add the elements in the right order to make sure the result is valid.

 

I was able to get row insertion to work in a DITA document using code like this (where the caret is anywhere in the table to be updated):

 

function add_row() {

  local toid = tbl_oid_cell(oid_caret());

  local tgrid = tbl_obj_grid(toid);

  local rows[];

  local nrows = tbl_grid_rowlist(tgrid, rows);

  tbl_obj_add(rows[nrows], 0);

}

 

Of course, you can always find the <tgroup> element and insert your own <row> element as described above. If you take that route, you'll also need to insert the correct number of <entry> elements to keep the table structure intact.

 

--Clay


Viewing all articles
Browse latest Browse all 3717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>