Use blockquote to output value from xml
File: Data.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="Transform.xslt"?>
<InvList xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="Schema.xsd">
<ItemInfo LastUpdated="2005-02-01">
<ItemName>name 1</ItemName>
<ItemNum>0001</ItemNum>
<ItemDesc>description 1</ItemDesc>
<ItemCost>14.55</ItemCost>
<ItemLocation>Chicago</ItemLocation>
<NumInStock>2345</NumInStock>
</ItemInfo>
<ItemInfo LastUpdated="2004-12-09">
<ItemName>name 1</ItemName>
<ItemNum>0002</ItemNum>
<ItemDesc>description 2</ItemDesc>
<ItemCost>9.06</ItemCost>
<ItemLocation>SanDiego</ItemLocation>
<NumInStock>13</NumInStock>
</ItemInfo>
<ItemInfo LastUpdated="2003-13-19">
<ItemName>name 1</ItemName>
<ItemNum>0003</ItemNum>
<ItemDesc>description 3</ItemDesc>
<ItemCost>12.34</ItemCost>
<ItemLocation>Over-seas</ItemLocation>
<NumInStock>40325</NumInStock>
</ItemInfo>
</InvList>
File: Transform.xslt
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns="http://www.w3.org/TR/REC-html40" xmlns:s="D:\Osborn-McGraw\XML-ComRef\Chapter27">
<xsl:output method="xml" version="1.0" encoding="UTF-8" omit-xml-declaration="no" indent="no" media-type="text/html" />
<xsl:template match="InvList">
<html>
<head>
<title> Inventory List </title>
<style type="text/css">
@page {
margin-left : 15px;
margin-bottom : 30px;
margin-right : 15px;
}
h1 {
font-family : Verdana, Arial, sans-serif ;
font-size : larger;
background-color : yellow;
border-bottom-style : double;
color : Black;
}
</style>
</head>
<body>
<xsl:for-each select="ItemInfo">
<h1>
<xsl:value-of select="ItemName" />
</h1>
<blockquote>
Item Number: <xsl:value-of select="ItemNum" /><br />
Item Description: <xsl:value-of select="ItemDesc" /><br />
Item Cost: $<xsl:value-of select="ItemCost" /><br />
Item Location: <xsl:value-of select="ItemLocation" /><br />
Num. In Stock: <xsl:value-of select="NumInStock" />
</blockquote>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Output:
<?xml version="1.0" encoding="UTF-8"?><html xmlns:s="D:\Osborn-McGraw\XML-ComRef\Chapter27" xmlns="http://www.w3.org/TR/REC-html40" xmlns:fo="http://www.w3.org/1999/XSL/Format"><head><title> Inventory List </title><style type="text/css">
@page {
margin-left : 15px;
margin-bottom : 30px;
margin-right : 15px;
}
h1 {
font-family : Verdana, Arial, sans-serif ;
font-size : larger;
background-color : yellow;
border-bottom-style : double;
color : Black;
}
</style></head><body><h1>name 1</h1><blockquote>
Item Number: 0001<br/>
Item Description: description 1<br/>
Item Cost: $14.55<br/>
Item Location: Chicago<br/>
Num. In Stock: 2345</blockquote><h1>name 1</h1><blockquote>
Item Number: 0002<br/>
Item Description: description 2<br/>
Item Cost: $9.06<br/>
Item Location: SanDiego<br/>
Num. In Stock: 13</blockquote><h1>name 1</h1><blockquote>
Item Number: 0003<br/>
Item Description: description 3<br/>
Item Cost: $12.34<br/>
Item Location: Over-seas<br/>
Num. In Stock: 40325</blockquote></body></html>
Related examples in the same category