Pages: 1
Print
Author Topic: Function "FindInsertLocation" doesn't seem to work correctly  (Read 872 times)
rewers08
Member

Posts: 9


« on: March 02, 2011, 08:26:54 AM »

Hello,

we are using XMAX 5.5.
In an XML-File supported by a XML-Schema we use the function "findInsertLocation" to find the insert location for a certain tag. We use this function in quite many places and in most of the cases it works just fine. In the following example it doesn't work and I can't see why:

<Element A>
   <Element A_1>
   ...
   </Element A_1>

   <Element A_2>
   ...
   </Element A_2>

   <Element A_4>
   ...
   </Element A_4>
</Element A>


What we want to do is to insert "Element A_3" which - according to the XML-Schema - can be inserted inbetween "Element A_2" and "Element A_4". If I place the cursor between these two elements in XMetaL or XMAX I can choose "Element A_3" from the Elements-Window. I see this as a proof that the Schema is correct and XMAX and XMetaL interpret it correctly. We have a Macro (JS) which uses the following call of findInsertLocation:

if( !rng.FindInsertLocation("Element_A_3"), true) {
   rng.FindInsertLocation("Element_A_3", false);
}

According to my understanding this will make XMAX look for an insert location for "Element_A_3". It will first look forward starting from the current cursor location. If it can't find the insert location it will look backwards. I would expect XMAX to move the Range to the approriate position. But the Range remains unchanged. Could it be that the function is not working correctly? Am I missing something? I am quite sure that the following things are correct:

- XML-Schema
- XML file is valid
- JavaScript is correct

Thanks in advance,
rewers
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 1546



WWW
« Reply #1 on: March 02, 2011, 12:23:03 PM »

In our testing here the function is working properly, but it is possible we have not covered all possible test cases. So, it is best if you can provide the schema and the XML instance so we can reproduce the issue. If you do not wish to post those files here please submit a support case with XMetaL Support.

Please also test in both Tags On and Normal view to see if the behavior is the same. In this case (as Range is used) there should be no difference, but if you have uncovered a bug there may be a difference (eg: it works in one view but not the other, or it doesn't work in either but slightly differently, etc).
« Last Edit: March 02, 2011, 12:40:52 PM by Derek Read » Logged
rewers08
Member

Posts: 9


« Reply #2 on: March 03, 2011, 02:09:31 AM »

Thanks for your fast reply.

It seems that we made a mistake. Before calling the findInsertLocation function we called the function rng.SelectNodeContents on the document's root node. I changed the call to rng.SelectBeforeNode on the root node. Now everything seems to work fine.

Sorry for the false alarm.

Greetings,
rewers.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 1546



WWW
« Reply #3 on: March 03, 2011, 02:03:11 PM »

I see, that would do it. Thanks for clearing this up.
Logged
Pages: 1
Print
Jump to:  

email us