Eyal Oren, eyal@cs.vu.nl
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>Vrije Universiteit Amsterdam</title>
...
</head>
<body>
<h1>Example of HTML document</h1>
<p id="top">
Here is a paragraph with a sample reference to the <a
href="http://www.few.vu.nl">FEW section of the VU</a>.
</p>
<p>
Another paragraph, referring to the <a href="#top">top of this page</a>.
</p>
</body>
</html>
<p align="center">
<hr width="20%">
<img height="212px">
<table cellspacing="50%">
<frameset cols="20%,80%">
<html>
<head>
<title>Example</title>
<link rel="stylesheet" href="style.css" type="text/css"/>
</head>
<body>
</body>
</html>
h1 {
font-size: 120%;
font-weight: bold;
}
img.bordered {
border: 1px solid black
}
<?xml version="1.0" encoding="UTF8"?>
<country name= "The Netherlands" >
<geography>
<capital name= "Amsterdam" >
<remark> The Hague is the seat of the government </remark>
</capital>
<neighboring_country> Germany </neighboring_country>
<neighboring_country> Belgium </neighboring_country>
</geography>
</country>
<xml version="1.0" encoding="utf-8"?>
<person firstname="John" lastname="Smith"/>
<?xml version="1.0" encoding="UTF8"?>
<?xml:stylesheet type="text/css2" href="style.css"?>
<country name= "The Netherlands" >
<geography>
<capital name= "Amsterdam" >
<remark> the seat of the government is The Hague </remark>
</capital>
<neighboring_country> Germany </neighboring_country>
<neighboring_country> Belgium </neighboring_country>
</geography>
<!-- Should be extended with other data >
</country>
<!-- comment -->
<?xml:stylesheet type="text/css2" href="style.css"?>
<name>
<firstName>Vincent
<lastName>van Gogh
</firstName>
</lastName>
</name>
<name>
<firstName>Vincent</firstName>
<lastName>van Gogh</lastName>
<collection
xmlns:books="http://www.oclc.org/books/1.0/"
xmlns:webpage="http://www.w3c.org/html/1.0/">
<book>
<books:title>Gulliver's travels</books:title>
</book>
<web>
<webpage:title>My first homepage</webpage:title>
</web>
</collection>
<!ELEMENT country (geography, people, economy)>
<!ATTLIST country
name CDATA #REQUIRED>
<!ELEMENT geography (capital, neighboring_country*)>
<!ELEMENT capital (remark*)>
<!ATTLIST capital
name CDATA #REQUIRED>
<!ELEMENT remark (#PCDATA)>
<!ELEMENT neighboring_country (#PCDATA)>
<complexType name="capital">
<element name="name" type="string"/>
<element ref= "remark" maxOccurs="unbounded"/>
</complexType>
<complexType name="WindowsType">
<element name="version" type="string" minOccurs="0"
maxOccurs="1" default="W98"/>
<element name="includedBrowser" type="string"
minOccurs="0" maxOccurs="1" fixed="Internet Explorer"/>
</complexType>
<schema
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:po="http://www.example.com/purchaseOrder">
<element name="purchaseOrder" type="po:type"/>
<element name="comment" type=":string"/>
<element name="anotherComment" type="xsd:string"/>
<!-- etc. -->
</schema>
SELECT student_id, name FROM student WHERE firstyear = '2006'
http://www.cia.gov/cia/publications/factbook/index.html#chiefsofstate
/country/geography/capital/@name="Amsterdam"
/country/geography/capital/@name="Amsterdam"
/country[geography/neighboring_country="Germany"]
//capital
//capital
<xql:result>
<capital name="Algiers">
<capital name="Amsterdam">
<remark> the seat of the government is The Hague </remark>
</capital>
<capital name="Berlin"/>
<capital name="Bogota">
<capital name="Buenos Aires">
....
</xql:result>
/country[geography/neighboring_country="Germany"]
//author[3]
//author[3]/book[last()]
//author[3]/book[not @title]
<?xml version="1.0" encoding="iso88591" ?>
<country name= "The Netherlands" >
<geography>
<capital name= "Amsterdam" >
<remark> The Hague is the seat of the government </remark>
</capital>
<neighboring_country>Germany</neighboring_country>
<neighboring_country>Belgium</neighboring_country>
</geography>
</country>
/country/geography/neighboring_country
/country/geography/neighboring_country[2]
/country/geography/capital/@name
/country/geography/capital/remark/text()
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="foo.xsl"?>
<countries>
...
</countries>
<xsl:template match="/country/geography/capital">
<html>
<body>
<b> Name: </b>
<xsl:valueof select= "@name"/>
</body>
</html>
</xsl:template>
<xsl:template match="/country/geography">
<xsl:applytemplates select="capital"/>
</xsl:template>
<?xml version="1.0" encoding="iso-8859-1"?>
<countries>
<country name="The Netherlands">
<geography>
<capital name="Amsterdam">
<remark>The Hague is the seat of the government</remark>
</capital>
<neighboring_country> Germany </neighboring_country>
<neighboring_country> Belgium </neighboring_country>
</geography>
</country>
<country name="France">
<geography>
<capital name="Paris">
<remark>There is more to France than just Paris</remark>
</capital>
<neighboring_country>Germany</neighboring_country>
<neighboring_country>Belgium</neighboring_country>
<neighboring_country>Spain</neighboring_country>
<neighboring_country>Italy</neighboring_country>
<neighboring_country>Switzerland</neighboring_country>
</geography>
</country>
</countries>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1" indent="yes"/>
<xsl:template match="text()">
</xsl:template>
<xsl:template match="/">
<html>
<head>
<title>
<xsl:text>first example of XSLT transformation</xsl:text>
</title>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match ="country/geography/capital">
<p>
<b>Name of the capital</b>:
<xsl:value-of select = "@name"/>
</p>
</xsl:template>
</xsl:stylesheet>
Name of the capital: Amsterdam
Name of the capital: Paris
<?xml version="1.0" encoding="iso-8859-1"?>
<countries>
<country name="The Netherlands">
<geography>
<capital name="Amsterdam">
<remark>The Hague is the seat of the government</remark>
</capital>
<neighboring_country> Germany </neighboring_country>
<neighboring_country> Belgium </neighboring_country>
</geography>
</country>
<country name="France">
<geography>
<capital name="Paris">
<remark>There is more to France than just Paris</remark>
</capital>
<neighboring_country>Germany</neighboring_country>
<neighboring_country>Belgium</neighboring_country>
<neighboring_country>Spain</neighboring_country>
<neighboring_country>Italy</neighboring_country>
<neighboring_country>Switzerland</neighboring_country>
</geography>
</country>
</countries>
Country: The Netherlands
Neighboring country: Germany
Neighboring country: Belgium
Country: France
Neighboring country: Germany
Neighboring country: Belgium
Neighboring country: Spain
Neighboring country: Italy
Neighboring country: Switzerland
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1" indent="yes"/>
<xsl:template match="text()">
</xsl:template>
<xsl:template match="/">
<html>
<head>
<title>
<xsl:text>Second example of XSLT transformation</xsl:text>
</title>
</head>
<body>
<p>
<xsl:apply-templates/>
</p>
</body>
</html>
</xsl:template>
<xsl:template match="country">
<b>Country</b>:
<xsl:value-of select="@name"/>
<hr/>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="neighboring_country">
<b>Neighboring country:</b>
<xsl:value-of select="text()"/>
<hr/>
</xsl:template>
</xsl:stylesheet>