[xml] xsl:apply-imports not passing on parameters

I was going to raise this as a bug until I noticed that sablotron and
Xalan do the same. apply-imports is supposed to allow templates to be
modified so it seems quite bad to me that parameters are not passed on

I've cut down the stylesheets I was using but I'll show them here to
demonstrate what I was trying to do:

This is the main stylesheet. The default value for $style in the p
template was actually a complex bit of xsl:choose that I wouldn't want
to duplicate.

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"

  <xsl:template match="p">
    <xsl:param name="style">default</xsl:param>

    <text style="{$style}">

  <xsl:template match="top">
      <xsl:with-param name="style">in top</xsl:with-param>


Now I have another stylesheet which marks up changes:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"

 <xsl:import href="main.xsl"/>

 <xsl:template match="*[ chg]">
    <change-start change-id="{generate-id(.)}"/>
    <change-end change-id="{generate-id(.)}"/>


For the input, try this:

<top><p chg="del">Changed paragraph</p><p>Unchanged paragraph</p></top>

If you compare the two stylesheets, with the second the overriden style
gets lost (and becomes just "default"). This is because apply-imports
does not pass on the $style parameter.

Given that apply-templates is described as a way to override a
template, this really doesn't seem ideal to me. It isn't obvious that
this will happen so it is an easy source of bugs in stylesheets.
xsltproc actually lets me pass $style on with a with-param inside
apply-imports but I think that isn't proper XSLT 1.0.

This will be even more unexpected with XSLT 2.0's xsl:next-match. Do
you agree with me that this is not ideal? Should I be mentioning this
to someone at w3.org? If so, who? 


PS. I'm not subscribed to the list so please copy me in any replies.
(though, I will check the archives). Sorry if this wsn't really the
right place to post this.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]