1. Create an xml document to display Product Information with the
following attributes
a. Product_id
b. product_name
c. product_type
d. product_price
e. product_warranty
<?xml
version="1.0" encoding="UTF-8"?>
<!--
To
change this license header, choose License Headers in Project Properties.
To
change this template file, choose Tools | Templates
and
open the template in the editor.
-->
<ps>
<p>
<p-id>101</p-id>
<p_type>commercial</p_type>
<p_name>face-cream</p_name>
<warenty_period>2-mon</warenty_period>
<p_price>100</p_price>
</p>
<p>
<p-id>111</p-id>
<p_type>domestric</p_type>
<p_name>cot</p_name>
<warenty_period>3yrs</warenty_period>
<p_price>2000</p_price>
</p>
<p>
<p-id>120</p-id>
<p_type>commercial</p_type>
<p_name>body-wash</p_name>
<warenty_period>3-mon</warenty_period>
<p_price>3000</p_price>
</p>
<p>
<p-id>121</p-id>
<p_type>commercial</p_type>
<p_name>sofa</p_name>
<warenty_period>3-years</warenty_period>
<p_price>30000</p_price>
</p>
<p>
<p-id>122</p-id>
<p_type>commercial</p_type>
<p_name>caboard</p_name>
<warenty_period>5-years</warenty_period>
<p_price>25000</p_price>
</p>
<p>
<p-id>123</p-id>
<p_type>domestic</p_type>
<p_name>fridge</p_name>
<warenty_period>5years</warenty_period>
<p_price>30000</p_price>
</p>
<p>
<p-id>124</p-id>
<p_type>domrstic</p_type>
<p_name>mixer</p_name>
<warenty_period>2-year</warenty_period>
<p_price>3000</p_price>
</p>
<p>
<p-id>135</p-id>
<p_type>comercial</p_type>
<p_name>soap</p_name>
<warenty_period>1-mon</warenty_period>
<p_price>300</p_price>
</p>
<p>
<p-id>154</p-id>
<p_type>domrstic</p_type>
<p_name>washing-machine</p_name>
<warenty_period>5-year</warenty_period>
<p_price>30000</p_price>
</p>
</ps>
OUTPUT:
<?xml
version="1.0" encoding="UTF-8"?>
<!--
To
change this license header, choose License Headers in Project Properties.
To
change this template file, choose Tools | Templates
and
open the template in the editor.
-->
<ps>
<p>
<p-id>101</p-id>
<p_type>commercial</p_type>
<p_name>face-cream</p_name>
<warenty_period>2-mon</warenty_period>
<p_price>100</p_price>
</p>
<p>
<p-id>111</p-id>
<p_type>domestric</p_type>
<p_name>cot</p_name>
<warenty_period>3yrs</warenty_period>
<p_price>2000</p_price>
</p>
<p>
<p-id>120</p-id>
<p_type>commercial</p_type>
<p_name>body-wash</p_name>
<warenty_period>3-mon</warenty_period>
<p_price>3000</p_price>
</p>
<p>
<p-id>121</p-id>
<p_type>commercial</p_type>
<p_name>sofa</p_name>
<warenty_period>3-years</warenty_period>
<p_price>30000</p_price>
</p>
<p>
<p-id>122</p-id>
<p_type>commercial</p_type>
<p_name>caboard</p_name>
<warenty_period>5-years</warenty_period>
<p_price>25000</p_price>
</p>
<p>
<p-id>123</p-id>
<p_type>domestic</p_type>
<p_name>fridge</p_name>
<warenty_period>5years</warenty_period>
<p_price>30000</p_price>
</p>
<p>
<p-id>124</p-id>
<p_type>domrstic</p_type>
<p_name>mixer</p_name>
<warenty_period>2-year</warenty_period>
<p_price>3000</p_price>
</p>
<p>
<p-id>135</p-id>
<p_type>comercial</p_type>
<p_name>soap</p_name>
<warenty_period>1-mon</warenty_period>
<p_price>300</p_price>
</p>
<p>
<p-id>154</p-id>
<p_type>domrstic</p_type>
<p_name>washing-machine</p_name>
<warenty_period>5-year</warenty_period>
<p_price>30000</p_price>
</p>
</ps>
2. Create a DTD document to display Product Information created in
above xml document
<?xml
version='1.0' encoding='UTF-8'?>
<!--
TODO define vocabulary identification
PUBLIC ID: -//vendor//vocabulary//EN
SYSTEM ID: http://server/path/product-1.3b.dtd
-->
<!--
An example how to use this DTD from your
XML document:
<?xml version="1.0"?>
<!DOCTYPE ps SYSTEM
"product-1.3b.dtd">
<ps>
...
</ps>
-->
<!---
Put your DTDDoc comment here. -->
<!ELEMENT
ps (p)*>
<!---
Put your DTDDoc comment here. -->
<!ELEMENT
p (p_price|warenty_period|p_name|p_type|p-id)*>
<!---
Put your DTDDoc comment here. -->
<!ELEMENT
p-id (#PCDATA)>
<!---
Put your DTDDoc comment here. -->
<!ELEMENT
p_type (#PCDATA)>
<!---
Put your DTDDoc comment here. -->
<!ELEMENT
p_name (#PCDATA)>
<!---
Put your DTDDoc comment here. -->
<!ELEMENT
warenty_period (#PCDATA)>
<!---
Put your DTDDoc comment here. -->
<!ELEMENT
p_price (#PCDATA)>
OUTPUT:
<?xml
version='1.0' encoding='UTF-8'?>
<!--
TODO define vocabulary identification
PUBLIC ID: -//vendor//vocabulary//EN
SYSTEM ID:
http://server/path/product-1.3b.dtd
-->
<!--
An example how to use this DTD from your
XML document:
<?xml version="1.0"?>
<!DOCTYPE ps SYSTEM
"product-1.3b.dtd">
<ps>
...
</ps>
-->
<!---
Put your DTDDoc comment here. -->
<!ELEMENT
ps (p)*>
<!---
Put your DTDDoc comment here. -->
<!ELEMENT
p (p_price|warenty_period|p_name|p_type|p-id)*>
<!---
Put your DTDDoc comment here. -->
<!ELEMENT
p-id (#PCDATA)>
<!---
Put your DTDDoc comment here. -->
<!ELEMENT
p_type (#PCDATA)>
<!---
Put your DTDDoc comment here. -->
<!ELEMENT
p_name (#PCDATA)>
<!---
Put your DTDDoc comment here. -->
<!ELEMENT
warenty_period (#PCDATA)>
<!---
Put your DTDDoc comment here. -->
<!ELEMENT
p_price (#PCDATA)>
3. Create an XSL document to display Product Information created in
exercise 1 and display it as a table in a browser using XSLT.
<?xml
version="1.0" encoding="UTF-8"?>
<!--
Document
: product-1.3c.xsl
Created on : December 8, 2015, 2:33 PM
Author
: Administrator
Description:
Purpose of transformation follows.
-->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html"/>
<!-- TODO customize transformation rules
syntax recommendation
http://www.w3.org/TR/xslt
-->
<xsl:template match="/">
<html>
<head>
<title>product-1.3c.xsl</title>
</head>
<body>
<p
align="center"><b>Product details</b>
<table border="1"
>
<th
bgcolor="pink">p-id</th>
<th
bgcolor="white">p_type</th>
<th
bgcolor="pink">p_name</th>
<th
bgcolor="white">warenty_period</th>
<th bgcolor="pink">p_price</th>
<xsl:for-each
select="ps/p">
<tr>
<td
bgcolor="pink"><xsl:value-of
select="p-id"></xsl:value-of></td>
<td
bgcolor="white"><xsl:value-of select="p_type"></xsl:value-of></td>
<td
bgcolor="pink"><xsl:value-of
select="p_name"></xsl:value-of></td>
<td
bgcolor="white"><xsl:value-of
select="warenty_period"></xsl:value-of></td>
<td
bgcolor="pink"><xsl:value-of
select="p_price"></xsl:value-of></td>
</tr>
</xsl:for-each>
</table>
</p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
FINAL OUTPUT:
No comments:
Post a Comment