• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Why use XML?

 
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know this is probably a rhetorical question, but I still can't figure it out. How and Why do you use XML? I see the sites that explain what it is and what it can do (as well as books, and I've even had a 5 day class on it), but I have not seen a practical example of why I have to use it. I would like to try it, but I can't wrap my head around it. Can anyone give me a concrete example of an application (without any trade/Corporate secrets, etc.) that uses it with JAVA and/or JSP?
What would be a good rule of thumb for when you should use it?
Thanks.
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We can logically divide all uses into two big groups: 1) XML as a persistent mechanism and 2) XML as a mechanism to transfer transient data.
1. XML as a persistent mechanism .
In this category XML serves as an easy-to-use, cheap alternative to database. When you may prefer XML to database?
1) If you do not have huge amount of information. XML design goals include easy-to-use and all all all, but memory/performance optimization was not even mentioned. Even worse, memory/performance optimization was the price that was paid to achieve other design goals (like "human readability")
2) if you do not need extra services databases provide:
transactional integrity
security
authentication
concurrency control
developed search mechanism
multiple views
(Surprisingly enough list of database virtues looks suspiciously similar to the list of XML proposed initiatives... security... authentication... XQuery as a search mechanism, XSLT as multiple view generators... Hm... In any case, databases are far more mature.)
One example of popular usage includes program configuration files, which are now often written in XML. Another example is representation of data on the WWW, where you can take advantage of XML ability to separate content from presentation. By applying different stylesheets, you can get differently formatted documents for several agents.
2. Transfer transient data.
XML becoming a popular high-level protocol in distributed computing. Such technologies as SOAP or XML-RPC use XML as an underlying format for remote procedure calls. However, here I am leaving my area of competence and risk to get Michael Ernest (another moderator of this forum) sarcastic comments. If you manage to get his attention, he will tell you a lot of how "fat" XML protocols increase network traffic manifolds without any reasonable benefit. Another example of high-level protocol that uses XML is Jabber.
I have not seen a practical example of why I have to use it
Here is Scott Bain's post in this forum that he later rework into a FAQ:
"I'll tell you some of the specific areas where I use it -- perhaps that will help.
I use XML to store configurational information for an application. For a server, for instance, I might store its IP address, root folder, handler application paths, etc...
I use XML to communicate over a network connection. For example, one of my clients needs to send complex information between an AS/400 and a Java application, using sockets. We structure this information in XML.
I use XML (via SOAP or XML-RPC) to create distributed objects, to make method calls to remote objects over a TCP/IP connection.
I use XML to control a project (the CDROM mentioned above). The slides, audio files, video components, etc... are all managed by an XML structure that defines what audio goes with what file, etc... then I use XSLT to translate this into a catalog page, javascript arrays for the actual tool, etc... If I need to move a slide, add a video clip, whatever, I just change the XML and re-run the transformations.
These are just some examples. As has been said elsewhere in this forum, XML is not a magic bullet, but a useful tool. I don't mark up huge amounts of data with it (I have not found a need for this). I use it primarily as a way to communicate between processes, and to control various activities within a process".
Areas where XML is most useful
[ May 18, 2002: Message edited by: Mapraputa Is ]
 
Sam Smoot
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the info... I'll be digesting this for a while... It looks like it'll help.
Thanks again...
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We use XML extensively for generating complex presentation data from business entities. A factery pattern cooks XML documents combining two or more business entities. Think MVC. The model comprises of business entities while the controller, ie., the factory creates XML views.
The documents thus generated are transformed on the server side( using a dynamic XSL lookup ) to generate presentation. We also send such documents across the wire to collaborating business components.
As you can see, the XML is being used as an ad-hoc representation of business entity. It is also the currency of data exchange between trusted parteners. The business logic layer always deals with XML-ized business entities thus enabling us to completely hide the internal methods of data access and persistence in the EJB layer.
Hope this will give you some food for thought.
 
Drove my Chevy to the levee but the levee was dry. A wrung this tiny ad and it was still dry.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic