Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Lectures_SSD2_Yermakova / Lectures_SSD2 Yermakova.doc
Скачиваний:
226
Добавлен:
25.02.2016
Размер:
3.16 Mб
Скачать

5.1.1 Mime Types

It is possible to attach images and other types of documents to an email message. This raises a problem: how is the mail client (that is, an application that reads email) supposed to know what to do with these documents? The solution is to give each attachment a label explaining what kind of document it is. The labels are calledMIME types. Incidentally, MIME is the acronym for Multipurpose Internet Mail Extension.

MIME type designations have two components: a type and a subtype, which are separated by a slash (/). Some examples include text/plaintext/htmlimage/gif,image/jpeg, and application/msword. Users can control how their mail clients handle attachments of a given type through a configuration file called a MIME types file. For example, they may specify that GIF and JPEG images should be displayed using a particular viewer program, or that files associated with the application/msword type should be opened immediately using Microsoft Word. The MIME types file permits wildcard specifications, such as image/*, which matches any type of image file, or even */*, which a mail client can use to provide a default behavior for any file type. A common choice of default behavior for unfamiliar types is "save to disk." This allows the user to deal with the attachment manually at a later time.

MIME types are not just for email anymore. Web browsers use them as well. Web sites that contain sound or video clips, for example, may require the mail client to launch a player program in order to present those files to the user. The MIME types file tells the Web browser what kind of player to use. You can display and edit MIME types' settings using your Web browser by editing your preferences.

Microsoft Windows operating system also now uses this information. If you double-click a file icon, the file extension is looked up in the MIME types file to determine which application should be used to open the file. If you are using Windows Explorer to view your disk files, on the View menu, click Folder Options and then click the File Types tab. This window shows a list of all file extensions registered under Windows and displays the appropriate MIME type associated with each extension.

MIME extensions also specify the character encoding in email messages. Languages such as French or Spanish require accent characters that are not part of the regular character set, which is known as ASCII (American Standard Code for Information Interchange). Email messages in nonwestern languages, such as Japanese, require a different character set altogether. The MIME extensions provide a way to specify which encoding a message is using. It is then up to the mail client to translate that encoding into something that can be meaningfully displayed to the user.

5.1.2 Internet Languages

  • HTML

  • XML

  • JavaScript

  • Java

There are many Internet languages that are used to exchange data on the World Wide Web. In this section, we will focus our discussion on the ones that are commonly used today.

HTML

HTML stands for Hyper Text Markup Language. An HTML file is a text file containing a set of predefined tags that are used to specify how data should be displayed in a browser or another application program. For example, inserting the built-in tag "<i>" and "</i>" around a phrase would italicized the phrase displayed. Because HTML is composed of text, you can create an HTML file using a text editor. To enable the Web browser to interpret how you want the page to be displayed, you must save the file with an "htm" or "html" file extension. Note that "<" and ">" are indicates the beginning and end of a tag, respectively.

You can use the following steps to create a web page:

1. Open a text editor application such as Notepad.exe.

2. Copy the following text and paste it into the text editor program:

<html> <head> <title>Page title</title> </head> <body> This is an example of a Web page. <b>A tag is used to make this text appear bold.</b> </body> </html>

3. Save the file on Desktop as "sample.html".

4. Open a Web browser application.

5. Drag "sample.html" from Desktop to the Web browser. You should be able to see the web page.

HTML tags, which are used for marking up documents, are predefined. Therefore, the author of HTML documents can only use tags that are defined in the HTML standard to customize the look and feel of a web page. There are numerous resources on the Internet that you can use to learn how to create web pages with HTML. One way you can locate HTML resource pages is using an Internet search engine such as Google, and type in "HTML tutorial" in the search box.

XML

Another text document markup language is XML (eXtensible Markup Language). While HTML tags are primarily concerned with how text should bedisplayed, XML tags can be used to describe what a piece of text means. Another major difference between HTML and XML is that there are no predefined tags in XML. Users have the freedom to define their own tags.

For example, an XML programmer could create a tag called <phone> to indicate that the enclosed text is a telephone number. See the following example XML code:

<phone>4125551212</phone>

The programmer can also include other tags such as <address>, <name>, <occupation>, etc. To describe how tags are used to organize the data, a DTD (document type definition) is utilized. For example, in a DTD, the developer can specify that CUSTOMER tags can contain NAME tags, but NAME tags cannot contain CUSTOMER tags. A DTD ensures that all the documentation is formatted in the same way. Applications can use the DTD to read and display the content of the document. One advantage of using the DTD is that changing the document format would involve just modifying the DTD.

Since XML just organizes data by assigning them descriptive tags, Extensible Stylesheet Language (XSL) is used to specify how an XML document would be interpreted and displayed by the browser.

The phone example above can be rendered by the browser as specified by the XSL as follows:

Phone: (412) 555-1212

You can view an XML phonebook with the phone entry shown above. Some browsers will use the XSL specified in the XML file to transform the data. You can view the source to the XML and the XSL.

XML allows the author to define his own tags and his own document structure. By using tags to encapsulate data, XML can represent complex data structures, such as records from a database. The formatting information associated with the tags is used to generate XSL sheets from an XML document, which can be viewed with a normal Web browser. Because XML is composed of text, it is software and hardware independent, meaning any computer system would be able to interpret an XML document. Due to XML's flexibility and interoperability, it is becoming the standard for exchanging data over the Internet.

You can learn more about XML from the World Wide Web Consortium (W3C) website.