XMLWhat Is It and Why Should I Use It?


XML”What Is It and Why Should I Use It?

XML is a set of language rules that have been defined to describe and structure data. It was originally developed by the World Wide Web Consortium (W3C) as part of an effort that started in 1996 and produced the first XML specification (version 1.0) in 1998. Their goal at the time was to expand web functionality by providing a flexible architecture for exchanging data. The architecture supports more than the typical web client-server relationship between a browser and a web server. That is, XML isn't just for web pages.

XML can store any type of structured information. One benefit of storing standard data (that is, not web related ) is that XML can be used to facilitate data communications between two computer platforms that would otherwise be incompatible as well as store configuration or application data for easy access by the applications. A number of features are what make XML so successful”let's take a quick look at them.

XML Is Extensible

XML is called extensible because it isn't based on a rigid set of rules like HyperText Markup Language (HTML). HTML and XML are both subsets of Standard Generalized Markup Language (SGML) and have their similarities and differences. HTML defines a standard set of tags, and because each tag has a predefined meaning, the language is not extensible. Because HTML tags are already defined as a standard, the HTML interpreter (the browser, for example) does not have to interpret any tags that are not a part of the HTML standard. The interpreter is free to choose whether or not it wants to ignore the tags, throw an exception, display it as plain text, and so on. XML, on the other hand, is a meta-language that can be used to structure your data and define other meta-languages. In essence, when you generate an XML document, you are actually defining a new data format or a new meta-language because you define the start tags, end tags, and so forth.You then create an interpreter for your language using an XML Parser, which will understand the user -defined syntax.You can also create a Document Type Definition (DTD) to further validate and restrict your language's syntax.

Note

Even though XML is a meta-language, it still has to follow a set of syntax rules to render a valid XML document. These rules are defined in Appendix A, "What is XML?"


XML Separates Data from the Presentation of the Data

The data contained in an XML document is separated from the presentation of the document. This feature enables you to decide how to display the data contained in an XML document based on the client viewing the XML document (that is, different clients can view the same data in different ways). Technologies such as eXtensible Stylesheet Language Transformation (XSLT), XML Path Language (XPath), Cascading Style Sheets (CSS), and so forth can be used to transform XML documents for varying presentations to the viewer.

XML Documents Are Stored As Text

An XML document is stored as text.You can view and edit an XML document easily using any text editor because its legibility makes development and debugging much easier than in binary or other illegible formats. Because an XML document is a text file, it is not platform specific. By that, I mean an XML document generated on one platform”for example, a PC running Microsoft Windows”can be used ( viewed , read, or processed ) on another platform, such as a Unix workstation. Cross platform portability can sometimes be an issue when applications store their data in a proprietary binary format (such as a word processor document or a spreadsheet). Think of an XML document as a clear glass container that holds data”everyone can see inside of it and nothing is hidden, which is how information or data should be treated.

XML Provides a Solid Foundation for a Family of Technologies

XML itself is the specification that describes the rules designed to store and represent data. It specifies how start and end tags are defined, which characters are allowed for element names , how comments are written, and so on. In addition to XML, a large number of related specifications are designed from the beginning to closely integrate with XML. Here is a short list of some of the more popular specifications.

  • XLink” Defines the syntax for adding hyperlinks to XML documents. In XML, any element can be designated as a link. XLink is more flexible than a standard hyperlink because it can support several types of links. For example, XLink can be used to create a standard HTML link, a bi-directional link that will return the user to the main document, or a multi-directional link that can provide multiple paths to the same document. Currently, most browsers support simple XLink functionality; however, custom applications can tap into the full functionality of XLink.

  • XPointer” Enables you to specify a particular point or range in an XML document. XPointer is similar in concept to a URL. However, rather than pointing off to a document somewhere on a web server, the link points to data inside an XML document.

  • Cascading Style Sheet (CSS)” Enables you to specify how to display an XML document in a browser. CSS is a non-XML syntax that doesn't change the content of the XML data, it only applies display rules to the existing XML data.

  • eXtensible Stylesheet Language (XSLT)” Supports transformation of an XML document into another format, whether it's another XML document, an HTML page, or any data format (such as a small summary report generated from a large XML document). XSLT stylesheets contain rules (or templates) regarding format and content of an XML document. XSLT applies the templates found in an XSLT stylesheet and applies them to an input XML document, generating a new document. The contents of the new document are XSLT stylesheet dependent, and the stylesheet can describe a new XML document, an HTML document, or any number of different output formats.

  • XPath” A language specification used to query XML data to locate and identify parts of XML documents that are specified using XPath expressions.

  • Document Object Model (DOM)” Defines a language independent (such as Perl, C++, or Java) method of storing structured documents in memory. Once stored in memory, an application can walk up and down the branches of the tree containing elements and attributes and easily retrieve or modify elements and attributes.

  • Simple API for XML (SAX)” Defines an interface for event-based XML parsing. The event-based parsing concept is a stream-based, sequential parsing model that enables you to parse XML data without storing the entire document in memory. Because it doesn't store the entire XML document in memory, SAX is usually used to parse large XML documents.

XML Is Not a Transport Protocol

One of the few misconceptions about XML is that it is a transport protocol” it isn't.You cannot use or open an XML-based socket between two processes (for example, a browser client and a web server) to exchange data.You can, however, open up a TCP socket (for example, a browser client and a web server) and exchange a file that contains data stored in XML.

XML Is Not a Programming Language

Another popular misconception about XML is that it is considered a programming language. XML is not a programming language. XML cannot calculate the average of the first column of a table of data; however, an XML document can store the data from the table. Tools have been written using a number of programming languages (such as Perl, C/C++, and Java) that can generate, build, or parse XML documents, but an XML document is not a script or a source code file.

There are several XML-based languages, and XSLT is a good example. XSLT programs are written using XML constructs, which are then interpreted and executed as defined in the specification. XSLT interpreters can be written in languages such as C, C++, Perl, or Java.

XML-based languages are a hot topic in the compiler and interpreter communities right now because many developers are beginning to see the benefits of using XML-based syntax, which easily defines things such as validations using DTDs or schemas, and namespaces.



XML and Perl
XML and Perl
ISBN: 0735712891
EAN: 2147483647
Year: 2002
Pages: 145

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net