[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Question about xsl:apply-imports


Subject: [xsl] Question about xsl:apply-imports
From: Bill French <french@xxxxxxxxxxxxx>
Date: Thu, 10 Sep 2009 18:27:28 -0700

Hi all,

xsl:import is pretty awesome, let me say that right off. But it sometimes yields surprising results.

I have a stylesheet called rendereddocument.xsl that imports a number of other stylesheets using the xsl:import instructions:

<xsl:import href="inc/baseline.xsl"/>
<xsl:import href="inc/application-tabs.xsl"/>
<xsl:import href="inc/fields.xsl"/>
<xsl:import href="inc/search-criteria.xsl"/>
<xsl:import href="inc/search-fields.xsl"/>
<xsl:include href="../../override/xslt/customization.xsl"/>

in fields.xsl, I have a template defined as follows:

<xsl:template match="rm:document">
  <xsl:element name="div" namespace="http://www.w3.org/1999/xhtml">
    <xsl:attribute name="class">
      <xsl:text>document</xsl:text>
      <xsl:if test="position() mod 2 = 0">
        <xsl:text> alt</xsl:text>
      </xsl:if>
    </xsl:attribute>
    <xsl:apply-templates select="rm:fields"/>
  </xsl:element>
</xsl:template>

and in rendereddocument.xsl I have two templates that are defined as follows:

<xsl:template match="rm:document" priority="-0.1">
  <rm:content name="rendereddocument.document">
    <xsl:apply-templates select="rm:fields"/>
  </rm:content>
	
  <xsl:apply-templates select="rm:associated"/>
</xsl:template>

<xsl:template match="rm:associated" priority="-0.1">
<rm:content name="{concat('rendereddocument.associated.', ../rm:associated/@name)}">
<div class='component collapsible-component collapsed'>
<div class='component-title'>
<h3><a href='#'><xsl:value-of select="@displayName"/></a></h3>
<ul class='component-action-list'>
<li class='active'><a href='#'>Showing relevant</a></li>
<li class='last'><a href='#'>Show all</a></li>
</ul>
</div>
<div class='component-part component-document-list'>
<xsl:apply-imports/>
</div>
</div>
</rm:content>
</xsl:template>


In the last template, there's an xsl:imports instruction. The element on which this template is matching, rm:associated, has rm:document children. It's my understanding that xsl:apply-imports should elect to apply the xsl:template defined in fields.xsl, not in rendereddocument.xsl. However, this isn't what's happening. Instead, the template matching rm:document defined in rendereddocument.xsl is being applied.

Any help would be most appreciated. Let me know if you need to see all the files. Last time, the issue was glaringly apparent from just the first email. ;)

Best regards,

--Bill F.


Current Thread