This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Stuck on meta-stylesheet problem


Hi Charles,

> In order to get through the first transformation with my product stylesheet
> parameter declarations intact, I pull this little kludge in the first
> stylesheet:
>
>         <xsl:variable name="v_updateProc">$updateProc</xsl:variable>
>         <xsl:variable name="v_canEdit"><xsl:copy-of
> select="concat('{$','canEdit}')" /></xsl:variable>
>         <xsl:variable name="v_script"><xsl:copy-of
> select="concat('{$','script}')" /></xsl:variable>
>         <xsl:variable name="v_css"><xsl:copy-of
> select="concat('{$','css}')" /></xsl:variable>
>         <xsl:variable name="v_class"><xsl:copy-of
> select="concat('{$','class}')" /></xsl:variable>

Assuming you always treat these variables as strings (rather than as
result tree fragments that you convert to node sets), these are
exactly the same as:

  <xsl:variable name="v_updateProc" select="'$updateProc'" />
  <xsl:variable name="v_canEdit" select="'{$canEdit}'" />
  <xsl:variable name="v_script" select="'{$script}'" />
  <xsl:variable name="v_css" select="'{$css}'" />
  <xsl:variable name="v_class" select="'{$class}'" />

> My problem comes with the "canEdit" parameter. I wish to use its value
> to determine whether or not to call a particular template.

It's easiest if you work backwards. In the XSLT that's the result of
your first stylesheet, you want to have:

  <xslt:if test="$canEdit = 'true'">
    <xslt:call-template name="saveButton" />
  </xslt:if>

You want the "$canEdit" part of the test to be provided from the
$v_canEdit variable in the stylesheet that's generating this XSLT. So
the $v_canEdit variable needs to be set to the string '$canEdit':

  <xsl:variable name="v_canEdit" select="'$canEdit'" />

and the test attribute of the xslt:if literal result element needs to
contain an attribute value template that inserts the value of the
$v_canEdit variable in place of the "$canEdit" part of the test:

  <xslt:if test="{$v_canEdit} = 'true'">
    <xslt:call-template name="saveButton" />
  </xslt:if>

You say that you've tried this; all I can tell you is that it should
work. If it doesn't, try checking the result that you *are* getting to
see what XSLT you're generating to make sure that it's the XSLT you
think you're generating, and try running that XSLT alone (and editing
it as necessary) to see what that XSLT needs to be in order to work.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]