This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Why,When,Where-> XML??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Why,When,Where-> XML???" Watch "Why,When,Where-> XML???" New topic
Author

Why,When,Where-> XML???

mahadevan raja
Ranch Hand

Joined: Apr 11, 2001
Posts: 96
hi all,
plz help me out,i am totally confused of why to use xml
i read in many books that it is for data interchange,and other uses of it.
i also saw in a post that u can create an xml file from a database query.
but i have lots of confusions.
First is:
What data interchange exactly is,already i had posted this query,but i did not get a proper simple reply.
Second is:
when v have a database then y shud we convert it into an xml file,there shud be some valid reason behind it.
Please somebody clear me my doubts,
i have almost finished xmlparsing using domparser.before i proceed further,i shud be clear with y xml and not others.
How,where and under what scenario shud i use xml.
Reply soon.
Thanx in advance.


SPECIALIST-WCSV5.1 Implementation.<br />SYSTEMS EXPERT-WAS4.0 Administration
Raf Van de Plas
Greenhorn

Joined: Aug 29, 2001
Posts: 13
I would like to point out my view on XML.
What happens today if you want to make a data format or document that needs to be read by multiple systems (= differences in hardware or software, it doesn't matter as long as they're different from eachother). You would decide on a certain way of storing your data and then have to adapt these systems to correctly interprete the document. This is often very difficult or even impossible and would often require source code and recompilation (I'm not even getting started about the hardware problems such as the big endian & little endian issue). The industry had to come up with a solution that was interpretable by almost any system and this meant using plain text. That way this solution (XML) is editable and viewable in any plain text editor, and this would be impossible with a binary format.
Then came the issue of how we're going to recognize certain data between other characters. For this part of XML, they used a subset of a standard that's around for almost 30 years, called SGML. They threw away the bits of SGML that weren't really worth their salt and created the XML 1.0 specification available at www.w3c.org. SGML and XML are not a language to encode data in a text-document, but they are meta-languages. This means: with XML you define a language for the specific purpose you want to achieve (and create whatever elements you need). Examples of such a language, defined by XML, are MathML and XHTML (The XML specification of HTML 4.0).
Well, I've given quite an extensive explanation about what exactly XML is, but maybe you're wondering why we need it.
XML is a way of making you're stored data available to programs other than the parent app that created the file in the first place. This can be done by adapting a system to understand XML or (if the legacy system cannot be changed) by using a separate XML parser that outputs a data format that the legacy system can understand.
In conjunction with databases, XML serves a rather subjective role. When you're data is resting on a system (i mean not moving through different architectures or needed by any program that doesn't understand a DB resultset) you should use whatever DB you use and handle you're data through SQL. But whenever you want to exchange data with some other source (like a file or other database) you're better off first converting to XML and then importing it in you're DB. (I know, the big databases often provide some function to import different data formats, but in the real world the one you need is often just not in the list and you're glad you can import XML).
Well I could go on like this forever but it's probably better if anyone with an XML question just posts it here and I'll try to give you my 2 cents about the solution.
Anyway raja, hope I could help you out. If not let me know too
-------------------------
Raf Van de Plas
The Angry Belgian
mahadevan raja
Ranch Hand

Joined: Apr 11, 2001
Posts: 96
oh thanx for that huge reply of urs,i am able to get some idea of it,but according to ur first solution it is somewhat acting like mqseries,hope i am right,that means it wud act like a middleware.isnt it.
and one more thing is u can format the xml to any required format using xsl.u can create an xml file accessing data from database.
but these things can be done in jsp itself.
instead of creating an xml file using the database contents and then converting it using xsl,u can directly write a single jsp and create the required format(of course only possible in the case of html).
plz reply soon.
thanx for ur detailed reply.
Raf Van de Plas
Greenhorn

