From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,XPRIO autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5903ab5e65d46397,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!newshub.sdsu.edu!ctu-peer!Spring.edu.tw!news.nctu.edu.tw!feeder.seed.net.tw!netnews!not-for-mail From: "bubble" Newsgroups: comp.lang.ada Subject: Gnatcom problem with MS XML Date: Fri, 18 Mar 2005 18:58:57 +0800 Organization: HiNetNews Message-ID: NNTP-Posting-Host: 211-21-128-195.hinet-ip.hinet.net X-Trace: netnews.hinet.net 1111143543 17431 211.21.128.195 (18 Mar 2005 10:59:03 GMT) X-Complaints-To: usenet@HiNetnews.hinet.net NNTP-Posting-Date: Fri, 18 Mar 2005 10:59:03 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 Xref: g2news1.google.com comp.lang.ada:9612 Date: 2005-03-18T18:58:57+08:00 List-Id: dear all: I am learning how to use Gnatcom . I do a COM's practice ; the practice is Microsoft XML COM Library(msxml3.dll and msxml5.dll) . I get some problem in practice and I can not sure where problem is? I write my questions in code comment. if you can understand my problem , could you explain why? thank you. my OS is windows XP. my compiler is GNAT 3.15P + Gnatcom -------------------------------------------------------------------------------------------- -------this is full complete test code. ---------------------------------------------------------------------------------------------- with Gnatcom; with Gnatcom.Initialize; with Gnatcom.Bstr; with Gnatcom.Variant; with Gnatcom.Types; with Ada.Text_Io; with Msxml5.Ixmldomdocument_Interface; with Msxml5.Ixmldomelement_Interface; with Msxml5.Ixmldomnode_Interface; procedure Test is use Msxml5; use Gnatcom; Dom : Ixmldomdocument_Interface.Ixmldomdocument_Type; P_Root : Pointer_To_Ixmldomelement; Node : Ixmldomelement_Interface.Ixmldomelement_Type; Node2 : Ixmldomelement_Interface.Ixmldomelement_Type; begin Gnatcom.Initialize.Initialize_Com; --- initialize COM environment Ixmldomdocument_Interface.Create(Dom,Clsid_Domdocument); P_Root :=Ixmldomdocument_Interface.Createelement(Dom,Gnatcom.Bstr.To_Bstr("root")); Ixmldomdocument_Interface.Putref_Documentelement(Dom,P_Root ); Ixmldomelement_Interface.Attach (Node,P_Root ); Ixmldomelement_Interface.Attach (Node2,P_Root ); ---here I get problem ----------------------- ------------------------- why can not attach P_Root to Node twice? ------------------------- -------------------------- if I write the statement " Ixmldomelement_Interface.Attach (Node,P_Root ); " twice. -------------------------- such as -------------------------- ------------------------- Ixmldomelement_Interface.Attach (Node,P_Root ); <- pass -------------------------- Ixmldomelement_Interface.Attach (Node,P_Root ); <- crash here -------------------------- -------------------------- it will crash at second statement. -------------------------- -------------------------- if my code is -------------------------- ------------------------- Ixmldomelement_Interface.Attach (Node,P_Root ); <- pass ------------------------- Ixmldomelement_Interface.Attach (Node2,P_Root ); <- pass -------------------------- -------------------------- perfect work and I still don't know why? -------------------------- for I in 1 .. 2 loop declare Tag : Types.Bstr := Bstr.To_Bstr ("child"); Ns : Types.Bstr := Bstr.To_Bstr (""); Node_Type : Types.Variant := Variant.To_Variant (Node_Element); P_Child : Pointer_To_Ixmldomnode; Child : Ixmldomnode_Interface.Ixmldomnode_Type; begin P_Child:=Ixmldomdocument_Interface.Createnode (Dom, Node_Type, Tag, Ns); declare X_Child : Pointer_To_Ixmldomnode := Ixmldomelement_Interface.Appendchild (Node, P_Child); begin --------- --------- --------- here I do attach x_child to child over twice again --------- the code is --------- ---------- Ixmldomnode_Interface.Attach (Child,X_Child ); <- pass ---------- Ixmldomnode_Interface.Attach (Child,X_Child ); <-pass --------- --------- Ixmldomnode_Interface.Attach (Child,X_Child ); Ixmldomnode_Interface.Attach (Child,X_Child ); end; Bstr.Free(Tag); Bstr.Free(Ns); end; end loop; declare Xml : Gnatcom.Types.Bstr; begin Xml:=Ixmldomdocument_Interface.Get_Xml(Dom); Ada.Text_Io.Put_Line(Gnatcom.Bstr.To_Ada(Xml)); Gnatcom.Bstr.Free(Xml); end; end;