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

Re: use choose in call-templates not possble

Subject: Re: use choose in call-templates not possble
From: henry human <henry_human@xxxxxxxx>
Date: Thu, 10 May 2012 14:55:54 +0100 (BST)
Re:  use choose in call-templates not possble
Thanks, It helps!
regards
H

----- Urspr|ngliche Message -----
Von: G. Ken
Holman <gkholman@xxxxxxxxxxxxxxxxxxxx>
An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx;
"xsl-list@xxxxxxxxxxxxxxxxxxxxxx" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
CC:
Gesendet: 14:33 Donnerstag, 10.Mai 2012
Betreff: Re:  use choose in
call-templates not possble

At 2012-05-10 13:25 +0100, henry human wrote:
>   
<xsl:variable name="Fcfactor">
>      <xsl:call-template name="translateDcml">
>      <xsl:choose>
>      <xsl:when test="FCDecimalPlace  != ''">
> 
> 
>   
    <xsl:with-param name="factor" select="FCDecimalPlace"/>
> 
>     
<xsl:otherwise>
>      <xsl:with-param name="factor" select="LCDecimalPlace"/>
>        </xsl:otherwise>
>        </xsl:choose>
>      </xsl:call-template>
>      </xsl:variable>

You do not show how you are working with $factor and
that affects the answer. You are passing a node in your old code.

If you need
a node in the function, then the ways are:

In XSLT 1:

  <xsl:variable
name="Fcfactor">
      <xsl:choose>
        <xsl:when test="FCDecimalPlace  !=
''">
          <xsl:call-template name="translateDcml">
           
<xsl:with-param name="factor" select="FCDecimalPlace"/>
         
</xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
         
<xsl:call-template name="translateDcml">
            <xsl:with-param
name="factor" select="LCDecimalPlace"/>
          </xsl:call-template>
       
</xsl:otherwise>
      </xsl:choose>
  </xsl:variable>

In XSLT 2:

 
<xsl:variable name="Fcfactor">
    <xsl:call-template name="translateDcml">
 
      <xsl:with-param name="factor" as="node()">
          <xsl:choose>
     
      <xsl:when test="FCDecimalPlace  != ''">
            <xsl:sequence
select="FCDecimalPlace"/>
            </xsl:when>
            <xsl:otherwise>
            <xsl:sequence select="LCDecimalPlace"/>
           
</xsl:otherwise>
          </xsl:choose>
      </xsl:with-param>
   
</xsl:call-template>
  </xsl:variable>

If you need only the value to be
passed then this works with both XSLT 1 and XSLT 2 by passing a temporary tree
with the value:

  <xsl:variable name="Fcfactor">
    <xsl:call-template
name="translateDcml">
        <xsl:with-param name="factor">
         
<xsl:choose>
            <xsl:when test="FCDecimalPlace  != ''">
           
<xsl:value-of select="FCDecimalPlace"/>
            </xsl:when>
           
<xsl:otherwise>
            <xsl:value-of select="LCDecimalPlace"/>
         
  </xsl:otherwise>
          </xsl:choose>
      </xsl:with-param>
   
</xsl:call-template>
  </xsl:variable>

The whole key is to put the choice
inside the value of the parameter.

I hope this helps.

. . . . . . . . . Ken
--
Public XSLT, XSL-FO, UBL and code list classes in Europe -- Oct 2012
Contact us for world-wide XML consulting and instructor-led training
Free
5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm
Crane
Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman 
                mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Google+ profile:
https://plus.google.com/116832879756988317389/about
Legal business
disclaimers:    http://www.CraneSoftwrights.com/legal

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.