140 likes | 244 Views
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 <xsl:value-of> tag to extract and display XML data. Use the <xsl:attribute> tag to make Web content dynamic.
E N D
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 <xsl:value-of> tag to extract and display XML data. • Use the <xsl:attribute> tag to make Web content dynamic. Advanced Internet Technologies
Objectives (cont.) • Use the <xsl:for-each> tag to display XML data repetitively. • Use the <xsl:if> tag for conditional XML data processing. Advanced Internet Technologies
XSL Basics • XSL stands for XML Stylesheet Language. • XSL was designed to be a companion technology to XML. Advanced Internet Technologies
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. Advanced Internet Technologies
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]”?> Advanced Internet Technologies
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. Advanced Internet Technologies
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. Advanced Internet Technologies
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. Advanced Internet Technologies
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> Advanced Internet Technologies
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. Advanced Internet Technologies
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. Advanced Internet Technologies
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. Advanced Internet Technologies
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. Advanced Internet Technologies