14
Unit 3 — Advanced Internet Technologies Lesson 11 — Introduction to XSL

Unit 3 — Advanced Internet Technologies

  • Upload
    kamin

  • View
    17

  • Download
    0

Embed Size (px)

DESCRIPTION

Unit 3 — Advanced Internet Technologies. Lesson 11 — Introduction to XSL. Objectives. Create simple XML/XSL Web Pages. Understand what an Xpath is and how to use it. Use the tag to extract and display XML data. Use the tag to make Web content dynamic. - PowerPoint PPT Presentation

Citation preview

Page 1: Unit 3 — Advanced Internet Technologies

Unit 3 — Advanced Internet Technologies

Lesson 11 — Introduction to XSL

Page 2: Unit 3 — Advanced Internet Technologies

Advanced Internet Technologies 2

Objectives

Create simple XML/XSL Web Pages. Understand what an Xpath is and how to use

it. Use the <xsl:value-of> tag to extract and

display XML data. Use the <xsl:attribute> tag to make Web

content dynamic.

Page 3: Unit 3 — Advanced Internet Technologies

Advanced Internet Technologies 3

Objectives (cont.)

Use the <xsl:for-each> tag to display XML data repetitively.

Use the <xsl:if> tag for conditional XML data processing.

Page 4: Unit 3 — Advanced Internet Technologies

Advanced Internet Technologies 4

XSL Basics

XSL stands for XML Stylesheet Language. XSL was designed to be a companion

technology to XML.

Page 5: Unit 3 — Advanced Internet Technologies

Advanced Internet Technologies 5

Hello World—Again

XSL documents are called stylesheets. The purpose of XSL stylesheets is to define

how XML data should be displayed in a Web browser.

Page 6: Unit 3 — Advanced Internet Technologies

Advanced Internet Technologies 6

Hello World—Again (cont.)

The XSL stylesheet for a particular XML document is identified by an XML directive tag.

<?xml-stylesheet type=“text/xsl” href=“[URL]”?>

Page 7: Unit 3 — Advanced Internet Technologies

Advanced Internet Technologies 7

Hello World—Again (cont.)

All XSL stylesheets must include an <xsl:stylesheet> tag and an <xsl:template> tag.

The <xsl:stylesheet> tag identifies the XML namespace to use.

The <xsl:template> tag identifies the root node of the corresponding XML document.

Page 8: Unit 3 — Advanced Internet Technologies

Advanced Internet Technologies 8

XSL Transformations

Combining an XML document with an XSL stylesheet is called transforming it.

The resulting Web page is called an XML Stylesheet Language Transformation (XSLT).

The <xsl:value-of> tag extracts a data value from an XML file and displays it.

Page 9: Unit 3 — Advanced Internet Technologies

Advanced Internet Technologies 9

Understanding Xpaths

An Xpath is a notational convention used to identify a particular data element in an XML document.

Xpaths can be absolute or relative.

Page 10: Unit 3 — Advanced Internet Technologies

Advanced Internet Technologies 10

Text Strings in XSL

Placing arbitrary text strings in XSL stylesheets can cause syntax errors.

Static text strings should be enclosed within <xsl:text> and </xsl:text> tags.

<xsl:text>Hello XSL World!</xsl:text>

Page 11: Unit 3 — Advanced Internet Technologies

Advanced Internet Technologies 11

XSL Tag Attributes

Static XSL tag attributes must follow the same syntax rules as XML and XHTML tag attributes.

XSL allows tag attributes to be added dynamically with the <xsl:attribute> tag.

Dynamic attribute values can be extracted and set with the <xsl:value-of> tag.

Page 12: Unit 3 — Advanced Internet Technologies

Advanced Internet Technologies 12

XSL Conditional Tags

All programming languages include “if” statements.

XSL supports conditional processing with the <xsl:if> tag.

The condition is specified in the test attribute of the <xsl:if> tag.

<xsl:if> tags can determine whether a particular XML data element is present or not.

Page 13: Unit 3 — Advanced Internet Technologies

Advanced Internet Technologies 13

Summary

You created simple XML/XSL Web pages. You understand what an Xpath is and how to

use it. You used the <xsl:value-of> tag to extract and

display XML data. You used the <xsl:attribute> tag to make Web

content dynamic.

Page 14: Unit 3 — Advanced Internet Technologies

Advanced Internet Technologies 14

Summary (cont.)

You used the <xsl:for-each> tag to display XML data repetitively.

You used the <xsl:if> tag for conditional XML data processing.