Simple analysis of TXMLDocument internal structure

zhaozj2021-02-11  177

The first time I was interested in txmldocument, and I used TXMLDocument when I used TXMLDocument. At that time, I was aimed in a software, just want to add a point, because I didn't have much, I decided to do an interface first, slowly expand, but how Make the interface expansion performance, can mix with various tools, so I think that Java uses XML to configure the method, the syntax is from C , the architecture is from Java (which of the above idea is also copied from Java, haha), is of course It was used with delphi, so I wrote a configuration file. I found that TXMLDocument can't read the data. I checked the XML file, the unnailed, and finally changed the Domvendor property. It turned into OpenXML. Now I decided to go to my old trace, do it in Domvendor, start simply analyze TXMLDocument, it is important to choose the entry point correctly, it is necessary to waste a lot of time, sometimes this is really luck.

When the Domvendor property is like an enumeration property, but in txmldocument is defined as class tdomvendor; this is of course thinking to find DefineProperties, chasing the READOMVENDOR from DefineProperties, and finally find the real entry getDomvendor (DomvendorDesc).

The structure is officially introduced below.

TXMLDocument is divided into two layers, one layer is idom *****, one layer is IXML ******, IXML is an interface for users to use, IDOM *** should be DOM as a model defined as model For IXML use, IDOM has a variety of specific implementation means, this is a typical Bridge mode, I will take pictures, you can follow ( gof Chinese version) 101 pages which picture is controlled.

When we use the IXML *** interface, it will use idom to complete the operation.

Here IdomDocument is inherited idomnode, but IXmldocument is not, it seems not necessarily, because the internal main use of IDM interface, if you want to idomnode, you can use idomDocument to convert it, it is not used.

So much implementation, how to create a corresponding example accurately and beautifully, use the Abstract Factory mode in TXMLDocument, refer to the following figure

Abstract Factory wants to specify specific classes, but in order to find them, in txmldocument is through specifying a string, what kind of strings we appear when you click Domvendor. Now go back to start, let's take a look at the entry point

Domvendor: = GetDomvendor (DomvendOrDesc);

Finally, I get a idomplementation, which has a createDocument (....): IdomDocument; function, this function will return an idomDocument; the interface allows IXmldouCment.

If you use MSXML, the interface corresponds to TMSDomDocument, TMSDOMDocument is actually calling MSXML technology, below is the code called MS COM.

Function CreateDomDocument: ixmldomdocument;

Begin

Result: = TryObjectcreate ([Class_DomDocument40, Class_DomDocument30,

Class_Domdocument26, msxml.class_domdocument]) as ixmldomdocument; if not assigned (result) THEN

Raise DomException.create (SMSDomnotInstalled);

END;

Class_Domdocument26: tguid = '{F5078F1B-C551-11D3-89B9-0000F81FE221}';

Class_Domdocument30: tguid = '{F5078F32-C551-11D3-89B9-0000F81FE221}'

Class_DomDocument40: tguid = '{88D969C0-F192-11D4-A65F-0040963251E5}';

OpenXML uses another method

It doesn't know how to make a TDOMPLEMentation, there is another createDocument, in contrane, there are many code, no energy.

Which TXERCESDOMPLEMENTATIONFAACTORY is also used in Linux, but there is a small code, look at it.

Initlibrary;

GetDomproc: = getProcaddress (Flibhandle, sgetdomimpl);

GetDomproc (Result);

Run to the dynamic connection library, save me to waste time.

转载请注明原文地址:https://www.9cbs.com/read-5383.html

New Post(0)