Pages: 1
Author Topic: MoveToElement() skips thead and rows  (Read 1878 times)

Posts: 19

« on: March 04, 2014, 04:38:27 AM »

XMetaL Author 6.0

I have documents with cals-tables in them.
If I run a macro with a simple loop with a rng.MoveToElement() to fill all open id'd the loop skips all <thead> elements, most <entry> elements and the elements from about row 2 and beyond.
Is this a bug? What is wrong here? Is there a solution?

To reproduce, run the macro on the demo-table below:
   // XMetaL Script Language JSCRIPT:
   var rng=ActiveDocument.Range;
   var n=0;
   while (rng.MoveToElement()) {
      if (rng.hasAttribute("id") && rng.ContainerAttribute("id")=="") {
         rng.ContainerAttribute("id") = "P"+n;

   <tgroup cols="5">
« Last Edit: March 05, 2014, 03:01:57 AM by KdG » Logged

Posts: 57

« Reply #1 on: May 15, 2014, 03:15:12 PM »

You'll need to rewrite the code to use XMetaL's DOM APIs instead.

Range and Selection objects are limited to what elements they can select, especially if the requested selection state cannot be made by a user on-screen in Tags On or Normal view.  As you are seeing, it is not possible to select a thead programmatically and neither is it possible with a mouse.  When attempting to make such a selection, XMetaL will adjust the selection to the nearest location that is selectable on-screen and/or also permits text input like a entry element.



Addam Smith, XMetaL Project Lead & Architect
JustSystems Canada Inc.
Pages: 1
Jump to: