Re: [xslt] Passing parameters within <xsl:apply-templates>



On Sunday Aug 17 2003 at 22:29 Vitaly Ostanin wrote:
> Hello, All!
>
> I need to pass parameters within <xsl:apply-templates>. As far as
I understand, it's allowed by
> http://www.w3.org/TR/xslt#section-Passing-Parameters-to-Templates
and not deprecated by XSLT errata:
> http://www.w3.org/1999/11/REC-xslt-19991116-errata/
>
> Attached test contains simple test for passing params but it not
works for me.

I think the problem is with your stylesheet (test.xsl).  You have
three templates - let's call them templ1, templ2 and templ3, named
in the order they appear.  When you execute test.xsl, eventually
templ3 is applied to test.xml, and the 'document' causes test1.xml
to be used.  templ3 then does an apply-templates with-param with
mode="images".  This causes templ2 to be applied, but templ2 does
not have a param, and when it does a further apply-templates no
param is is specified.  So, when temp1 finally is used, there is no
parameter set, and it correctly uses a null value.

It's a little difficult for me to guess what you are trying to
accomplish with this stylesheet, but you can probably fix your
problem by changing templ2 to be:

<xsl:template match="*|@*|text()" mode="images">
  <xsl:param name="dir"/>
  <xsl:apply-templates mode="images">
    <xsl:with-param name="dir" select="$dir"/>
  </xsl:apply-templates>
</xsl:template>

Also please note that there was a somewhat different problem with
parameters which I recently fixed
(http://bugzilla.gnome.org/show_bug.cgi?id=114563) which also
affects this, so please use the CVS version of libxslt until the
next release.

Regards,
Bill





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