What is the advantage of XML?

I just read the sample chapters of the new XML book, and im kinda confused, what is the advantage of XML over plain XHTML?

The book states that it is easier to display documents in mobile devices using XML, and that is easier to translate content language. But, it doesn’t demonstrate either of them, nor gives any other reasons to use XML. I find the XML concept intresting and it could be the next big thing…but currently i cant see why i should use it over XHTML and PHP…

I’m kinda sure that its very easy to implement a template system and different languagefiles in PHP and XHTML only. And if XHTML is designed to just make it easy to make web documents, I cant see why i should use XML if i dont plan to view my site in mobile devices…

Anyone care to enlighten me ?

XML and XHTML do completely different things,

xhtml is a markup language for displaying web documents.
xml is a standard for storing/transmitting content/data.

there is absolutely no presentation data in an xml file.
xml is converted into a xhtml by an xsl stylesheet.

the same xml content can be used to display 2 completely views or be used on completely different pages accross the internet.

example: you can parse an xml file sitting on my server and create your own webpage using the information I’ve added to my xml file.

you then convert that xml content into an xhtml document so you can display it as a webpage on your server.

the most basic use of XML is for two systems to understand the same piece of data. Before XML markup if you wanted to send some data to a java server you would make a comma seperated list of data

jim,test,data,but,what,does,this,mean

that format is very fragile, every field needs to be exact, if you add a field in the middle then you break the code. And what data is that string describing?

xml solves human readability and computer readability by tagging data
<customer>
<name>jim</name>
<addresss>555 oak lane</addresss>
</customer>

if you look at that data you know exactly what it does. XML at its basic function is for transmitting data across systems. By adding a schema around this document you create a “contract”. Which means you validate the xml you get against the schema to see if it complies with the contract you have with the other party.

the most basic use of XML is for two systems to understand the same piece of data. Before XML markup if you wanted to send some data to a java server you would make a comma seperated list of data
What is wrong with CSV for data for data exchange?

that format is very fragile, every field needs to be exact, if you add a field in the middle then you break the code.
If course both parties need to have a common data model. It’s no use sending data that the other party does not understand of course.

xml solves human readability and computer readability by tagging data
I can understand that it improves human readability, but why is it necessary for humans to be able to read a format that is used to transfer data between two computer applications? How does it improve computer readability? I don’t see why computer application would find <bla>bla</bla> more readable than bla,bla,bla.

if you look at that data you know exactly what it does.
Data does not “do” anything, it means something. Again why is it necessary for, presumably humans, to be able to figure out what the data means when it is used for exchange between computer applications whose designers have upfront agreed a meaning for the data they send to eachother?

in simple terms, xml is a human readable, standard, multi-platform, web based storage system.

xhtml is a markup language for formatting content for a web browser.

jim,84.48,test,3

what does that data mean to a computer? 4 fields? thats pretty generic

if I send
84.48,jim,test,3

will the computer know the difference? its still 4 fields however I just switched a string with a float

if you create a schema for your xml document you can state that
<name> must be a string
<price> must be a float
<id> must be an int

allowing the computer to know what the data is and if something is sent that does not agree on that contract, it is an invalid data stream. Can you please write up how you would be send a complex type using csv? that java could understand from a php data feed?

XML is built for computers to understand the data they receive, being human readable is a by product of the format.

Lets not turn this into a discussion of whether XML is just hype, its clearly not, its here, in use, every nanosecond.

Huh?!? XHTML is XML. Which goes to show one of the cool things you can do with XML – XHTML docs.

You can also use XML to delimit and describe data such as the example jplush76 shows. The upside as noted is that the description of the data goes with each value. And it is human readable to an extent. The downside of that is that the XML document is much bigger than the delimited one.

PHP is generator language in that browsers don’t understand PHP but the do understand the XHTML or XML that PHP generates.

What is wrong with CSV for data for data exchange?

Nothing, to a certain point I suppose, but I’ve always thought of it (CSV) as having no structure. Without structure, you have no means to represent the data, none whatsoever actually.

but why is it necessary for humans to be able to read a format that is used to transfer data between two computer applications?

I don’t actually feel the format it’s self has anything to do with human readability, but what has got to do with human readability, is what you can do with that format? Which kind of backs up my first response from the quote I made of your post.

The computer is only interested in the data, not what to do with it in other words :slight_smile:

