Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

inventory.

xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/XSL" href="invenstyle.xsl"?>
<inventory>
<product>
<name>Monitor</name>
<id>1001</id>
<price>20000</price>
<total_stock>5000</total_stock>
<sold>2647</sold>
</product>
<product>
<name>Keyboard</name>
<id>1002</id>
<price>600</price>
<total_stock>8500</total_stock>
<sold>6298</sold>
</product>
<product>
<name>Mouse</name>
<id>1003</id>
<price>200</price>
<total_stock>1000</total_stock>
<sold>123</sold>
</product>
<product>
<name>CPU</name>
<id>1004</id>
<price>15000</price>
<total_stock>6000</total_stock>
<sold>1687</sold>
</product>
<product>
<name>Printer</name>
<id>1005</id>
<price>6000</price>
<total_stock>2000</total_stock>
<sold>568</sold>
</product>
</inventory>

invenstyle.xslt

<?xml version="1.0" encoding="UTF-8"?>


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<html>
<body style="background-color:#95B5D6">
<center><h1>Inventory Details</h1></center>
<table border="5">
<tr bgcolor="#CC0000">
<th>Product name</th>
<th>Product ID</th>
<th>Price</th>
<th>Total Stock</th>
<th>Sold</th>
</tr>
<xsl:for-each select="inventory/product">
<xsl:if test="total_stock &gt; 10">
<tr bgcolor="#FFFF00">
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="id"/></td>
<td><xsl:value-of select="price"/></td>
<td><xsl:value-of select="total_stock"/></td>
<td><xsl:value-of select="sold"/></td>
</tr>
</xsl:if>
<xsl:otherwise>
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="id"/></td>
<td><xsl:value-of select="price"/></td>
<td><xsl:value-of select="total_stock"/></td>
<td><xsl:value-of select="sold"/></td>
</tr>
</xsl:otherwise>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

invenschema.xs
<?xml version="0.1"?>
<xs:schema>
<xs:element name="inventory">
<xs:element name="product">
<xs:complextype>

<xs:sequence>
<xs:element name="name" type="xs:string">
<xs:element name="id" type="xs:integer">
<xs:element name="price" type="xs:float">
<xs:element name="total_stock" type="xs:integer">
<xs:element name="sold" type="xs:integer">
</xs:sequence>
</xs:complextype>
</xs:element>
</xs:element>
</xs:schema>
inven.dtd
<!DOCTYPE inventory
[
<!ELEMENT inventory (product)>
<!ELEMENT product (name,id,price,total_stock,sold)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT id (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT total_stock (#PCDATA)>
<!ELEMENT sold (#PCDATA)>
]>

You might also like