Você está na página 1de 4

1

UNIT 4
Advanced Markup languages XML and WML

XML
What is XML?
XML stands for EXtensible Markup Language
XML is a markup language much like HTML
XML was designed to carry and store data, not to display data
XML tags are not predefined. You must define your own tags
XML is designed to be self-descriptive
XML and HTML were designed with different goals:
XML was designed to transport and store data, with focus on what data is
HTML was designed to display data, with focus on how data looks
HTML is about displaying information, while XML is about carrying information.
XML does not DO anything. XML was created to structure, store, and transport information.
The following example is a note to Tove, from Jani, stored as XML:
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
The note above is quite self-descriptive. It has sender and receiver information, it also has a heading and a
message body.
But still, this XML document does not do anything. It is just information wrapped in tags. Someone must
write a piece of software to send, receive or display it.

XML Separates Data from HTML
If you need to display dynamic data in your HTML document, it will take a lot of work to edit the HTML
each time the data changes.
With XML, data can be stored in separate XML files. This way you can concentrate on using HTML/CSS
for display and layout, and be sure that changes in the underlying data will not require any changes to the
HTML.
With a few lines of JavaScript code, you can read an external XML file and update the data content of
your web page.

XML Simplifies Data Sharing
In the real world, computer systems and databases contain data in incompatible formats.
XML data is stored in plain text format. This provides a software- and hardware-independent way of
storing data.
This makes it much easier to create data that can be shared by different applications.

XML supports Unicode
XML is a textual data format with strong support via Unicode for the languages of the world.


2

XML documents must be well-formed, meaning they should follow the syntax rules of the XML
specification. It is also possible (but not a requirement) for XML documents to be valid. A valid XML
document conforms to a Document Type Definition (DTD) or an XML Schema. A DTD or an XML
Schema dictates what elements and attributes may be part of a given XML document.

A schema is a formal way of defining and validating the content of an XML document. (A well-formed
XML document that conforms to its schema is said to be valid.)

The schema is how we assign the data types to each tag and any attributes that are contained in the XML
document. A schema is a structured document which must obey XML syntax rules. It is composed of a
series of predefined tags and attributes that are part of the XML language and are used to set the data
types for the values associated with our custom tags. Simply put, not only do we get to create custom
XML tags, but we can also denote that an XML data value is, for example, an integer data type. This
ability to assign specific data types to specific XML data values is one of the reasons why XML has
attracted so much attention.

A schema can be part of the XML document or a separate file.

XML with correct syntax is "Well Formed" XML.
XML validated against a DTD or an XML Schema is "Valid" XML.

A "Well Formed" XML document has correct XML syntax.
The syntax rules for XML documents are:
XML documents must have a root element
XML elements must have a closing tag
XML tags are case sensitive
XML elements must be properly nested
XML attribute values must be quoted


Wireless Markup Language (WML), based on XML, is a markup language intended for devices that
implement the Wireless Application Protocol (WAP) specification, such as mobile phones. It provides
navigational support, data input, hyperlinks, text and image presentation, and forms, much
like HTML (HyperText Markup Language)

WML (Wireless Markup Language) is the first markup language standard for wireless devices. It is
supported by all the major mobile phone manufacturers
Optimized for small screens and limited size memory.
HTML type formatting language,defined as XML document type.
Uses card and deck metaphor while creating documents.
Has a built in hierarchy that allows individual document to work both in a mobile phone and
a handheld computer.
Current version is 1.1
The role of WML in mobile Internet applications is the same as that of HTML in web applications. WAP
sites are written in WML, while web sites are written in HTML.
A major difference between HTML and WML is that the basic unit of navigation in HTML is a page,
while that in WML is a card. A WML file can contain multiple cards and they form a deck. When a user
3

goes to a WAP site, the mobile browser loads a WML file that contains a deck of cards from the server.
Only one card will be shown on the screen of the wireless device each time. If the user goes to another
card of the same deck, the mobile browser does not have to send any requests to the server since the file
that contains the deck is already stored in the wireless device.
WML is designed in this way because wireless devices have a high latency for connecting to the server.
Downloading a deck of cards at a time can lower the number of round trips to the server.
You can put links, text, images, input fields, option boxes and many other elements in a card.

Let's take a look at our first WML example. It shows the structure of a typical WML document.
helloWorld.wml
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">

<wml>
<card id="card1" title="WML Tutorial">
<p>Hello World</p>
</card>

<card id="card2" title="WML Tutorial">
<p>Welcome to the world of WML</p>
</card>
</wml>
The result of the "Hello World" WML example in mobile phone emulators is shown below:


Statement by statement explanation of the above helloWorld.wml program:
Prolog refers to the first two lines of our "Hello World" WML example:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
Every WML document starts with the prolog. The first line is the XML declaration and the second line is
the DOCTYPE declaration.
All WML documents must have the DOCTYPE declaration. It should be placed between the XML
declaration and the <wml> element.
4

The DOCTYPE declaration specifies the name of the DTD (Document Type Definition) and the URL to
the DTD. The DTD contains information about the syntax of the markup language. It defines what
elements and attributes can be used in the markup and the rules that they should be used.
<wml> Element
<wml> is the root element of WML. All other elements should be enclosed within the <wml></wml>
tags.
<card> Element
The <card> element specifies the content of a card. There are two cards in our Hello World WML
example. As you can see in the earlier screenshots, only one card is displayed at a time.
In our Hello World WML example, two attributes, id and title, have been specified to the <card> tag. We
use the id attribute to define a unique ID for a card. Card IDs are needed for navigation between cards.
The title attribute is used to set the title of a card. Typically, a title is displayed at the top of a wireless
device's screen. Most WAP browsers display the title of a card, although a few very old ones do not. If the
title is too long, WAP browsers will truncate the title to match the size of the title bar.

Features of WML :
Comments are placed inside <!-- --> in WML. This is the same as HTML. For example, the following
lines are comments. WAP browsers ignore all comments.
<!-- This is a comment in WML -->
<!-- This is a multi-line
comment -->
<br/> is the line breaking tag in WML, which is the same as that in HTML.
The <b>, <i> and <u> tags mean bold, italic and underline respectively.
The <small> and <big> tags are used to reduce and increase the text size respectively.
The <pre> tag is used to specify preformatted text in WML. Preformatted text is text of which the format
follows the way it is typed in the WML document.
The <img> tag is used to add an image to a WML card. This is the same as in HTML. WAP browsers will
display the text assigned to the alt attribute of the <img> tag if it cannot display the image for reasons
such as file not found or image format not supported. The URL of the image file is specified with
the src attribute.
The height and width attributes of the <img> tag, as their names suggested, are used to specify the height
and width of an image's display area.
To create tables and place some data in them, you need the <table>, <tr> and <td> WML tags. A table
(<table>) has a number of rows (<tr>) and each row has a number of cells (<td>). Data is placed in table
cells.
A major difference between WML and HTML is that WML has built-in support of variables. You can
assign a value to a variable or output the value of a variable in WML without involving any scripting
languages. To use variables in HTML, a client-side scripting language (e.g. JavaScript and VBScript) is
required.
In WML, variables do not have to be declared explicitly. You can choose a variable name you like and
assign a value to it directly. If you read a variable without assigning a value to it earlier, you will obtain
an empty string.
Variable names in WML are case-sensitive. The first character of a variable name must be a letter or an
underscore. The rest of the characters can be letters, numbers or underscores. Other characters, such as
punctuations, are not permitted.
All variables are stored as string. They have a global scope, which means once you have set the value of a
variable, you can read it in any cards and decks.

Você também pode gostar