Using Delphi XML Mapper

Embarcadero Enterprise Studio package contains a wonderful utility that can assist any Delphi developer with the ability of importing a XML document for the sole purpose of using it within a datagrid.  Displayed below is a simple SSH cheat XML document that was created using Excel and will be used.

The purpose of this entire exercise to get the XML data into a clientdataset so it can be used in a datagrid.

 

XML Mapper is a stand-alone tool located in the bin folder or you can click on tools and you will see the item called “XML Mapper”.  The tool allows any type of XML document file to be converted over to a data packet file (*.xml,*.cds), schema files (*.dtd,*.xdr,*.xsd), repository files (*.xrp) and transformation files (*.xtr), or vice versa where you can load a datapacket back into an XML file.

Once the file is loaded, you have the ability of viewing either the document or schema view by clicking the tabs below on the left side.  The tabs on top are DTD, XDR or XML-Schema as displayed below.

 

Create and test transformation

  1. First select the radio button that indicates what the transformation creates:
  • Choose the Datapacket to XML button if the mapping goes from data packet to XML document.
  • Choose the XML to Datapacket button if the mapping goes from XML document to data packet.
  1. If you are generating a data packet, you will also want to use the radio buttons in the Create Datapacket As section. These buttons let you specify how the data packet will be used: as a dataset, as a delta packet for applying updates, or as the parameters to supply to a provider before fetching data.
  2. Click Create and Test Transformation to generate an in-memory version of the transformation. XML mapper displays the XML document that would be generated for the data packet in the Datapacket pane or the data packet that would be generated for the XML document in the XML Document pane.
  3. Finally, choose File > Save > Transformation to save the transformation file. The transformation file is a special XML file (with the .xtr extension) that describes the transformation you have defined.

 

The image below shows the mapping  with the field types and the lengths.

 

Upon clicking on the button the result is displayed with the XML data mapped to the particular field.  So now i can save this as a datapacket file and have my clientdataset read the information.

Here is a simple application that will display the XML on a datagrid.

So just follow these simple steps to create an XTR file from XML in Delphi using XML Mapper:

1. Open the XML Mapper Tools from RAD Studio.

2. Load the XML document.  All the nodes will appear on the left section of XML Mapper.

3. Right click on left section and select “Select All Children” option or simply click on each field.

4. Hit “Create and Test Transformation” button in the middle section of XML Mapper.

5. You can than save the Datapacket to a XTR file for use in your application.  It is that simple.

Click on the logo for more information

 

Delphi

 

Apple Offers Apology, Replacement Deal for Tired iPhone Batteries

Apple has finally told everyone that they slowed down your smart devices due to batteries that no longer could no longer perform up to speed.  iPhone users also got a $29 battery replacement deal.

Message sent

The message sent to all users had the following:

“We know that some of you feel Apple has let you down, we apologize.”

“First and foremost, we have never—and would never—do anything to intentionally shorten the life of any Apple product, or degrade the user experience to drive customer upgrades, Our goal has always been to create products that our customers love, and making iPhones last as long as possible is an important part of that.”

Purchase a replacement battery

The apology does not help anyone who purchases a device between $600 to $900 dollars finding out there is only so much you can do. iPhone users is the $29 battery deal which will allow owners of the iPhone 6 and later to replace the batteries in their phones at a $50 discount. The deal lasts for a year, after which Apple will apparently hike the replacement cost back up to $79.  As always, the push for updating iOS came into sight as well.

The apology falls short of telling anyone they are sorry for slowing your device nor does it indicate that their battery stinks, in which case everyone knew.  This is why there is a class suit filed December 21st in Los Angeles as well as Chicago and New York getting involved.

Users of iPhones older than the iPhone 6, iPads and MacBooks aren’t included in the battery deal. However, Apple does offer battery life extension tips for these devices.