XML Session07.pps
XML Session07.pps
XML Session07.pps
Objectives
XPath:
Is used to search and retrieve information from an XML file.
Treats an XML document as a tree of interrelated branches
and nodes, as shown in the following figure.
PRODUCTDATA
PRODUCT
CATEGORY
PRODID=“P001” PRODUCTNAME DESCRIPTION PRICE QOH
=“TOY”
Problem Statement:
The executive at CyberShoppe needs to display the
product-wise order report. The product and order data is stored
in an XML document. This data includes product details, such
as product ID, name, and price per unit. For each product, the
details about all the orders placed against that product are also
stored in the document. The order details include the order
number, shipping address, total quantity ordered and the order
value. The total sales value for each product also needs to be
displayed.
SUMMARY
PRODUCT
ORDER
SHIPPING
ADDRESS
QUANTITY
Problem Statement:
The employee information of an organization is stored in the file
employee.xml. The data stored in this file is as follows:
<?xml version="1.0"?>
<EMPDETAILS>
<EMP EMPID="E001">
<ENAME>Karen</ENAME>
<DESG>MANAGER</DESG>
<DEPT>SALES</DEPT>
<SALARY>250</SALARY>
</EMP>
<EMP EMPID="E002">
<ENAME>George</ENAME>
<DESG>Executive</DESG>
<DEPT>ACCOUNTS</DEPT>
<SALARY>300</SALARY>
TABLE Acts as a container for all other tags used to specify the appearance of data in
a table. It has attributes, such as border, background color, cellpadding,
cellspacing, and width that enable you to specify the appearance of the table.
TR Used to represent a row in a table. This tag acts as a container for the TH and
TD elements.
Problem Statement:
The details about the books that are available for sale at
CyberShoppe are stored in an XML document. The book
details, such as book ID, title, rate, author first name, and
author last name should be displayed in a table. The first and
last names of the author should be displayed in a single
column, AUTHOR(S). If a book has multiple authors, their
names should be displayed as comma‑separated values. The
following figure shows a sample output.
Problem Statement:
The list of products sold at CyberShoppe needs to be
displayed. These products need to be categorized based on
their prices, with products priced higher than $50 displayed in
red and the rest in green. The product name, description, price,
and quantity on hand of each product should be displayed, as
shown in the following figure.
Answer:
a. <xsl:if test=”SALARY[. = 1200]”>
Answer:
c. False
Answer:
c. The expression will result in an error.
Answer:
b. <xsl:value-of select= “@partno” />