Am I ready for Mulberry's Advanced Document Processing with XSLT 2.0 course?
Mulberry's Fundamentals of XSLT and XPath 3-day course is intended for beginners, but some of our happiest alumni are those who have taken it as a refresher course. Since it focuses on the fundamentals of the XSLT processing model, introduces and explains relevant technical terminology, and presents comprehensive coverage of XPath 1.0 -- all of which can be mysterious to the self-taught or casual XSLT user -- our introductory course offers a strong foundation in XSLT even to programmers who have prior experience.
But many prospective students will not have taken our introduction, and may nevertheless be well prepared for the advanced course. The problem is knowing whether you are in this category, or whether you need a more systematic introductory treatment before you can benefit from (and contribute to) an advanced hands-on treatment.
In order to help you assess whether you are ready for the advanced class, please review the concepts described below (which are covered in the introductory class). Then please take a few minutes to attempt and grade yourself (informally) on the quiz questions offered below. If you can't answer these questions, or if you find the concepts to be novel and disconcerting, please consider taking our Fundamentals of XSLT and XPath before you sign up for the Advanced class.
Core prerequisites for the Advanced XSLT course
All students in our advanced class will be expected to have the following:
-
You should have experience (not just instruction) using XSLT (1.0 or 2.0).
Note: the hands-on exercises in our 3-day introduction may barely qualify as "experience". That is, while the advanced course may be taken directly as a follow-on to our introduction, we recommend this only for programmers with some prior experience. If you are truly new to XSLT, you will probably do better if you can go home and practice the basics before taking the Advanced XSLT Class.
- You understand the XPath/XSLT data model, including the document tree; node types including the root (document) node, element, attribute and text nodes; and XPath terminology expressing the relations between nodes in the tree (parent, sibling, child, descendant, etc.).
- You understand the basic XSLT processing architecture, the differences and relations between parsing, transformation and serialization, and at least the concept of pipelining (chaining) transformations.
- You understand the basic XSLT processing model and core features of the language,
including the use of template rules; the semantics of template match patterns; the
xsl:apply-templates
instruction; modes and named templates; variables and parameters; and how the processor resolves conflicting template rules and handles nodes that have no explicit template rule given. - You have proficiency and some confidence with both absolute and relative XPath (path expressions), awareness of XPath's capabilities, and understanding of how to debug it. You understand axes, predicates (filter expressions), functions and operations, and have some familiarity with the XPath 1.0 function library.
- You have some understanding of the practical limits of XSLT 1.0, and have been exposed to methods of dealing with harder problems such as grouping, string processing, or date and duration processing, using either specialized techniques, methods, and extensions in XSLT 1.0, or other technologies.
- You have the option of using XSLT 2.0, as soon as you learn its features.
A self-assessment quiz
If you answer these questions correctly without cheating, and if you understand (and concur with) the explanations given of the answers here, you are likely ready to take our Advanced Document Processing with XSLT 2.0 course. If you do not, you may want to consider our Fundamentals of XSLT and XPath course instead.
Since some of the questions and answers include code, you may want to print this quiz, mark your answers on the page, and then return and check them against the web page.
Question 1. Translate the following XPath expression into natural language:
title[1]/following-sibling::*
1a. The following siblings of the context node, if the context node is a title.
1b. The first title child (of the context node) with a following sibling.
1c. Every title child that contains the character "1" and has a following sibling.
Question 2.. Here's a little XML document:
<room> <table>t99</table> <chair type="chippendale">Ch4</chair> <chair type="chippendale">Ch33</chair> <chair type="chippendale">Ch1</chair> <chair type="queenanne">QA45</chair> </room>
Which of these results would you expect from processing it with a stylesheet containing (only) these three templates:
<xsl:template match="room"> <ul> <xsl:apply-templates/> </ul> </xsl:template> <xsl:template match="chair"> <li> <xsl:apply-templates/> </li> </xsl:template> <xsl:template match="table | chair[@type='queenanne']"/>
2b.
<room> <ul> <table>t99</table> <chair> <li>Ch4</li> </chair> <chair> <li>Ch33</li> </chair> <chair> <li>Ch1</li> </chair> <chair type="queenanne"> <li>QA45</li> </chair> </ul> </room>
2c.
<ul> <table>t99</table> <li>Ch4</li> <li>Ch33</li> <li>Ch1</li> <chair type="queenanne">QA45</chair> </ul>
Question 3. What results do you expect to see from applying a stylesheet containing no templates to the same source document?
<room> <table>t99</table> <chair type="chippendale">Ch4</chair> <chair type="chippendale">Ch33</chair> <chair type="chippendale">Ch1</chair> <chair type="queenanne">QA45</chair> </room>
3a.
<room> <table>t99</table> <chair type="chippendale">Ch4</chair> <chair type="chippendale">Ch33</chair> <chair type="chippendale">Ch1</chair> <chair type="queenanne">QA45</chair> </room>
Question 4. Which of these is what XSLT developers call an "identity template"? (And what is it used for?)
4a.
<xsl:template match="* | /"> <xsl:apply-templates/> </xsl:template>
4b.
<xsl:template match="*"> <xsl:element name="{name()}"> <xsl:apply-templates/> </xsl:element> </xsl:template>
4c.
<xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template>
Question 5. Which of the following is the best rewrite of this template?
<xsl:template match="div"> <xsl:choose> <xsl:when test="attribute::type='part'"> <sec> <xsl:apply-templates/> </sec> </xsl:when> <xsl:when test="attribute::type='chapter'"> <subsec> <xsl:apply-templates/> </subsec> </xsl:when> <xsl:when test="attribute::type='section'"> <subsec2> <xsl:apply-templates/> </subsec2> </xsl:when> <xsl:otherwise> <sec> <xsl:apply-templates/> </sec> </xsl:otherwise> </xsl:choose> </xsl:template>
5a.
<xsl:template match="div"> <xsl:choose> <xsl:when test="@type=part"> <sec> <xsl:apply-templates/> </sec> </xsl:when> <xsl:when test="@type=chapter"> <subsec> <xsl:apply-templates/> </subsec> </xsl:when> <xsl:when test="@type=section"> <subsec2> <xsl:apply-templates/> </subsec2> </xsl:when> <xsl:otherwise> <sec> <xsl:apply-templates/> </sec> </xsl:otherwise> </xsl:choose> </xsl:template>
5b.
<xsl:template match="div"> <sec> <xsl:apply-templates/> </sec> </xsl:template> <xsl:template match="div[@type='chapter']"> <subsec> <xsl:apply-templates/> </subsec> </xsl:template> <xsl:template match="div[@type='section']"> <subsec2> <xsl:apply-templates/> </subsec2> </xsl:template>
5c.
<xsl:template match="div[not(@type='chapter'|@type='section')]"> <sec> <xsl:apply-templates/> </sec> </xsl:template> <xsl:template match="div[@type='chapter']"> <subsec> <xsl:apply-templates/> </subsec> </xsl:template> <xsl:template match="div[@type='section']"> <subsec2> <xsl:apply-templates/> </subsec2> </xsl:template>
5d.
<xsl:template match="div"> <xsl:when test="@type='chapter'"> <subsec> <xsl:apply-templates/> </subsec> </xsl:when> <xsl:when test="@type='section'"> <subsec2> <xsl:apply-templates/> </subsec2> </xsl:when> <xsl:otherwise> <sec> <xsl:apply-templates/> </sec> </xsl:otherwise> </xsl:template>
XSLT 1.0 and XSLT 2.0
Finally, please note that Mulberry's Advanced XSLT class, unlike the 3-day introduction, is a course in XSLT 2.0. If you are restricted to using XSLT 1.0 and need instruction in it beyond the content covered by our introduction, Mulberry offers customized training and consulting on applying XSLT and related technologies. Please let us know what you need.