7
Document Type Definition
We need to revise our basics
once more. This chapter, Don't Tell Dumbos, was put together after much
thought. It contains all the things that most other books would not tell you.
The Document Type Definition or DTD is the base of all WML code. If you do not
understand this, there is little that you can do in WML. Sure, you would be
able to get programs running, but then, so can you get a car that stopped to
move by pushing it. But if you really want to fix a broken car, you need to
take a look under the hood and find out what is wrong with the engine. And in
this case, the engine that drives everything around is XML, which is used to
write the DTD.
So let's start with the
basics again. We start with <?xml then version... hey, don't say we've done
this before. We know we have. We said we were repeating it to make sure that
you understood all that we have done. When writing an WML document, any WML
document, the first line has to be <?xml version="1.0"?>
a11.wml
<?xml version="1.0"?>
Screen 7. 1 |
Right? This states that we
are writing an XML document. We then also said there was a DOCTYPE. That was the second line. But you will
realise that the DOCTYPE we are using here is different from the other DOCTYPE.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml []>
Screen 7. 2 |
DOCTYPE in a wml file had the
words like wml, then PUBLIC followed by the file and location that contained
the WML rules. Here we are going to
write our own rules. These rules are written within the open and close square
bracket. Since we have wml before the
brackets, the rules within the brackets
apply to wml files only.
Let's get cracking. We
write the word wml, and run the routine. We get an error. If you don't figure
this error out, you need to do some real basic revision.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml []>
<wml>
Screen 7. 3 |
You always need to open and
close tags. These are always used in pairs. So if there is one, you have to have
another to match the first one. Add the pending content i.e. an end tag and
then compile it.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml []>
<wml>
</wml>
Screen 7. 4 |
One more error. It states
that there are no elements declared within it. We need to define an element. To
do so, add a new line with <!ELEMENT … Elements start and end with
angle brackets. wml now becomes the root tag. In the wml document, every
statment must be enclosed with the wml tags. This is not enough. If we stop
here, we will see another error.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml >
]>
<wml>
</wml>
To remove the error, write
EMPTY.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml EMPTY>
]>
<wml>
</wml>
We now have an element
called wml which is empty. It does not contain
any tags or statments. When you compile it, you will see no errors.
While working through all
these programs we learnt that a wml
deck contains a card. To add a card to
the wml file, we modify the wml element.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
]>
<wml>
</wml>
The open and close brackets
are a must. If you don't put the open and close the brackets, you get errors.
Also, you must have a space
before the brackets. On compiling, you
will see one more error - required child element missing.
Screen 7. 5 |
Card becomes a child element of wml and requires a definition
Screen 7. 6 |
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card EMPTY>
]>
<wml>
<card>
</card>
</wml>
wml contains card and the
card is currently EMPTY. Now we write
hi within the card tag
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card EMPTY>
]>
<wml>
<card>
Hi
</card>
</wml>
This gives us an error - no text permitted within this element. To have card accept text, we replace EMPTY with #PCDATA within ( ).
Screen 7. 7 |
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (#PCDATA)>
]>
<wml>
<card>
Hi
</card>
</wml>
PCDATA stands for Parseable
Character Data. It is the good, old text that we write. What we are now saying
is that an element called wml can only have a card in it. And the card can have
any sort of text within it.
See, when we use
<card> </card>, we get no errors at all. We can also enter hi and
blank lines, we still will not get any errors.
That was easy. Wasn't it?
Think you can write in two <card> statements? Follow the next program
through.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (#PCDATA)>
]>
<wml>
<card>
Hi
</card>
<card>
Bye
</card>
</wml>
Screen 7. 8 |
We get an error because we have
only defined an open and close bracket for the card element. This open and
close with nothing else means only one card allowed. You can't have two. You
can't have zero. That's what the next example will show you. You have to have
one and only one card.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (#PCDATA)>
]>
<wml>
</wml>
Screen 7. 9 |
When we checked the actual DTD
for <card> in the xml file, it
had a plus. The plus means one or many. You can have one card, or 7 cards. It
won't make a difference. Add the plus and try the next example where we have
three cards.
Screen 7. 10 |
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)+>
<!ELEMENT card (#PCDATA)>
]>
<wml>
<card>
Hi
</card>
<card>
Bye
</card>
<card>
NO
</card>
</wml>
The next example says that
because you have a + in the card, you must at least have one card. After all,
if you do define something, it is because you intend to use it. If you did not,
why define it in the first place?
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)+>
<!ELEMENT card (#PCDATA)>
]>
<wml>
</wml>
Screen 7. 11 |
As there is no card in use in
the above example, we get an error.The next one shows an asterisk star sign
after the card.. Not the type that appear in the sky, but an asterisk. You'd
see some though if you keeping fooling around with the boss' daughter and not
do your job seriously. The asterisk has been used so often in programming
lingo, that it's meaning is not likely to change. If you guessed it, try the
next program and see if you are right.
Screen 7. 12 |
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)*>
<!ELEMENT card (#PCDATA)>
]>
<wml>
</wml>
* means zero or infinity.
You are allowed to put in as much or as little as you want when an asterisk is used
in the definition. If you are an old DOS hand, then you will not only
understand how the * works, but also how the ? works as well. The ? is used to
state a single occurrence or again, nothing at all. Without a card, wml files
are meaningless, hence the screen flashes an error - Unknown file content
You now understand how one can define a few elements to be compulsory, or optional, or then again, restrict the use to a single occurrence. These modifiers will come handy in a while, so you better remember their use.
Screen 7. 13 |
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)?>
<!ELEMENT card (#PCDATA)>
]>
<wml>
</wml>
Screen 7. 14 |
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)?>
<!ELEMENT card (#PCDATA)>
]>
<wml>
<card>
</card>
</wml>
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)?>
<!ELEMENT card (#PCDATA)>
]>
<wml>
<card></card>
<card></card>
</wml>
Screen 7. 15 |
The last example would have given you an error, as you can
have at best a single card defined. Experiment with a few other variations to
make sure that you understand just exactly what the +, * and ? do.
It's been quite a while
since we took a break, so it is time to look at <p> again. We've added <p> to the card and are
attempting to run the following program. What do you think is the result?
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (#PCDATA)>
]>
<wml>
<card>
Hi
<p> </p>
</card>
</wml>
Screen 7. 16 |
You expected the error,
right? But the error is not because we’ve given Hi outside the <p> tag, but
because we have used <p> tags that have not been defined. Remember, we
could use any text between the <card> </card> tag as this has been
defined as PCDATA. And hence, any sort of text is acceptable. Errors appear
when there are non-text elements within the <card> tag.
Well, our definition is
going to get a little longer. We are going to make it clear that there is
something called <p> within card. And then, this something <p> can
have something called PCDATA. You know what PCDATA is, so we go on.
Screen 7. 17 |
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (p)>
<!ELEMENT p (#PCDATA)>
]>
<wml>
<card>
<p>
Hi
</p>
</card>
</wml>
You get no error. Do you?
Seems like we have solved this problem. The <p> tags are now acceptable
and you can place as much of PCDATA
between the open and close tags. However, in doing this, we have removed the ability
of entering any other text into the <card> tags.
Try placing any text within
card and you will get an error.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (p)>
<!ELEMENT p (#PCDATA)>
]>
<wml>
<card>
Hi
<p>
Hi
</p>
</card>
</wml>
Screen 7. 18 |
The rules always remain the
same. If you do not put a <p> in the <card>, then you will get an
error, as it is defined and must be used. But it is more likely that you will
want to use more than a single <p> tag in the <card> and to do
this, you must clarify your definition. In its current form, the definition
specifies that there must be one and only one <p> tag in <card>.
Avoid it and you get an error. Put in two or more, and you will again get an
error.
What you need to make use
of are the modifiers that we used in the last set of examples. To allow one, or
multiple, use the right sign.
Screen 7. 19 |
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (p)*>
<!ELEMENT p (#PCDATA)>
]>
<wml>
<card>
<p>
Hi
</p>
<p>
Bye
</p>
</card>
</wml>
Just text is not good
enough. We need to be able to do a lot more than just entering in text. What
about the <br> tag? And would it be possible to add in other tags as
well? Let's take a shot at doing this now.
Screen 7. 20 |
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (p)*>
<!ELEMENT p ( br | b )>
<!ELEMENT br EMPTY>
<!ELEMENT b EMPTY>
]>
<wml>
<card>
<p>
<br/>
</p>
</card>
</wml>
Here we say <p> will
contain either a br or b. b stands for bold and br means new line and or means
it can have either one of them. We have further defined that br and b are empty.
Flip a few chapters behind, and you will have examples that will show you the
use of these tags <b/> or <br/> have nothing between the open tag
and the close tag. This means that the tag is empty or can contain nothing. And
hence, it is defined as such. The tags can't contain any text. You give it any
content and you will be gifted with an error.
In our example, you can
have a <b> or you can have a <br>, but not both. You will get an
error because one of them has to be present. If you put a *, the card can have
as many <p> and every <p> can have as many <b> or <br>
in any combination or in any order.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (p)*>
<!ELEMENT p ( br | b )*>
<!ELEMENT br EMPTY>
<!ELEMENT b EMPTY>
]>
<wml>
<card>
<p>
<b/>
<br/>
<b/>
</p>
</card>
</wml>
A quick revision. We want
the <p> to contain PCDATA or as many <br> as possible. This example
is like the earlier one. The only change is that we have replaced the <b>
with PCDATA. This is just to show you that you can have text, br or a
combination of them.
Screen 7. 21 |
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (p)*>
<!ELEMENT p (#PCDATA | br)*>
<!ELEMENT br EMPTY>
]>
<wml>
<card>
<p>
hi
<br/>
Byee
</p>
</card>
</wml>
The only difference is that
if you use PCDATA anywhere, it has to be the added first. That is a rule. So
here we don't have a choice but to comply.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (p)*>
<!ELEMENT p ( br | #PCDATA )*>
<!ELEMENT br EMPTY>
]>
<wml>
<card>
<p>
hi
</p>
</card>
</wml>
Screen 7. 22 |
In wml, you can have head,
template, card. Here we put head, card. That means you have to have head or
card. You have to follow the order.
Screen 7. 23 |
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml ( head, card)>
<!ELEMENT head (p)>
<!ELEMENT card (#PCDATA)>
<!ELEMENT p EMPTY>
]>
<wml>
<head>
<p/>
</head>
<card>
</card>
</wml>
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml ( head , card)>
<!ELEMENT head (p)>
<!ELEMENT card (#PCDATA)>
<!ELEMENT p EMPTY>
]>
<wml>
<card>
</card>
<head>
<p/>
</head>
</wml>
Screen 7. 24 |
These are three basic
elements that you can use in WML. In the original DTD, these elements were
defined as: head?, template? and card+.
Template and head can be
used only once in the main program, or not used at all, as both of these are
marked with a ?. This sign means one or no occurrence of the element specified.
The + wild card is a different story. However, a + is at least one occurrence
of the element
Screen 7. 25 |
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml ( head? ,template?, card+)>
<!ELEMENT head (p)>
<!ELEMENT card (#PCDATA)>
<!ELEMENT template (p)>
<!ELEMENT p EMPTY>
]>
<wml>
<head>
<p/>
</head>
<template>
<p/>
</template>
<card />
</wml>
Here goes. Head I win,
tails you lose. This routine is only to emphasise what we have explained to you
so far. Add in more than one head or template, and you will get an error.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml ( head? ,template?, card+)>
<!ELEMENT head (p)>
<!ELEMENT card (#PCDATA)>
<!ELEMENT template (p)>
<!ELEMENT p EMPTY>
]>
<wml>
<template>
<p/>
</template>
<card />
</wml>
Add one more template
and you will see an error message box
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml ( head? ,template?, card+)>
<!ELEMENT head (p)>
<!ELEMENT card (#PCDATA)>
<!ELEMENT template (p)>
<!ELEMENT p EMPTY>
]>
<wml>
<template>
<p/>
</template>
<template>
<p/>
</template>
<card />
</wml>
Screen 7. 26 |
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml ( head? ,template?, card+)>
<!ELEMENT head (p)>
<!ELEMENT card (#PCDATA)>
<!ELEMENT template (p)>
<!ELEMENT p EMPTY>
]>
<wml>
<card />
<card />
<card />
</wml>
No errors displayed as head
and template are both optional. Another important rule to remember is that of
belonging. To be able to use a tag in another tag, first it has to be defined
as a part of it. If you noticed, the <p> tag was defined each time for
head and template. Similarly, since head and template are two different
entities, they cannot occur in each other's space. Any such combination will
generate an error.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml ( head? ,template?, card+)>
<!ELEMENT head (p)>
<!ELEMENT card (#PCDATA)>
<!ELEMENT template (p)>
<!ELEMENT p EMPTY>
]>
<wml>
<head>
<p>
</head>
<card />
<template>
<p>
</template>
<card />
<card />
<card />
</wml>
Screen 7. 27 |
But there may be times when
you would like such a combination. The easiest way out is to to put a star at the end of the definition.
This allows one to have as many of anything as one wants. With the * at the end
of the line, all the combinations would be possible. You could have head, card
or template, card, or whatever combination you choose. Try this next example.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml ( head? ,template?, card+ )* >
<!ELEMENT head (p)>
<!ELEMENT card (#PCDATA)>
<!ELEMENT template (p)>
<!ELEMENT p EMPTY>
]>
<wml>
<head>
<p/>
</head>
<card />
<card />
<head>
<p/>
</head>
<card />
<template>
<p/>
</template>
<card />
</wml>
Do you realise that most of
the time we have elements? And that these elements also have attributes? So how
do you give these elements attributes?
Screen 7. 28 |
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (#PCDATA)*>
<!ATTLIST card title CDATA #IMPLIED>
]>
<wml>
<card title="hi">
</card>
</wml>
ATTLIST means attribute
list. You need to specify the name of the element, its title and the attributes
that you wish to assign to it. In this example, we are assigning values to a
card. The title CDATA (this means character data) is IMPLIED, meaning optional.
If you didn't have this ATTLIST, card title="hi" will give you an
error. As of now it doesn't.
You need to remember that
all this is case sensitive. title is not the same as Title.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (#PCDATA)*>
<!ATTLIST card title CDATA #IMPLIED>
]>
<wml>
<card Title="hi">
</card>
</wml>
Screen 7. 29 |
As far as the quotes are
concerned, the enclosing quotes have to match. But one could have single quotes
within double, and vice versa.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (#PCDATA)*>
<!ATTLIST card title CDATA #IMPLIED>
]>
<wml>
<card title="h'i">
</card>
</wml>
Do understand that the
title is not mandatory, as it has been defined as #IMPLIED.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (#PCDATA)*>
<!ATTLIST card title CDATA #IMPLIED>
]>
<wml>
<card>
</card>
</wml>
There is one more option of
#REQUIRED. This attribute makes the item mandatory. In the next case, id looks
like CDATA and is #REQUIRED. Since title is #IMPLIED it is not compulsory to have one
but without an id, an error is reported.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (#PCDATA)*>
<!ATTLIST card title CDATA #IMPLIED id CDATA #REQUIRED>
]>
<wml>
<card title="hi" id="no">
</card>
</wml>
With two attributes
defined, there would be a question of preference. However, the order is not
important, the commas are used for ordering.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (#PCDATA)*>
<!ATTLIST card title CDATA #IMPLIED id CDATA #REQUIRED>
]>
<wml>
<card title="hi">
</card>
</wml>
Screen 7. 30 |
So there is no order so we
don't have a problem, though you will get an error as id is a must.
Let us understand the |
(or) sign. It can be used to separate two possible values that an element can
take. In this example, title can take two values - sad or bad.
Screen 7. 31 |
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (#PCDATA)>
<!ATTLIST card title (sad | bad) "sad">
]>
<wml>
<card title="bad">
Hi
</card>
</wml>
In the above example, the title
can take either sad or bad. If you don’t give any title, it is assumed to be
sad. Try giving a title other than sad or bad and you will surely see an error
message on your screen.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (#PCDATA)>
<!ATTLIST card title (sad | bad) "sad">
]>
<wml>
<card title="good">
Hi
</card>
</wml>
Screen 7. 32 |
If you set a wrong default
value, as in this case where the default is ugly, the micro browser is smart
enough to spot this. You are given an error as - default attribute values do
not match with any of the declared
ones.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (#PCDATA)>
<!ATTLIST card title (sad | bad) "ugly">
]>
<wml>
<card >
Hi
</card>
</wml>
Screen 7. 33 |
Screen 7. 34 |
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (#PCDATA)>
<!ATTLIST card title (true | bad) "bad">
]>
<wml>
<card>
Hi
</card>
</wml>
The minute you specify the
title, you have to initialise it so the default doesn't work.
Here the id is supposed to be implied so we don't get an error.
Screen 7. 35 |
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (#PCDATA)>
<!ATTLIST card id ID #IMPLIED>
]>
<wml>
<card>
Hi
</card>
</wml>
ID has a special
meaning. Any field with an ID can take numbers, letters and the special
four character - minus, colon, dot, underscore. This field therefore has to be unique. You cannot have two
elements with id (note the small id and
the capital ID are two separate entities).
Just to get this straight.
What happens when there are 2 cards? In this case, because of the * in front of
card, we can have multiple cards. Yet, we don't get an error even though there
is an ID defined. If we haven;t specified any id, the program generates a
different one automatically.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)*>
<!ELEMENT card (#PCDATA)>
<!ATTLIST card id ID #IMPLIED>
]>
<wml>
<card>
Hi
</card>
<card>
Hi
</card>
</wml>
But try defining the same id for
both of them, and you will get an error.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)*>
<!ELEMENT card (#PCDATA)>
<!ATTLIST card id ID #IMPLIED>
]>
<wml>
<card id="a1">
Hi
</card>
<card id="a1">
Hi
</card >
</wml>
Screen 7. 36 |
Remember, ids cannot start
with single quotes or numbers. It will generate an error.
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)*>
<!ELEMENT card (#PCDATA)>
<!ATTLIST card id ID #IMPLIED>
]>
<wml>
<card id="a'1">
Hi
</card>
</wml>
Screen 7. 37 |
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)*>
<!ELEMENT card (#PCDATA)>
<!ATTLIST card id ID #IMPLIED>
]>
<wml>
<card id="1a">
Hi
</card>
</wml>
The same error is reported
again.
Screen 7. 38 |
This NMTOKEN means it can
start with a number or character. You can have these special characters.
Screen 7. 39 |
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)*>
<!ELEMENT card (#PCDATA)>
<!ATTLIST card id NMTOKEN #IMPLIED>
]>
<wml>
<card id="1a:-._">
Hi
</card>
</wml>
In NMTOKEN, you can't have
spaces. But in NMTOKENS you can have spaces. The trick lies in the plural, or
it would seem like that. But the truth is, that the extra S at the end of the
token is for Spaces, not just to make the word plural.
Substitutions are always
nice. Basically, this is what you do when you use variables. You substitute a
label for a value that is stored elsewhere. In this last set of examples, we have
a new entity sonal. Actually, it is not new. It has been around for ages. But
then, haven't we all? Here, all that sonal is to do, is to hold a spot for
another value - A.
Screen 7. 40 |
a11.wml
<?xml version="1.0"?>
<!DOCTYPE wml [
<!ELEMENT wml (card)>
<!ELEMENT card (#PCDATA)*>
<!ATTLIST card title CDATA #IMPLIED>
<!ENTITY sonal "A">
]>
<wml>
<card title="hi&sonal;">
hi &sonal;
</card>
</wml>
This is a trick that you
can enter characters that are not
usually possible using the standard keyboard. They are part of the character
set but are not directly typable characters. Wherever there is a sonal, it is replaced
with a A (as 65 is the ASCII value for A). It could be used anywhere.
This entity is nothing but a short form. C programmers call it a macro; and you can call it whatever you like. Just be sure that you name it before someone else does, and chances are that you could go down in history as one of the people who defined the most popular computer language in the 21th century. Enough of this. You can download the xml file from the wapforum site http://www.wapforum.org/DTD/wml_1.1.xml. You surely will understand a lot more now.