Home Forums General XMetaL Discussion xmetal selection ReadonlyContainer value Reply To: xmetal selection ReadonlyContainer value

Derek Read

Reply to: xmetal selection ReadonlyContainer value

Having no idea what your document structures look like it is difficult to give the best answer.

However, if there is only one in the document the following should do it. If not, then you would need to adjust appropriately. You may wish to use getNodesByXPath() if the document is complex (in which case you need to deal with DOM nodes and would need to  convert those to a Range before setting ReadOnlyContainer).</p> <p><tt>//XMetaL Script Language JScript:<br />var rng = ActiveDocument.Range;<br />rng.MoveToDocumentStart();<br />if(rng.MoveToElement("title")) {<br />  rng.ReadOnlyContainer = true;<br />  rng.NonRemovableContainer = true;<br />}</tt></p> <p>You say “the reference to the selection will change”. I'm not sure what you mean by that, but it sounds like maybe that is your issue. There is only ever one Selection object in a document, set by the user and possibly manipulated using script. Generally scripts use Range instead as you can have multiple Range objects, they are invisible, and they can go some places that a Selection cannot.

Reply

Products
Downloads
Support