XML

Workshop

The Workshop is designed to help you anticipate possible questions, review what you've learned, and begin learning how to put your knowledge into practice.

Quiz

1.

What is the difference between instructions and literals in XSLT style sheets?

2.

What is the significance of a forward slash (/) when used by itself in the match attribute of an XSLT element such as xsl:template?

3.

If you use the xsl:choose, xsl:when, and xsl:otherwise elements to create a conditional section of a style sheet, when does the code within the xsl:otherwise element get carried out?

4.

How do you reference the current node in the select attribute of an XSLT element such as xsl:value-of?

Quiz Answers

1.

Instructions are the XSLT elements and attributes that describe how XML content is to be transformed, whereas literals are static pieces of information that are placed directly in the output document without being processed.

2.

A forward slash (/) identifies the root node of a document when specified in the match attribute of an XSLT element such as xsl:template.

3.

The code in an xsl:otherwise element gets carried out when none of the xsl:when conditionals apply.

4.

A period (.) is used to reference the current node in the select attribute of an XSLT element such as xsl:value-of.

Exercises

1.

Modify the vehicles.xml document so that it includes several more vehicles of varying model years and prices. Open the document in a web browser to see how the vehicles.xsl style sheet automatically sorts the vehicles, identifies the vehicles with low mileage and CARFAX guarantees, and calculates an average price.

2.

Modify the vehicles.xsl style sheet so that only vehicles with model years greater than or equal to 2005 are highlighted. Hint: You must use the >= comparison operator to determine if each vehicle's year attribute is greater than or equal to 2005.

by BrainBellupdated
Advertisement: