XML Markup Languages Project
1. Introduction
Extensible Markup Language (XML) is a markup language that structures and
adds meaning to data. Unlike HTML, which is concerned with displaying
information, XML is primarily designed to store and transport data in a
structured way.
Uses:
Sharing data across applications.
Storing hierarchical and relational data.
Presenting database results in a flexible format.
2. HTML vs XML
HTML: Focuses on presentation (how data looks).
XML: Focuses on structure (how data is organized).
3. XML – Inspectors Data
[Link]:
<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="[Link]"?>
<buildinginspectors>
<inspector>
<insid>I11</insid>
<insname>Jane</insname>
</inspector>
<inspector>
<insid>I22</insid>
<insname>Niko</insname>
</inspector>
<inspector>
<insid>I33</insid>
<insname>Mick</insname>
</inspector>
</buildinginspectors>
This XML stores inspector information. The xml-stylesheet line links to the
XSLT file.
4. XSL Transformations
(a) Simple Text Output ([Link])
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="[Link]
<xsl:template match="/">
<html>
<head>
<title>Web page XML EXAMPLE1</title>
</head>
<body>
<b>Building Inspectors</b>
<xsl:for-each select="buildinginspectors/inspector">
<p>Inspector ID: <xsl:value-of select="insid"/></p>
<p>Inspector Name: <xsl:value-of select="insname"/></p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Output: Inspectors listed as plain text.
(b) Table Output ([Link])
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="[Link]
<xsl:template match="/">
<html>
<head>
<title>Web page XML EXAMPLE2</title>
</head>
<body>
<b>Building Inspectors</b>
<table border="1">
<tr bgcolor="#D3D3D3">
<th>Inspector ID</th>
<th>Inspector Name</th>
</tr>
<xsl:for-each select="buildinginspectors/inspector">
<tr>
<td><xsl:value-of select="insid"/></td>
<td><xsl:value-of select="insname"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Output: Inspectors displayed in a table with headers.
5. SQL/XML Queries
SQL can integrate with XML using xmlelement() to generate XML output
directly.
SQL Query A
SELECT [Link], [Link]
FROM inspector i;
Output (Table):
Insid Insname
I11 Jane
I22 Niko
I33 Mick
SQL/XML Query AX
SELECT xmlelement(name "inspector",
xmlelement(name "insid", [Link]),
xmlelement(name "insname", [Link]))
FROM inspector i;
Output (XML):
<inspector>
<insid>I11</insid>
<insname>Jane</insname>
</inspector>
<inspector>
<insid>I22</insid>
<insname>Niko</insname>
</inspector>
<inspector>
<insid>I33</insid>
<insname>Mick</insname>
</inspector>
This demonstrates how relational data can be output in XML form.
6. XPath and XQuery (Conceptual Overview)
XPath → A query language for selecting nodes in XML documents.
Example: /buildinginspectors/inspector/insname retrieves all
inspector names.
XQuery → A more powerful query language that can filter, sort, and
combine XML data. Example:
for $i in doc("[Link]")/buildinginspectors/inspector
return <result>{$i/insid} - {$i/insname}</result>
7. How to Test Live Examples
1. Save [Link], [Link], and [Link] in the
same folder.
2. Open [Link] in a browser (Firefox recommended for XSL
support).
3. It will apply the linked stylesheet and display formatted data.
4. Change the stylesheet reference in XML to switch between Example 1
and Example 2.
8. Screenshots (To be added)
Output of [Link] (List format).
Output of [Link] (Table format).
9. Key Learnings
1. XML structures data, while HTML presents it.
2. XSLT can transform XML into readable HTML.
3. SQL/XML integrates relational databases with XML.
4. XPath and XQuery provide ways to query and manipulate XML data.
End of Extended Draft – Professor-ready version with SQL/XML and
XQuery coverage.