Delphi 6 XML Image Tool

zhaozj2021-02-16  45

Delphi 6 contains many updated XML support features, adds XML file programming, XML data binding wizards, XML images, and BizSnap (SOAP / XML Web services). This article discusses the third article of the XML function series in Delphi 6, and the last article discusses the XML image tool in Delphi 6, also known as the XML Mapper.

The XML image can open an image device (XML Mapper) separately on or in the IDE tool (Tools) menu. This tool will use the XML file into a Dataset in the database! In the previous two articles, we all use TXMLDocument components to process XML files or XML binding data. Now, we no longer use the TXMLDocument component. We use the XML image to convert the XML file into a packet (or vice versa), so you can use the components such as DataSet to use components such as DataSet. The XML image can open the XML file and packet file (* .xml, *.), Outline file (* .dtd, *. Xdr, *. Xsd), library file (* .xRP), and conversion files (* .xtr). The back this conversion file is generated by the imager itself. Load us using the clinic.xml file used in the previous two articles to see what data is made.

As shown in Figure 1, clinic.xml is imaged into a CLINICS structure and contains several Clinic subtries. Each CLINIC has 4 domains: @no, title, date, and topics. Note @no is attribute, and the other three are elements. Move the mouse to the CLINIC node, press the right button, select "Select All" or "Select All Children", which adds @no, title, date and topics to the middle image table. There is no corresponding data set area. We reach the right mouse button again to the CLINIC node, select "CREATE DATAPACKET from XML" (Ctrl D), which generates the corresponding packet and displayed in the right of the imager, as shown in FIG. The image converts the XML file into 4 standard format packets. We can also add or delete packets. This is especially important in B2B, and the received data (record) is inserted into the database.

Create and test the conversion Press the Create and Test Transformation button, then pop up a DBGRID window, display the data in the clinic.xml file in the ClientDataSet packet format. After data conversion, there are 4 ways of deployment. For beginners, you can save back to the original clinic.xml file. Also available as package data file format (* .xml), repository format (.xRP), and conversion file format (* .xtr). The rear library files can be called by the XMLTransform component (in the Data Access tab).

XML conversion Delphi 6 has 3 XML conversion components. The TXMLTransFormProvider component converts the original XML file to the clientDataSet via the clinic.xtr file. For example, a TXMLTransformProvider is placed on the main form of Delphi 6 (in the Data Access tab). Set the TransformRead property of TransformRead attribute to clinic.xtr as a data source. Set XMLDataFile to a Clinic.xml file. Then place a ClientDataSet component, set its provikername properties to XMLTransformProvider. You can now activate the ClientDataSet component, which will be converted from the data provided by XMLTransformProvider. Its packetRecords property value is default to -1, indicating that all XML files are converted. To display data, we join the DataSource and DBGRID components. Point DataSource points to ClientDataSet, DBGRID points to DataSource, just like we usually use. The result is shown in Figure 3. You can now use the data in the XML file like using database data. If you modify the data, you can call the clientDataSet.ApplyUpdates method to save the data back to the XML file. But this is not enough. We have to start the XML imager and change the creation by "XML to DataPacket" to "DataPacket TO XML". At this time, if you press the "Create and Test Transformation" button, you can see a blank page. The conversion result is then stored as a CLINICTOML.XTR file. Now, set the child property transformationFile in the TXMLTransformationProvider's TransformationWrite property to a Clinictoxml.xtr file. Finally, in the ONCLOSE event of the main form, add the storage instruction: clientDataSet1.Applyupdates (-1) program to modify the XML file before exiting. This makes data preparation for the virtual intermediate layer of the B2B development environment BizSnap of Delphi 6.

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

New Post(0)