Data Binding and XML in ASP.NET

The World Wide Web and its rapid growth in the 1990s revolutionized the methods of accessing information and conducting commerce. Numerous companies use the Web as a powerful tool to advertise and sell their products. This has led to an increase in the number of Web applications and their requirements in terms of payment handling, data access, and security. As a result, various new technologies have evolved.

One of the most important requirements of Web applications, especially B2B ecommerce applications, is the ability to interchange data in a standard format that can be understood by any hardware and software platform. Enterprises having similar business interests may need to share data, which may be stored on disparate platforms. This need for a common interface for exchanging data resulted in the evolution of Extensible Markup Language (XML), which is the latest and the most hyped Web technology.

XML is the World Wide Web Consortium's (W3C) specification for interchanging structured data in Web applications. An XML document enables you to store data in the same way a database enables you to store data. However, unlike databases, an XML document stores data in the form of plain text, which can be understood by any type of device, whether it is a mainframe computer, a palmtop, or a cell phone. Thus, XML serves as a standard interface required for interchanging data between various Web applications.

W3C is a consortium that ensures the growth of the Web by developing common protocols for the Web. It also ensures that various Web technologies are interoperable. W3C has more than 500 organizations as its members.

XML is a markup language that enables you to enclose data within tags.

So how is it different from HTML?

The difference lies in the fact that HTML has a set of predefined elements that concentrate on the appearance of the contents within the document. For example, when you enclose the data within the and tags, the browser interprets these tags and displays the content enclosed within the tags in italics. The browser is not concerned about the contents within the tags.

Conversely, XML concentrates on the content in the document and is not concerned with how the contents should appear. For example, if you are creating a document that stores the data about the products offered by your company, you can create a tag called and enclose the description of a product within this tag.

Thus, tags in XML serve the purpose of structuring the content within the XML document. No presentation or appearance is associated with any of the XML tags. XML does not provide any predefined set of tags. Rather, it enables you to create your own tags. In that sense, XML can be called a meta-markup language, which enables you to create your own markup or vocabulary. In fact, many existing markup languages have been derived from XML.

Some examples of markup languages that are based on XML are Wireless Markup Language (WML), which is used to create Web applications that can be accessed using a cell phone, and MathML, which is used to represent mathematical equations.

XML does not exist all by itself. Numerous additional XML-related specifications provide guidelines for working with XML documents. Before discussing the implementation of XML in ASP.NET, it is important to understand these XML-related specifications. Therefore, this section looks at some of the important XML-related W3C specifications.

Document Type Definition

A Document Type Definition (DTD) enables you to specify the structure of the content in an XML document. Creating a DTD is similar to using a CREATE TABLE statement in SQL, in which you specify the columns to be included in the table and whether they can hold null values. In a DTD, you can specify the elements that can be used in an XML document and specify whether it is mandatory to provide values for the elements.

When you include a DTD in an XML document, software checks the structure of the XML document against the DTD. This process of checking the structure of the XML document is called validating. The software that performs the task of validating is called a parser.

The following are the two types of parsers:

Nonvalidating parser: Checks whether an XML document is well formed. An example of a nonvalidating parser is the expat parser.

Validating parser: Checks whether an XML document is well formed and whether it conforms to the DTD that it uses. The MSXML parser provided with Microsoft Internet Explorer 5.0 is an example of a validating parser.

An XML document that conforms to the DTD is called a valid document.

XML namespaces

XML enables you to create your own elements. It also enables you to use elements that are defined for and used by various software modules. This may lead to certain problems. For example, in case of a purchase order, you may have an element called QTY that stores the quantity of a purchase.

In some other case, the same element may be used to store the quantity on hand for a particular item. In such a case, there may be a collision of elements having the same names. To prevent this from happening, W3C has recommended the use of XML namespaces.

XML namespaces use Uniform Resource Identifiers (URIs) to differentiate tags used in different vocabularies. With this approach, each element can be uniquely identified using the namespace. A namespace can be declared using the xmlns keyword. For example,

a namespace for a purchase order could be defined in the following way:

xmlns:PurchaseOrder="http://www.po.com/po"

XML schemas

An XML schema provides a way of defining a structure of an XML document. It enables you to describe the elements and attributes that can be present in an XML document. An XML schema is similar to a DTD. However, it can be considered a superset of a DTD in terms of the functionality that it provides. An advantage of using an XML schema is that it enables you to specify the data types for elements.

A DTD, on the other hand, enables you to specify whether the element can contain character data or other elements, or whether it is an empty element. It does not enable you to specify whether a particular element should contain integer, float, or string values. Another difference between an XML schema and a DTD is that an XML schema follows XML syntax. In other words, it is an application of XML, whereas a DTD has its own syntax.

RELATED POST

CREATING ASSEMBLIES WITH ASP.NET

BUILDING HANDLERS IN ASP.NET

INTERFACES AND CLASSES CREATION IN ASP.NET

CACHING IN ASP.NET

CACHING IN ASP.NET PART TWO

WIRE LESS APPLICATION WITH ASP.NET

SECURITY IN ASP.NET PART ONE

SECURITY IN ASP.NET PART TWO

LOCALIZING ASP.NET APPLICATIONS

DEPLOYING ASP.NET APPLICATIONS

ASP.NET CONFIGURATION SYSTEM

WEB SERVICES IN ASP.NET

WEB SERVICES PART TWO

WEB SERVICE INFRASTRUCTURE

WEB SERVICE INFRASTRUCTURE PART TWO

EXCHANGING MESSAGES IN ASP.NET

MICROSOFT HAIL STORM

SOAP AND DOT NET PART ONE

SOAP AND DOT NET PART TWO


No comments:

Post a Comment