Search for notes by fellow students, in your own course and all over the country.

Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.

My Basket

You have nothing in your shopping cart yet.

Title: xml
Description: extensible mark up language

Document Preview

Extracts from the notes are below, to see the PDF you'll receive please use the links above


XML and DTDs
by Jacob Cleary
2004
Welcome to XML & DTDs
This tutorial assumes that you have been introduced to the possibilities of XML and want
to learn more about the nuts and bolts of creating an XML document or DTD
...

Objectives:
This tutorial aims to show you how to create both a "well formed" XML document and a
DTD that validates the XML
...

Take you through why you would want to create a DTD, the steps of creating a DTD, and
some examples of DTDs currently used
...

Definitions:
When talking about XML, here are some terms that would be helpful:





XML: eXtensible Markup Language, a standard created by the W3Group for
marking up data
...

XML Parser: Software that reads XML documents and interprets or "parse" the
code according to the XML standard
...


XML Anatomy
1

If you have ever done HTML coding, creating an XML document will seem very
familiar
...
If you haven't coded in HTML before,
after creating an XML document, you should find creating HTML documents easy
...
The
prolog or head of the document usually contains the administrative metadata about the
rest of document
...
Content is usually divided into two parts, that of the structural markup and
content contained in the markup, which is usually plain text
...
0" encoding="iso-8859-1"?>
...
0" declares which recommended version of XML the document should be
evaluated in
...

Note: XML currently has two versions out: 1
...
1
...
This tutorial deals with primarily with
XML version 1
...

Note: For more information about standard character sets, see
http://www
...
org/assignments/character-sets
The structural markup consists of elements, attributes, and entities; however, this tutorial
will primarily focus on elements and attributes
...
Element names can be any mixture of characters, with a few exceptions
...
For instance, is
different from , which is different from
...
The character : should be avoided as it
has been used for special extensions in XML
...
Elements containing content must have closing and opening tags
...

The content within elements can be either elements or character data
...

For example,
This is a sample of simple
XML
coding

...
is the child
of elementName, because it is nested within elementName
...

If the information in the attribute is valuable, why not contain that information in
an element?

3



Since some attributes can only have predefined categories, you can't go back and
easily add new categories
...

When using attributes in XML, the value of the attributes must always be contained in
quotes
...
For example, the attribute
version=”1
...
0’ and would
be interpreted the same way by the XML parser
...
For
example, if there was an attribute name with a value of John “Q
...


4

There are some rules regarding the order of opening and closing elements, but that will be
covered later in the tutorial
...


Creating a Simple XML Document
Now that you know the basic rules for creating an XML document, let's try them out
...

You can also use programs like Dreamweaver and Cooktop, but all that is necessary to
create the document is a text editor
...
We want to encode the emails and letters because we are creating an online
repository of archival messages within an organization or by an individual
...

To begin, we need to declare an XML version:
...
Let's use message as the root element, since both email and letters can be
classified as messages
...
0" encoding="iso-8859-1"?>


Note: You might have noticed that I created both the opening and closing tags for the
message element
...
After creating the tags, you would then fill in the
content
...

Parent and child relationships
A way of describing relationships in XML is the terminology of parent and child
...

An easy way of showing how elements are related in XML is to indent the code to show
that an element is a child of another
...
0" encoding="iso-8859-1"?>




Now that we have the XML declaration, the root element, and the child element (email),
let's determine the information we want to break out in an email
...
Since the
information about the sender and recipients are generally in the head of the document,
let's consider them children elements of a parent element that we will call

...

So our XML will look something like this:
...
utexas
...
utexas
...




Now, let's create an XML document for a letter
...
Additionally, we
want to know the date that it was sent and what salutation was used to start off the
message
...
0" encoding="iso-8859-1"?>



Margaret
God
1970

6



Are you there God?
It's me Margaret
...

Instead of creating an additional element called , let's assign an attribute to the
elements and indicating whether that document was a reply to a
previous message
...

Now that we've made some XML documents, let's talk about "well formed" XML and
valid XML
...
Valid
When talking about XML documents, two commonly-used terms are "well formed" and
"valid
...
in its markup
...

Note: An XML Parser is software that reads XML documents and interprets or "parses"
the code according to the XML standard
...

For example, a parser would be needed to compare an XML document to a DTD
...

When you say an XML document is valid, you're saying that the element structure and
markup of the XML document matches a defined standard of relationships, in addition to
having well formed markup
...

These standards are useful when dealing with the creation of a number of XML
documents for they provide a quality control measure to ensure that all the documents
meet a minimum standard
...
Later, we'll create a
sample DTD for our email and letter XML documents
...
Additionally, you can
create XML documents without a DTD, but the XML document can't be considered valid
without a document type
...
To determine whether or not XML documents are well formed, we
need to use an XML parser
...

The most recent versions of Internet Explorer, Netscape, Mozilla or Firefox have at least
some simple XML parsing functionality built in and can check XML documents for well
formed markup
...

Since XML requires elements to have opening and closing tags, missing a closing tag
will cause what XML calls a "fatal" error - the parser will shut down and give an error
message
...
You will see the error message that your browser generates
...
Notice that the element is
missing a closing tag
...
However, XML is less forgiving then HTML; in XML,
case matters
...

HTML would read them as the same element
...
Take a look at this

8

example of mixed capitalization to see what error messages your parser might give for
that mistake
...

Another common error is forgetting to close your quotations around the attributes value
...
To see the code that generated this error message,
view the source
...
XML
requires the most recently opened XML element to be closed
...
No, we're not talking about the "Dancing Queen"; rather, if element A
is opened first, and element B is the child of element A, you must close element B before
closing A
...
To see the code that generated this error message, view the source
...
" Now let's talk about DTDs and validating your XML documents
...
For example, all the
information about dates are in tags called rather than