Passion of IT

Data types to exchange information

There are a lot of ways to exchange information between two systems written in different technologies.

The first way is using CSV (comma separated values): it is a simple text file (in windows is opened by excel) that contains a table having fields split by a fixed character specified before than this file is written.

There are a lot of libraries to convert from/to csv, to make dynamic csv files (for example in affittavetrina I saved the search information in a simple csv) but the problem of this type of data is that you cannot create hierarchical structures.

you cannot convert complex object in csv but your object must be with all attributes in the first level of the class diagram tree.

 

The second type of data is XML (Extended mark-up language).

XML is the best type to exchange data, there are a lot of libraries to convert java to xml and vice-versa (marshalling and unmarshalling) this technology is used by web services SOA to exchange the information (soap (simple object application protocol) runs over http and exchange a xml file that contains a envelope with the whole object in xml)

There are also a lot of technologies for inquiry xml files that allow to get the needed information without the conversion of xml object to java, it is enough to send the XML string and the query to the method then the interpreter returns the result of this query.

The best technology is XPATH, now I have written a simple test file that uses the libraries contained in the package (javax.xml.xpath) and with this two instructions

xpath.compile(“/Employees/Employee[@id='" + 4 + "']/name/text()”);

name = (String) expr.evaluate(documentXML, XPathConstants.STRING);

I get the name of the employee with ID=4 in the following XML file

<Employees>
<Employee id=”4″>
<age>25</age>
<name>Michele</name>
<gender>Male</gender>
<role>Engineer</role>
</Employee>
</Employees>

A specific type of XML is HTML or XHTML (eXtended Hypertext Markup Language), this type of data is interpreted by web browser to show the page on the computer client with the animations (flash or javascript) and the correct format  (With CSS Cascade Stylesheet).

JQUERY language is necessary for inquiring HTML or XHTML file dynamically while this page is loaded on computer client.

Jquery is like xpath, the difference is that jquery is applied on html file not xml (html is a subset of XML) and jquery is executed on the browser of the computer client, it doesn’t need a particular library and it is possible to use it with java, php and all the technologies to create html page.

 

The last type of data to exchange the information between client and server is J-SON this is hierarchical and the difference with xml file is that this type of data is smaller than xml and requires less time to be processed and to be sent to the destination and requires less overhead to the exchange data.

For the precedent reasons json is used in web service rest.

There are a lot of java libs to convert from object to json for example google G-SON.

the following is an example of json

{
    "type": "menu",
    "value": "File",
    "items": [
        {"value": "New", "action": "CreateNewDoc"},
        {"value": "Open", "action": "OpenDoc"},
        {"value": "Close", "action": "CloseDoc"}
    ]
}

No Comments Yet

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite="
"> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Recent Comments

Michele Rizzithe website doesn't exist. Ara you a robot? In any case it's difficult that an automatic system writes a comment here since there are two captchas...
Hello there! This is kind of off topic but I need some guidance from an established blog. Is it very hard to set up your own blog? I'm not very t...
We are a group of volunteers and opening a new scheme in our community. Your web site offered us with valuable information to work on. You've done a...
November 2024
M T W T F S S
« Dec    
 123
45678910
11121314151617
18192021222324
252627282930  

Login