eXtensible Markup Language (XML)
Before the lab
Introduction
Lab instructions
The lab is divided into sections. You should allow aprox. 10 minutes for each section.
However, note that the tasks are increasingly difficult and latter sections may be more time-consuming than the former ones.
Determine which of the following XML documents is well-formed. If a document is well-formed,
show its corresponding tree model. If it is not well-formed, explain why not. You may assume that all
of these documents are intended to be XML 1.0 documents, and thus the declaration is not needed.
NOTE: Assume that the prolog of the documents is present and the following lines are the body of the document.
- <a><b/><a>
- <a><b>foo</b></a><a>bar</a>
- <a><b>foo</b><b>bar</a>
- <a><b><c>foo</b>bar</c></a>
- <a/><b>foo</b><b>bar<b>
- <a><b><c>foo</c>baz<c>bar</c></b></a>
- <a x="1" X="2"><b>foo</b></a>
- <a x="1"><b x="2">foo</b></a>
- <a x="1" y="2" x="3"><b>foo</b></a>
- <a><b x="3"><c y="1">foo</c><c>bar</c></b></a>
2 Creating XML document
Modify the code below to describe the best book from your bookshelf:
<book>
<author>Grigoris Antoniou</author>
<author>Frank van Harmelen</author>
<title>A Semantic Web Primer</title>
<date>2008-10-09</date>
<publisher>The MIT Press</publisher>
</book>
3 DTD
Using a text editor, define a
DTD definition for your XML syntax. Put it in the report

You can define DTD definition inside XML file:
<?xml version="1.0" ?>
<!DOCTYPE root [
]>
XML content
4 Validating XML with DTD
Test your XML against defined DTD using
online validator -
it requires embedded DTD.
or
You can also test your XML using
xmlstarlet command:
Testing xml file against external DTD definition file use:
xmlstarlet val -e -d file.dtd file.xml
or when you use embeded DTD definition use:
xmlstarlet val -e -E file.xml
5 XSD
Using a text editor, define an
XSD definition for your XML syntax. Put it in the report

6 Validating XML with XSD
7 XPath
8 XSLT: XML -> HTML
Control questions
What are the required elements of XML file?
What is an empty element?
Does the XML have any predefined tags?
How to define a comment?
Is the XML platform dependent?
What is a CDATA section in XML file?
What is the meaning of the colon within tag name?
What is the DTD?
What is the XSD?
Which language (DTD or XSD) is more expressive?
What is the XPath?
Does the XPath allow for nested queries?
What is XSLT for?
How does the XSLT work?
If you want to know more