XML - Lesson 6

Embed Size (px)

Citation preview

  • 8/14/2019 XML - Lesson 6

    1/45

    Displaying Data with XSLT

    NIIT eXtensible Markup Language/Lesson 6/Slide 1 of 45

    Objectives

    In this lesson, you will learn to:

    Perform conditional formatting in a style sheet Use XPath pattern matching in a style sheet

    Create a comma-separated list of values

    Import a style sheet in another style sheet

  • 8/14/2019 XML - Lesson 6

    2/45

    Displaying Data with XSLT

    NIIT eXtensible Markup Language/Lesson 6/Slide 2 of 45

    Problem Statement 6.D.1A list of products sold at CyberShoppe needs to be displayed.These products need to be categorized based on their prices.The details about products priced higher than $50 are to be

    displayed in red and the rest are to be displayed in green.The details to be displayed include the product name,description, price, and quantity on hand.

  • 8/14/2019 XML - Lesson 6

    3/45

    Displaying Data with XSLT

    NIIT eXtensible Markup Language/Lesson 6/Slide 3 of 45

    Task List

    Identify data to be displayed.

    Identify the elements required to format data based on

    a condition. Create a style sheet to format data based on a

    condition.

    Apply the style sheet to the XML document.

    View the XML document.

  • 8/14/2019 XML - Lesson 6

    4/45

    Displaying Data with XSLT

    NIIT eXtensible Markup Language/Lesson 6/Slide 4 of 45

    Task 1: Identify data to be displayed.

    Result

    As per the scenario, the data that has to be displayed is as

    follows:

    PRODUCTNAME

    DESCRIPTION

    PRICE

    QUANTITY

  • 8/14/2019 XML - Lesson 6

    5/45

    Displaying Data with XSLT

    NIIT eXtensible Markup Language/Lesson 6/Slide 5 of 45

    Task 2: Identify the elements required to format databased on a condition.

    The if Element

    The if element provides a simple if-then construct. Thesyntax ofif element is as follows:

    [actions to be performed if the condition

    is true]

  • 8/14/2019 XML - Lesson 6

    6/45

    Displaying Data with XSLT

    NIIT eXtensible Markup Language/Lesson 6/Slide 6 of 45

    Task 2: Identify the elements a condition. (Contd.)

    The choose Element

    The choose element is used to make a choice when there

    are two or more possible courses of action.

    It provides a means for testing multiple conditions.

  • 8/14/2019 XML - Lesson 6

    7/45

    Displaying Data with XSLT

    NIIT eXtensible Markup Language/Lesson 6/Slide 7 of 45

    Task 2: Identify the elements a condition.(Contd.)

    The syntax of the choose element is as follows:

    [action to be taken]

    :

    :

    [action to be taken]

  • 8/14/2019 XML - Lesson 6

    8/45

    Displaying Data with XSLT

    NIIT eXtensible Markup Language/Lesson 6/Slide 8 of 45

    Task 2: Identify the elements a condition. (Contd.)

    The following table lists the comparison and booleanoperators that can be used with the xsl:choose and xsl:ifelements:

    PRICE[. >= 20]Greater than or equal to>=

    PRICE[.

    PRICE[. < 20]Less than