Pages: 1
Print
Author Topic: Remove or replace child  (Read 1932 times)
pooh2583
Member

Posts: 47


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

Hello,

My xmetal Tree structure is as follows,

<Node1>
<A>
  <A1>
       <A11>
      <A111 att1="45" att2="'67>
              <A1111>data</A21>
      </A111>

   </A11>

   <A12>
        <A111 att1="4" att2="'6>
              
   </A111>
   <A112 att1="4" att2="'6>
              
   </A112>
   <A12>
 </A1>

</A>

</Node1>


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 insert.in

In both the cases parentNode is A12

Please guide me how can I achieve this

Regards


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

Posts: 2621



WWW
« 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.
Logged
Pages: 1
Print
Jump to:  

email us