to be able to figure out what the data means when it is used for exchange between computer applications whose designers have upfront agreed a meaning for the data they send to eachother?

You’ve said as much yourself… It’s about distribution of the data. We have XML as such as the format as it is, because the people of the W3C had the obvious vision of what they, and others that contributed advice and contributed their views, could do with just that format.

Big business had an invested interest in how XML was developed as a format, and I believe that they made themselves apparantly clear huh?

First, delimited data obviously has structure. The goal of delimited data files is to provide the minimum structure overhead necessary. Usually that is a single character column delimiter and a single character row delimiter. And it’s usually pretty readable and searchable. Plus it is trivially imported into all data manipulation software like databases and spreadsheets.

One of the questions is about embeded schema information as opposed to external schema information. For example, a database has very little embeded schema. When you fetch rows you get about the same information as delimited data gives you.

Data with embedded schema like XML excels in systems where the sender and recievers of the data do not want to maintain and syncronize common external schema.

Well i know one thing, XML isnt XHTML. Im still uncertain, in exact, why should i use XML to make a cms system. In the sample chapters of the book, the building starts off with defining what an article consists of. Id, Title, Poster etc. Now why cant you do this with MySQL table? No need for XML pages.

Then, when the book starts to transfrom the XML page with XSLT to an XHTML page, i get confused again…why use XSLT to transform the page if you cant use CSS over it. He uses html attributes like bgcolor in tags that arent up to the current css designing, where all design is defined in a css file.

It seems that there is another meta-language for the XML css replacement, XLS-FO, that is similar to css…why? why should i use this, instead of just CSS?

Atm, i cant see why i should use XML and the other technologies to build websites…

They both “do” absolutely nothing.

http://www.w3.org/TR/xhtml1/#xhtml
http://www.w3.org/TR/2000/REC-xml-20001006
http://www.w3.org/MarkUp/SGML and ISO8879

So XHTML is a subset of XML is a subset of SGML

So you already said it yourself, XML doesn’t solve the human readability and computer readability.

With a DTD/XSD you can test if the XML is valid data.

But the process of making information of that data is not specified. So, XML (even with a DTD/XSD) is not human readable if you don’t know how the data should be interpreted.

thanks for the theory lesson
:yawn:

however I dont think I said that at all. data with no context will always be meaningless so I dont see your point.

I think the advantage of XML is that virtually every environment has tools to generate/parse XML…

So instead of defining some (binary) format and writing the code to generate/parse it, you can use the allready available XML tools and spend your time on other parts of the code.

I don’t think anyone mentioned this, but XML also succeded because of RMI (XMLRPC and SOAP). It is flexible enough to define any data structure in a text file that can be transmited over HTTP, avoiding firewalls. This is the main disadvantage of CORBA (which is still in use, especially on the Java platform), and that is why SOAP was looked at as the next best thing (although it appears it has almoust all the disadvantages). Also, it is said XML is human-readable as opposed to CORBA’s IDL.

You definitely twisted some concepts together to make a point. There is a difference between readable and interpretable, but you are mixing them together. There is also a difference between solve and improve, and you mix those as well.

jplush76 was rightly noting that a format with schema information embeded with the data is more “readable” than one that is just data. Interpretation has not been discussed.

Ok, i mixed readable and interpretable.

I agree there is a difference, but i did not mix them. jplush76 said: xml solves human readability and computer readability by tagging data. And i said: XML doesn’t solve the human readability and computer readability.

I can agree with that.

I think as a developer there are better ways to approach exchanging data. In my case I have more developers say things like… “I’m working in PHP can you deliver content in a different method that uses PHP(s) strenghs instead of sending slow processing XML!”

I am sort of starting to understand this. Sure XML is a standard but how much does it help the end developer that wishes to deliver the fastest service to his/her’s clients! If your the centralized delivery agent then you should gather the feeds that you subscribe to and then make those feeds available to your clients in a different structured document that is better suited for their development language!

printf

Here’s what I think is a great implementation of XML.

The Problem:

You have an Indian Language in a SQL database online. Not only do you need this online database search able, but you need to create a downloadable cdrom that is also able to search the database.

The Solution:

I dump specific text to xml files, and use Flash to search the xml files on the cdrom. It’s actuall brilliant and requires nothing more than the flash file, and a directory containing the xml files.

Perfecto… hehe

XML has one big advantage. It is Unicode compatible. At least most of it :slight_smile: