5 XSLT PDF
5 XSLT PDF
5 XSLT PDF
<card xmlns
xmlns="http://businesscard.org">
http://businesscard.org >
<name>John Doe</name>
<title>CEO, Widget Inc.</title>
<email>john.doe@widget.inc</email>
<phone>(202) 555-1414</phone>
<logo
l uri="widget.gif"/>
i " id t if"/
</card>
<xsl:stylesheet
l l h version="2.0"
i " "
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:b="http://businesscard.org"
xmlns="http://www.w3.org/1999/xhtml">
l "htt // 3 /1999/ ht l"
<xsl:template match="b:card">
<html>
<head>
<title><xsl:value-of select="b:name/text()"/></title>
</head>
<body bgcolor="#ffffff">
<table border="3">
<tr>
<td>
<xsl:apply-templates select="b:name"/><br/>
<xsl:apply-templates
<xsl:apply templates select
select="b:title"/><p/>
b:title /><p/>
<tt><xsl:apply-templates select="b:email"/></tt><br/>
<xsl:template match="b:name|b:title|b:email|b:phone">
<xsl:value-of
<xsl:value of select=
select="text()"/>
text() />
</xsl:template>
</xsl:stylesheet>
IIntroduction
d i
Templates and pattern matching
Sequence constructors
Using XSLT
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
...
</xsl:stylesheet>
<xsl:template match="...">
...
</xsl:template>
rcp:recipe/rcp:ingredient//rcp:preparation
IIntroduction
d i
Templates and pattern matching
Sequence constructors
Using XSLT
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns "http://www w3 org/1999/xhtml"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="/">
<html>
<head>
<title>Hello World</title>
</head>
<body bgcolor="green">
<b>Hello
b H ll World</b>
W ld /b
</body>
</html>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version=
version="22.0
0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match=
match="/">
/ >
<xsl:element name="html">
<xsl:element name="head">
<xsl:element name=
name="title">
title >
Hello World
</xsl:element>
</xsl:element>
<xsl:element name="body">
<xsl:attribute name="bgcolor" select="'green'"/>
<xsl:element name=
name="b">
b >
Hello World
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version=
version="2
2.0
0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match=
match="/">
/ >
<xsl:element name="html">
<xsl:element name="head">
<xsl:element name=
name="title">
title >
Hello World
</xsl:element>
</xsl:element>
<xsl:element name="body">
<xsl:attribute name="bgcolor" select="//@bgcolor"/>
<xsl:element name=
name="b">
b >
Hello World
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns "http://www w3 org/1999/xhtml"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="/">
<html>
<head>
<title>Hello World</title>
</head>
<body bgcolor="{//@bgcolor}">
<b>Hello
b H ll World</b>
W ld /b
</body>
</html>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version
version="2.0"
2.0
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="students">
<summary>
<xsl:apply-templates select="student"/>
</summary>
</xsl:template>
<xsl:template match="student">
<grades>
<xsl:attribute name="id" select="@id"/>
<xsl:apply-templates select=".//@grade"/>
</grades>
</xsl:template>
<xsl:template match="@grade">
<grade>
<xsl:value-of select="."/>
</grade>
</xsl:template>
</xsl:stylesheet>
<summary>
<name id="100026">Joe Average</name>
/
<name id="100078">Jack Doe</name>
<grades id="100026">
<grade>C-</grade>
<grade>C+</grade>
<grade>D</grade>
</grades>
<grades id="100078">
g de /g de
<grade>A</grade>
<grade>A-</grade>
<grade>B+</grade>
<grade>A</grade>
</grades>
</summary>
/summary
An Introduction to XML and Web Technologies 28
Using Modes (1/2)
<xsl:stylesheet version=
version="2
2.0
0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
p
<xsl:template match="students">
<summary>
<xsl:apply-templates mode="names" select="student"/>
<xsl:apply-templates mode="grades" select="student"/>
</summary>
</xsl:template>
<xsl:template
s te p te mode="names"
ode es match="student">
tc stude t
<name>
<xsl:attribute name="id" select="@id"/>
<xsl:value-of select="name"/>
</name>
</xsl:template>
/xsl:template
An Introduction to XML and Web Technologies 29
Using Modes (2/2)
<xsl:template match="@grade">
<grade>
<xsl:value-of
l l f select="."/>
l t " "/
</grade>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version=
version="2
2.0
0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="students">
<summary>
<xsl:apply-templates select="student"/>
</summary>
</xsl:template>
<xsl:template match="student">
<grades>
<xsl:attribute name="id" select="@id"/>
<xsl:for-each select=".//@grade">
<grade>
<xsl:value-of select="."/>
</grade>
</xsl:for each>
</xsl:for-each>
</grades>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="students">
y
<summary>
<xsl:apply-templates select="student"/>
</summary>
p
</xsl:template>
<xsl:template match="student">
g
<grades>
<xsl:attribute name="id" select="@id"/>
<xsl:for-each select=".//@grade">
<xsl:if test=". ne 'F'">
<grade><xsl:value-of select="."/></grade>
</xsl:if>
/
</xsl:for-each>
</grades>
</xsl:template>
/ s sty es eet
</xsl:stylesheet>
<xsl:stylesheet version=
version="2
2.0
0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
xmlns:b="http://businesscard.org"
<xsl:template match=
match="b:card">
b:card >
<contact>
<xsl:choose>
<xsl:when test=
test="b:email">
b:email >
<xsl:value-of select="b:email"/>
</xsl:when>
<xsl:when test=
test="b:phone">
b:phone >
<xsl:value-of select="b:phone"/>
</xsl:when>
<xsl:otherwise>
No information available
</xsl:otherwise>
</xsl:choose>
</contact>
</xsl:template>
</xsl:stylesheet>
<xsl:template match="student">
<grades>
<xsl:attribute name=
name "id"
id select=
select "@id"/>
@id />
<xsl:for-each select=".//@grade">
<xsl:call-template
<xsl:call template name
name="listgrade"/>
listgrade />
</xsl:for-each>
</grades>
</xsl:template>
An Introduction to XML and Web Technologies 34
Template Invocation (2/2)
<xsl:template name="listgrade">
<grade>
<xsl:value-of
xsl:value of select
select="."/>
" "/
</grade>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match
match="students">
students >
<enrolled>
<xsl:apply-templates select="student">
<xsl:sort
l select="age"
l " " data-type="number"
d " b "
order="descending"/>
<xsl:sort select="name"/>
</xsl:apply-templates>
</enrolled>
</xsl:template>
<xsl:template match="student">
<student name="{name}" age="{age}"/>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/|@*|node()">
<xsl:copy>
<xsl:apply-templates
l l l select="@*|node()"/>
l "@ | d ()"/
</xsl:copy>
</xsl:template>
/ l t l t
</xsl:stylesheet>
IIntroduction
d i
Templates and pattern matching
Sequence constructors
Using XSLT
<xsl:stylesheet version=
version="2
2.0
0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:rcp="http://www.brics.dk/ixwt/recipes"
xmlns:xsl="http://www
xmlns:xsl= http://www.w3.org/1999/XSL/Transform
w3 org/1999/XSL/Transform">
>
<xsl:template match="rcp:collection">
<html>
<head>
<title><xsl:value-of select="rcp:description"/></title>
<link href="style.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<table border="1">
<xsl:apply-templates select=
select="rcp:recipe"/>
rcp:recipe />
</table>
</body>
</html>
</xsl:template>
<xsl:template match=
match="rcp:recipe">
rcp:recipe >
<tr>
<td>
<h1><xsl:value of select=
<h1><xsl:value-of select "rcp:title"/></h1>
rcp:title /></h1>
<i><xsl:value-of select="rcp:date"/></i>
<ul><xsl:apply-templates select="rcp:ingredient"/></ul>
<xsl:apply templates select=
<xsl:apply-templates select "rcp:preparation"/>
rcp:preparation />
<xsl:apply-templates select="rcp:comment"/>
<xsl:apply-templates select="rcp:nutrition"/>
</td>
</tr>
</xsl:template>
<xsl:template match=
match="rcp:ingredient">
rcp:ingredient >
<xsl:choose>
<xsl:when test="@amount">
<li>
<xsl:if test="@amount!='*'">
<xsl:value-of select="@amount"/>
<xsl:text> </xsl:text>
<xsl:if test="@unit">
<xsl:value-of select="@unit"/>
<xsl:if test=
test "number(@amount)>number(1)">
number(@amount)>number(1) >
<xsl:text>s</xsl:text>
</xsl:if>
<xsl:text> of </xsl:text>
</xsl:if>
</xsl:if>
<xsl:text>
sl te t </xsl:text>
/ sl te t
<xsl:value-of select="@name"/>
</li>
</xsl:when>
/ l h
<xsl:otherwise>
<li><xsl:value-of select="@name"/></li>
<ul><xsl:apply-templates select="rcp:ingredient"/></ul>
<xsl:apply-templates
<xsl:apply templates select=
select="rcp:preparation"/>
rcp:preparation />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match=
match="rcp:preparation">
rcp:preparation >
<ol><xsl:apply-templates select="rcp:step"/></ol>
</xsl:template>
<xsl:template match="rcp:step">
<li><xsl:value-of select="node()"/></li>
</xsl:template>
<xsl:template match="rcp:comment">
<ul>
<li type="square"><xsl:value-of select="node()"/></li>
</ul>
</xsl:template>
<xsl:template match="rcp:nutrition">
<table border="2">
<tr>
y
<th>Calories</th><th>Fat</th><th>Carbohydrates</th><th>Protein</th>
<xsl:if test="@alcohol">
<th>Alcohol</th>
</xsl:if>
</tr>
<tr>
g g
<td align="right"><xsl:value-of select="@calories"/></td>
/ /
<td align="right"><xsl:value-of select="@fat"/></td>
<td align="right"><xsl:value-of select="@carbohydrates"/></td>
g g
<td align="right"><xsl:value-of select="@protein"/></td>
p / /
<xsl:if test="@alcohol">
<td align="right"><xsl:value-of select="@alcohol"/></td>
/
</xsl:if>
</tr>
</table>
/ s te p ate
</xsl:template>
</xsl:stylesheet>
An Introduction to XML and Web Technologies 47
The Output
<xsl:stylesheet version=
version="2
2.0
0"
xmlns:rcp="http://www.brics.dk/ixwt/recipes"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match=
match="rcp:collection">
rcp:collection >
<nutrition>
<xsl:apply-templates select="rcp:recipe"/>
</nutrition>
</xsl:template>
<xsl:template match=
match="rcp:recipe">
rcp:recipe >
<dish name="{rcp:title/text()}"
calories="{rcp:nutrition/@calories}"
fat= {rcp:nutrition/@fat}
fat="{rcp:nutrition/@fat}"
carbohydrates="{rcp:nutrition/@carbohydrates}"
protein="{rcp:nutrition/@protein}"
alcohol="{if
alcohol= {if (rcp:nutrition/@alcohol)
then rcp:nutrition/@alcohol else '0%'}"/>
</xsl:template>
</xsl:stylesheet>
<nutrition>
<dish name="Beef Parmesan with Garlic Angel Hair Pasta"
calories="1167"
fat="23%" carbohydrates="45%" protein="32%" alcohol="0%"/>
<dish name="Ricotta Pie"
calories="349"
fat="18%" carbohydrates="64%" protein="18%" alcohol="0%"/>
<dish name="Linguine Pescadoro"
calories="532"
fat="12%" carbohydrates="59%" protein="29%" alcohol="0%"/>
<dish name="Zuppa Inglese"
calories="612"
fat="49%" carbohydrates="45%" protein="4%" alcohol="2%"/>
<dish name="Cailles en Sarcophages"
calories="8892"
fat="33%" carbohydrates="28%" protein="39%" alcohol="0%"/>
</nutrition>
<xsl:template match="nutrition">
<html>
<head>
<title>Nutrition Table</title>
</head>
<body>
<table border="1">
<tr>
<th>Dish</th>
<th>Calories</th>
<th>Fat</th>
<th>Carbohydrates</th>
<th>Protein</th>
</tr>
<xsl:apply-templates select="dish"/>
</table>
</body>
</html>
</xsl:template>
/ l t l t
<xsl:template match="dish">
<tr>
<td><xsl:value-of select="@name"/></td>
<td align=
align="right"><xsl:value-of
right ><xsl:value-of select=
select="@calories"/></td>
@calories /></td>
<td align="right"><xsl:value-of select="@fat"/></td>
<td align="right"><xsl:value-of select="@carbohydrates"/></td>
<td align="right"><xsl:value-of select="@protein"/></td>
</tr>
/ s te p ate
</xsl:template>
</xsl:stylesheet>
http://www.w3.org/TR/xslt20/
http://saxon sourceforge net/
http://saxon.sourceforge.net/
http://www.w3.org/TR/xsl/
http://xml.apache.org/fop/
<xsl:stylesheet version="2.0"
xmlns:rcp="http://www.brics.dk/ixwt/recipes"
xmlns:xsl "http://www w3 org/1999/XSL/Transform"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="rcp:collection">
<uses>
<xsl:for-each-group select="//rcp:ingredient"
group-by="@name">
<use name="{current-grouping-key()}"
count="{count(current-group())}"/>
</xsl:for-each-group>
/ l f h
</uses>
</xsl:template>
</xsl:stylesheet>
<uses>
<use name="beef cube steak" count="1"/>
<use name
name="onion,
onion, sliced into thin rings
rings" count
count="1"/>
1 />
<use name="green bell pepper, sliced in rings" count="1"/>
<use name="Italian seasoned bread crumbs" count="1"/>
<use name="grated
" d Parmesan cheese"
h " count="1"/>
"1"/
<use name="olive oil" count="2"/>
p g
<use name="spaghetti sauce" count="1"/>
<use name="shredded mozzarella cheese" count="1"/>
<use name="angel hair pasta" count="1"/>
<use name=
name="minced
minced garlic
garlic" count=
count="3"/>
3 />
...
</uses>
<xsl:stylesheet version="2.0"
xmlns:rcp="http://www.brics.dk/ixwt/recipes"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
p
<xsl:template match="rcp:ingredient">
p g
<rcp:ingredient>
<xsl:attribute name="level">
p
<xsl:number level="multiple" count="rcp:ingredient"/>
p g
</xsl:attribute>
<xsl:apply-templates select="@*|*"/>
/ p g
</rcp:ingredient>
</xsl:template>
p
<xsl:template match="@*">
<xsl:copy/>
</xsl:template>
<xsl:template match="*">
<xsl:copy><xsl:apply-templates/></xsl:copy>
/ s te p ate
</xsl:template>
</xsl:stylesheet>
An Introduction to XML and Web Technologies 58
Functions
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:local http://www.w3.org/2004/07/xquery local functions >
xmlns:local="http://www.w3.org/2004/07/xquery-local-functions">
<xsl:function name="local:fib">
<xsl:param name="n"/>
<xsl:value-of
l l f select="if
l "if ($n
($ le
l 1)
then 1
else local:fib($n -1)+local:fib($n -2)"/>
</xsl:function>
<xsl:template match=
match="/">
/ >
<xsl:value-of select="local:fib(10)"/>
</xsl:template>
</xsl:stylesheet>
<xsl:template match="rcp:recipe">
<xsl:variable name
name="t"
t select
select="rcp:title/text()"/>
rcp:title/text() />
<xsl:if test="not(doc('dislikes.xml')//
rcp:recipe[rcp:title eq $t])">
<xsl:copy-of
l f select="."/>
l " "/
</xsl:if>
</xsl:template>
</xsl:stylesheet>
An Introduction to XML and Web Technologies 60
Multiple Output Documents (1/2)
<xsl:stylesheet version="2.0"
xmlns="http://www
xmlns= http://www.w3.org/1999/xhtml
w3 org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="students">
<xsl:result-document
<xsl:result document href=
href="names
names.html
html">
>
<html>
<head><title>Students</title></head>
<body>
<xsl:apply-templates select="student" mode="name"/>
</body>
</html>
</xsl:result-document>
<xsl:result-document href="grades.html">
<html>
<head><title>Grades</title></head>
<body>
<xsl:apply templates select=
<xsl:apply-templates select="student"
student mode=
mode="grade"/>
grade />
</body>
</html>
</xsl:result document>
</xsl:result-document>
</xsl:template>
An Introduction to XML and Web Technologies 61
Multiple Output Documents (2/2)
<xsl:template match="student" mode="name">
<a href=
href="grades
grades.html#{@id}
html#{@id}"><xsl:value-of
><xsl:value of select=
select="name"/></a>
name /></a>
<br/>
</xsl:template>
<xsl:template match=
match="result">
result >
<li>
<xsl:value-of select="@course"/>:
<xsl:text> </xsl:text>
<xsl:value-of select="@grade"/>
</li>
</xsl:template>
</xsl:stylesheet>
An Introduction to XML and Web Technologies 62
The First Output
<html>
<head><title>Students</title></head>
<body>
<a href="grades.html#100026">Joe Average</a>
<br/>
<a href="grades.html#100078">Jack
h f " d h l#100078" k Doe</a>
/
<br/>
y
</body>
</html>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="howabout">
<answer>
I don't like <xsl:value-of select="text()"/>
</answer>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="2.0"
xmlns:xsl "http://www
xmlns:xsl= http://www.w3.org/1999/XSL/Transform
w3 org/1999/XSL/Transform">
>
<xsl:include href="negative.xsl"/>
<xsl:template match="*">
<answer>
I'm crazy for <xsl:value-of select="text()"/>
</answer>
</xsl:template>
</xsl:stylesheet>
<howabout>Zuppa Inglese</howabout>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="howabout">
<answer>
I don't like <xsl:value-of select="text()"/>
</answer>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="2.0"
xmlns:xsl "http://www
xmlns:xsl= http://www.w3.org/1999/XSL/Transform
w3 org/1999/XSL/Transform">
>
<xsl:import href="negative.xsl"/>
<xsl:template match="*">
<answer>
I'm crazy for <xsl:value-of select="text()"/>
</answer>
</xsl:template>
</xsl:stylesheet>
<howabout>Zuppa Inglese</howabout>
<translate language="Danish">
g g <translate language="French">
g g
<card>kort</card> <card>carte</card>
<name>navn</name> <name>nom</name>
<title>titel</title>
title titel /title <title>titre</title>
title titre /title
<email>email</email> <email>courriel</email>
<phone>telefon</phone> <phone>telephone</phone>
<logo>logo</logo> <logo>logo</logo>
</translate> </translate>
<xsl:template match="translate">
<myxsl:stylesheet version="2.0">
<xsl:namespace name=""
select="concat('http://businesscard.org/',@language)"/>
<myxsl:template match="b:card">
match "b:card">
<myxsl:element name="{card}">
<myxsl:apply-templates/>
</myxsl:element>
</myxsl:template>
<myxsl:template match="b:name">
<myxsl:element name="{name}">
<myxsl:value-of
m sl al e of select
select="."/>
" "/
</myxsl:element>
</myxsl:template>
</xsl:stylesheet>
An Introduction to XML and Web Technologies 69
Generated Stylesheet (1/2)
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:b="http://businesscard.org"
xmlns="http://businesscard.org/French">
<xsl:template match="b:card">
<xsl:element name="carte">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
p
<xsl:template match="b:name">
<xsl:element name="nom">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
<xsl:template match="b:title">
<xsl:element name="titre">
<xsl:value-of select="."/>
</xsl:element>
/ p
</xsl:template>
<card xmlns="http://businesscard.org">
p // g
<name>John Doe</name>
<title>CEO, Widget Inc.</title>
<email>john.doe@widget.inc</email>
<phone>(202) 555-1414</phone>
<logo
l uri="widget.gif"/>
i " id t if"/
</card>
<carte xmlns="http://businesscard.org/French">
<nom>John Doe</nom>
<titre>CEO, Widget Inc.</titre>
<courriel>john.doe@widget.inc</courriel>
<telephone>(202)
l h ( ) 555-1414</telephone>
/ l h
<logo uri="widget.gif"/>
</carte>
<integerlist>
<int>15</int>
<int>12</int>
<int>17</int>
<int>25</int>
i /i
<int>18</int>
<int>17</int>
i t 17 /i t
<int>23</int>
</integerlist>
/integerlist
An Introduction to XML and Web Technologies 73
XSLT 2.0 Solution (1/2)
<xsl:template
p match="integerlist">
g
<html>
<head>
<title>Integers</title>
title Integers /title
</head>
<body>
<xsl:variable name="sorted">
<xsl:for-each select="int">
<xsl:sort select="
select= ." data
data-type="number"/>
type= number />
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:variable>
<xsl:apply-templates select="$sorted"/>
</body>y
</html>
</xsl:template>
<xsl:template
p match="int">
<li>
<font>
<xsl:attribute
xsl attribute name
name="color"
"color"
select="if (position() mod 2 = 0) then 'blue'
else 'red'"/>
<xsl:value-of select="text()"/>
</font>
</li>
</xsl:template>
<xsl:stylesheet
y version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template
xsl template match
match="integerlist">
"integerlist"
<xsl:copy>
<xsl:apply-templates>
<xsl:sort select="." data-type="number"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="int">
<xsl:copy-of select="."/>
p
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet
y version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="integerlist">
<html>
<head>
<title>Integers</title>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
p
</xsl:template>
<xsl:template
p match="int[position()
p mod 2 = 0]">
<li>
<font color="blue">
<xsl:value-of
xsl value of select="text()"/>
select "text()"/
</font>
</li>
</xsl:template>
<xsl:template match="int[position()
match= int[position() mod 2 = 1]">
1] >
<li>
<font color="red">
<xsl:value-of select="text()"/>
</font>
</li>
</xsl:template>
</xsl:stylesheet>