The XSLT processing model: processing children

So what did we just do? We applied a template, which entails putting out the output elements, writing out any literal text (in this case <head><title>Test Document</head></title>). The next step is to process the children of the matched element, but only if xsl:apply-templates element is present!

Since there is the xsl:apply-templates, take a minute to think about:

  • what element is matched in this scenario?
  • what are the children?
  • how would we process those children?

We will discuss the answers to these questions below.

In this case, the TEI element is matched. And since the xsl:apply-templates element is present we do process the children.

The only child of TEI is text in this example. Note that there is no template that matches text in our stylesheet. However, the process doesn’t stop there. When no template is matched for the child of a given element, the stylesheet uses built-in processing rules that instruct that we spit out any text and process any children.

The first child of text in this case is front So what happens here? You will notice that the xsl:template that matches front has no content (and therefore no xsl:apply-templates). This signifies to the processor that the front element should be ignored, and no children should be processed. Therefore, nothing correlating to front appears in the output document.

The processor will then move to the next child of text, which will be discussed in the next slide.

The XSLT Processing Model, slide 4 of 10