Namespaces in input documents

Documents to be processed using an XSLT processor may already conform to the namespaces standard, perhaps because they contain elements from more than one namespace.

The stylesheet needs to be able to distinguish between elements from different namespaces when selecting templates. This is simply done by including the prefix in the Match attribute:

   <widget>normal widget</widget>
   <acme:widget>an ACME widget</acme:widget>


<template match="widget">
  <!-- PROCESS NORMAL WIDGETS -->
</template>
<template match="acme:widget">
  <!-- PROCESS ACME WIDGETS -->
</template>

Although these prefixes are not attached to any elements within the stylesheet, the stylesheet must nevertheless contain a suitable namespace declaration ...

Get XSL companion, The 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.