Tag Archives: YAML

Data representation

Data can be represented in text format for human and binary format for computer. Here my focus will be on text representation.

For application, we commonly use XML because:

  1. Its self-documenting format describes structure and field names as well as specific values. And it is easily digested by both human and machine.
  2. It is platform-independent, thus relatively immune to changes in technology and facilitate in data exchange across heterogeneous systems.
  3. It supports Unicode.
  4. It can represent common computer science data structures: records, lists and trees.
  5. It allows validation using schema languages such as DTD and XSD. XSDs are far more powerful than DTDs in describing XML languages. They use a rich datatyping system, allow for more detailed constraints on an XML document’s logical structure, and must be processed in a more robust validation framework.

With all the above advantages, it quickly becomes the standard of data exchange especially in web service world. However, XML also carries its disadvantages like it is verbose and the hierarchical model for representation is limited in comparison to an object oriented graph.

Other options:

  1. XML vs JSON - JSON is now more attractive than XML for kinds of data interchange that powers Web-based mashups and Web gadgets widgets. Why? Look at the articles below:
    • Fixing AJAX: XMLHttpRequest considered HarmfulYou don’t see much AJAX examples that access third party web services like Amazon, Yahoo and Google. That is because all the newest web browsers impose a significant security restriction on the use of XMLHttpRequest. That restriction is that you aren’t allowed to make XMLHttpRequest to any server except the server where your web page came from. If you attempt to do so, XMLHttpRequest will either fail or pop up warnings, depending on the browser you are using… Solution: Application Proxy, Apache Proxy or Use Script Tag Hack (On-demand Javascript).
    • JSON vs XML: Browser Security ModelThis article comments the solutions proposed above. It indicated that Script Tag approach is better than proxy.
    • JSON and Yahoo!’s Javascript API – This article will give you example of how to use Script Tag to communicate with Yahoo Web service API and bypass the restriction of XMLHttpRequest. The way to bypass XHR restriction is not using XHR at all. The cross-site requests are made by adding script tags to a document’s HEAD with DOM methods (i.e. [code]]czoxNDpcIi5hcHBlbmRDaGlsZCgpXCI7e1smKiZdfQ==[[/code])
    • Is JSON better than XML (a good objective review)
    • In conclusion, JSON enables you to use Script Tag approach to bypass XHR security restriction b/c JSON itself is part of Javasript. That makes JSON popular.
  2. YAML as an alternative of data serialization
  3. Java Serialization will take object to binary representation (versioning headache). XStream is a simple library to serialize objects to XML and back again.

For machine, data is represented in binary format:

  1. The art of assembly language (a free book that you can read online)
Leave a comment Continue Reading →