Precedence for Rules

Before we move on and examine some of the more advanced features of XSL, we need to look at one more topic—precedence. Precedence is a simple idea, really, that defines the order in which we will apply a rule, given that two rules match an input. For example, the following two rules each match Listing elements.

<xsl:template match ='Listing'...</xsl:template>

and

<xsl:template match ='//Listing'...</xsl:template>

Which would win if we were processing an XSL stylesheet? What if one of the rules were from an imported stylesheet? Would that matter? In this section we will find out.

xsl:import and Import Precedence

As we discussed at the very beginning of this chapter, XSLT supports importing other stylesheets via xsl:import ...

Get XML Development with Java™ 2 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.