Joined: Aug 29, 2001
Posts: 13
Hi,
I'm afraid I haven't had any experience with "mqseries" so I can't really say if XML serves a similar purpose, but you're partially right about the middleware-use of XML. I say partially because XML is much more than that single application. It can be used as universal data format between systems, never actually seen in that form by a user (=middleware). It can just as well be served directly to a customer (by applying a stylesheet or something). It serves as a common denomitor. Every single system that understands XML (and it's dictionary in the form of a DTD or schema) is able to talk with eachother.
About the Java server pages you're right: XML is not really necessary if you just want to show DB data on a webpage. But if you needed multiple clients to access the same set of data (some clients being webpages, but others being actual apps for example) it would be better to keep the access to the DB unified and simple through the use of XML.
Another benefit of XML, not very well known, is that it's much simpler to use for persistence of data if the dataset has rows that differ greatly in field fillup. In a relational DB this would mean that some rows would have a whole lot of empty or null values in fields that they really don't need, because somewhere there's a small number of rows that do need them. In XML you work more according to the OO paradigm and can individually add and remove to elements when necessary without causing a lot of empty fields in other elements.
Hope this clarifies things,
if not let me know
Raf Van de Plas
The Angry Belgian
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
You can certainly use messaging middleware to move XML messages around, but remember that XML is a way of formatting data, not a transport mechanism. My first real use of XML was for an intermediate format for questions for mock Java Programmer exams.
People use XML formatted data out of databases to make it easier to reformat the data for presentation. The presentation is then controlled by a separate XSL file. There is a whole massive effort to represent entire web applications as XML combined with XSL - see the Cocoon project and many others at xml.apache.org.
Another widespread use in Java is for configuration files. It is MUCH easier to represent program configuration data in an XML hierarchy than in "flat" properties files. Thats why Sun went entirely to using web.xml for configuring web applications.
Bill
Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
Hi, I will start to learn XML two weeks later after i finished up other things. I have 2 questions:
1)Talking about OO and XML, is there any detail article talking about XML with OO style? I tried searching Object-Oriented+XML and get nothing useful , poor me.
2)I've posted a topic "What XML can do with E-Learning Applications?". The only kind of application I feel I may interested(to be implemented as a mini team project) is "reuse course content more easily" metioned under that topic. I wonder if it's very easy/medium/hard for me to implement it in 1 month? If it's not "very easy", then I will just implement on this area, if not, then I will need to think again which area XML can use on e-learning app. Since I haven't touched XML yet so I need experienced people's estimation. Thank you very much


Thanks everyone who helped me
Raf Van de Plas
Greenhorn

Joined: Aug 29, 2001
Posts: 13
Hey Ken,
tell us something more about what your objective is with that class you've got to give and why you want XML in it so badly.
Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
Hi,Raf Van
As I'm studying Internet Comp, I've a project :As a continuation to your CyberVision project (max 4 students) in e-Commerce course (COMP418)[1], your team are required to further enhance your "dotcom" application with ANY ONE of the following modules: Example: Extend your EC project with XML technologies
As I've build a simple e-learning site in e-com subject so I want to extend my e-learning app with XML. I haven't learnt XML yet but i need to hand in proposal about my XML plan, the only idea in mind is using XML as "content separation" as discuss above or in other topic named "What XML can do with E-Learning Applications?", without learning XML I don't know the degree of difficulty in doing so, therefore, I can't write up a proposal yet.
Another matter of OO and XML because I need to write a term paper of OO, I want to link it with XML but it seems difficult for me to find any article related to this. Hope I can get some hints from here. Thanks
Raf Van de Plas
Greenhorn

Joined: Aug 29, 2001
Posts: 13
Hi,
First things first: my first name is simply 'Raf' (short for Raphael), all the rest is part of my surname.
Well it looks like you've got the main idea already. XML was conceived for separating the content from the presentation. I think this should give you ample possibilities for exporting the content of the courses you're offering to various media and formats (I'm thinking simple HTML on the site, the possibility to get a PDF, created server-side, with the same content but in a more printable form (just look for a simple PDF-generating script or app).
If everything already comes from a DB, you can still use XML to reduce access to the DB for the less important data. In fact I'm sure you've put certain data in the DB just because you needed some form of persistence and wanted to keep things as simple as possible (if not, you're the first I've heard of to be so disciplined ).
An example: If you're offering some form of help to your users, you could put the help topics and their explanation into an XML document instead of in a table in your DB.
In fact you can keep any information that is not subject to a lot of editing clear of the DB and unload it somewhat.
Another fine benefit of keeping not-frequently updated info out of the DB occurs when you've got extensive security features. When you're access to the DB is checked for security and validation, it would be a waste of resources to have to go through all that checking just to get to the read-only explanation of a certain help topic.
Hope this gives you some ideas, because it all depends on your situation and what you've got implemented at the moment.
What the link between OO and XML is concerned, you may be able to get some ideas from the JAXB at Sun (http://java.sun.com/xml/jaxb/index.html)
Anyway, any questions plz ask...
Raf
The Angry Belgian
mahadevan raja
Ranch Hand

Joined: Apr 11, 2001
Posts: 96
thank you guys,u all helped me a lot in understanding the concepts,cya.
thanks again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why,When,Where-> XML???
 
Similar Threads
Need Help
Read data to the xml file from the database?
Why XML Schemas???
XML/XMI XSL/XSLT
Urgent->where the table is stored by default of an cmp entity bean