First approach to xml

Marco Garutti

Usenet Archive
Joined
Aug 21, 2003
Messages
2
Reaction score
0
Hallo All,
I'm approaching xml for the first time.
My first example is this source code:
<?xml version="1.0"?>

<!DOCTYPE EMAIL [
<!ELEMENT EMAIL (TO, FROM, CC, SUBJECT, BODY)>
<!ELEMENT TO (#PCDATA)>
<!ELEMENT FROM (#PCDATA)>
<!ELEMENT SUBJECT (#PCDATA)>
<!ELEMENT BODY (#PCDATA)>
]>

<EMAIL>
<TO></TO>
<FROM></FROM>
<SUBJECT>My first DTD</SUBJECT>
<BODY>Hello, World</BODY>
</EMAIL>

but executing this code the result is bad:
<?xml version="1.0" ?>
<!DOCTYPE EMAIL (View Source for full doctype...)>
- <EMAIL>
<TO></TO>
<FROM></FROM>
<SUBJECT>My first DTD</SUBJECT>
<BODY>Hello, World</BODY>
</EMAIL>

What do you think I need or I havn't understood ?
Thanks in advice.

Marco.
 

Derek Fountain

Usenet Archive
Joined
Jul 17, 2001
Messages
90
Reaction score
0
Marco said:
Hallo All,
I'm approaching xml for the first time.
My first example is this source code:
<?xml version="1.0"?>

<!DOCTYPE EMAIL [
<!ELEMENT EMAIL (TO, FROM, CC, SUBJECT, BODY)>
<!ELEMENT TO (#PCDATA)>
<!ELEMENT FROM (#PCDATA)>
<!ELEMENT SUBJECT (#PCDATA)>
<!ELEMENT BODY (#PCDATA)>
]>

<EMAIL>
<TO></TO>
<FROM></FROM>
<SUBJECT>My first DTD</SUBJECT>
<BODY>Hello, World</BODY>
</EMAIL>

but executing this code the result is bad:
<?xml version="1.0" ?>
<!DOCTYPE EMAIL (View Source for full doctype...)>
- <EMAIL>
<TO></TO>
<FROM></FROM>
<SUBJECT>My first DTD</SUBJECT>
<BODY>Hello, World</BODY>
</EMAIL>

What do you think I need or I havn't understood ?
Thanks in advice.

Being a bit of a beginner myself, I'm not sure what you mean by "executing this code". Perhaps you could explain what you mean by that phrase?

Anyway, I can see a (possibly the) problem: your DOCTYPE says an EMAIL must have a TO, followed by a FROM, followed by a CC, followed by a SUBJECT, followed by a BODY. Your data's EMAIL doesn't have a CC, so it's rejected as invalid. Presumably you meant to make the CC optional?
 

Marco Garutti

Usenet Archive
Joined
Aug 21, 2003
Messages
2
Reaction score
0
Hi Derek,
I've tried to add CC but I haven't find differences.
When I say <execute the source code> I mean that it's no clear in my mind who process the XML code. When you double click on a XML page what happens ?
1) Internet explorer process the page with an interpreter inside ?
2) Is it necessary that the page is on a server with particular configurations for XML (enabling somethng on Apache, for example) or you can put the page on the desktop of your Win2000 and just double click on it ?
3) What else to understand architecture

Thanks in advice, Marco.
 

Derek Fountain

Usenet Archive
Joined
Jul 17, 2001
Messages
90
Reaction score
0
I've tried to add CC but I haven't find differences.

I changed the DTD line to read this:

<!ELEMENT EMAIL (TO, FROM, CC?, SUBJECT, BODY)>

and it parses correctly on my machine. You need to add a definition of CC if you actually want to use one:

<?xml version="1.0"?>

<!DOCTYPE EMAIL [
<!ELEMENT EMAIL (TO, FROM, CC?, SUBJECT, BODY)>
<!ELEMENT TO (#PCDATA)>
<!ELEMENT FROM (#PCDATA)>
<!ELEMENT CC (#PCDATA)>
<!ELEMENT SUBJECT (#PCDATA)>
<!ELEMENT BODY (#PCDATA)>
]>

<EMAIL>
<TO></TO>
<FROM></FROM>
<CC></CC>
<SUBJECT>My first DTD</SUBJECT>
<BODY>Hello, World</BODY>
When I say <execute the source code> I mean that it's no clear in my mind who process the XML code. When you double click on a XML page what happens ?

I don't know. It depends how you've got your machine set up. I use Linux for the most part, so I'm probably not the person to ask. Maybe IE will open and try to display it? Maybe an editor will open so you can edit it?
1) Internet explorer process the page with an interpreter inside ?

IE will do its best to show you the XML is a very general way. It doesn't, as far as I know, "process" it other than parsing it in order to display it.
2) Is it necessary that the page is on a server with particular configurations for XML (enabling somethng on Apache, for example) or you can put the page on the desktop of your Win2000 and just double click on it ?

No, no server software is needed. Leaving the file somewhere on your disk and pointing an XML processor of some sort at it is enough.
3) What else to understand architecture

XML is a language for describing data. The data, by itself, isn't much use. The best you can do is check that the data is valid; i.e. that the data matches the DTD description of what the data should look like.

Something needs to process that data, either to display it, or in some way work with it in order to get something done.

Your XML describes an email. OK, fine. But what do you want to do with that information? Display it in some way? Use it to send the described email? There isn't much point in just having a bit of XML data sitting on your disk. What do you intend to do with it, and how do you intend to do that?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,798
Members
249,594
Latest member
henrywalsh

Latest Threads

Top