Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
Hi All I'm new in ACL, and I want to insert automatically desc and sthead in the tables at the document, I was thinking to do something like this:
function _addMissingTags(){
oid = oid_first();
oid_find_children(oid,$tables,"table");
for( i = 1; i < count($tables); i++){
oid_table = $table[i];
goto_oid( oid_table);
oid_find_children(oid,$desc,"desc");
if(count($desc) < 1){
insert("<desc></desc>");
}
}
}
but it is not working, any help?
Thanks!!
Hi Carolina--
You probably have an issue with context. If you are using DITA (or a specialized version of it), the <desc> element has to follow any <title> element in the table. So, if your tables have titles, then you code will try to insert the <desc> at the beginning of the <table>, before the <title>, which is not allowed by the doctype.
There were also a couple of typos:
If you add a check for the title, you should be able to make it work. Try something like this:
function _addMissingTags(){
oid = oid_first();
oid_find_children(oid,$tables,"table");
for( i = 1; i <= count($tables); i++){
oid_table = $tables[i];
goto_oid( oid_table);
oid_find_children(oid,$desc,"desc");
if(count($desc) < 1){
oid_find_children(oid_table, $desc, "title");
if (count($desc) > 0) {
# we found a title, move caret after it
goto_oid($desc[1],-3); # -3 means "after the oid element";
}
insert("<desc></desc>");
}
}
}
--Clay