Pages: 1
Author Topic: Remove or replace child  (Read 1933 times)

Posts: 47

« on: February 20, 2013, 04:20:21 AM »


My xmetal Tree structure is as follows,

      <A111 att1="45" att2="'67>


        <A111 att1="4" att2="'6>
   <A112 att1="4" att2="'6>



Now I want to have the same content as of A11 ->A111 in  A12->A111

I have used removechild Api to remove existing A12->A111 and parntNode.inserBefore(A11->A111,A12-A112) Api to insert it. it says removechild is not permitted

Also i have used replaceChild i.e parntNode.replaceChild(A11->A111 ,A12->A111) it says can not

In both the cases parentNode is A12

Please guide me how can I achieve this


« Last Edit: February 20, 2013, 04:22:41 AM by pooh2583 » Logged
Derek Read
Program Manager (XMetaL)

Posts: 2621

« Reply #1 on: February 20, 2013, 12:25:11 PM »

No idea what your DTD allows (and it isn't clear to me where you want your document to end up) but I have to assume that what your script is trying to do is just not allowed according to the DTD.

While rules checking is enabled (which is the default and something that distinguishes XMetaL from most other editors as it helps stop users from creating invalid markup) an author cannot normally insert markup that is invalid. This applies to APIs as well. See the section on "rules checking" in the Help as it describes the feature in a lot more detail than I have here.

If a script needs to transition a document (temporarily) to an invalid state there is an API named ActiveDocument.RulesChecking that will do that. Just remember to turn it back on after your script finishes and has put the document back into a valid state.
Pages: 1
Jump to: