[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Stuck on meta-stylesheet problem

Subject: Re: Stuck on meta-stylesheet problem
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 23 May 2002 19:40:29 +0100
xslt if variable
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.