Templates

The body of the stylesheet consists of at least one transformation rule, as represented by the Template element:

<template ... >
  ...
</template>

In practice, a stylesheet typically contains a large number of rules, each one defining the transformation to be applied to a specific element in the source document, using the Match attribute, which contains an XPath expression. The following example demonstrates two rules: one for all Paragraph elements, and one for Emphasis elements:

<template match="para">
  ...
</template>

<template match="emph">
  ...
</template>

Multiple element template

When the same transformation rules apply to a number of elements, it is convenient to be able to use the same template for all the elements concerned. ...

Get XML Companion, The, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.