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

Problem with conditional parameter in call-template

Subject: Problem with conditional parameter in call-template
From: "Carlos Fragoso Mariscal" <cfragoso@xxxxxxxx>
Date: Tue, 4 Sep 2001 03:47:35 +0200
conditional parameter
Hi again,

Thank you to all of those who answered my
previos questions,my greetings goes to them.

I'm simplifying my xsl code and I faced a
problem. I can't put <xsl:choose> either
<xsl:if> elements inside a <xsl:call-template>
so there is a parameter (the one called tipus)
that should be password when the name of the
node is contrasenya and that should be text
when the node has another name.

Now I have faced the problem doing a when,
otherwise structure that doubles the amount
of code where only the tipus parameter is
different.

         <xsl:choose>
            <xsl:when test="name(.)='contrasenya'">
               <xsl:call-template name='entradaTexte'>
                  <xsl:with-param name='id'>
                     <xsl:value-of select='@id'/>
                  </xsl:with-param>
                  <xsl:with-param name='valor'>
                     <xsl:value-of select='valor'/>
                  </xsl:with-param>
                  <xsl:with-param name='tipus'>
                     <xsl:text>password</xsl:text>
                  </xsl:with-param>
               </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
               <xsl:call-template name='entradaTexte'>
                  <xsl:with-param name='id'>
                     <xsl:value-of select='@id'/>
                  </xsl:with-param>
                  <xsl:with-param name='valor'>
                     <xsl:value-of select='valor'/>
                  </xsl:with-param>
                  <xsl:with-param name='tipus'>
                     <xsl:text>text</xsl:text>
                  </xsl:with-param>
               </xsl:call-template>
            </xsl:otherwise>
         </xsl:choose>

The template called has got the default value for
the paremeter tipus to text so in the otherwise
body I could delete the with-param tag for
parameter tipus.

   <xsl:template name='entradaTexte'>
      <xsl:param name='tipus'>text</xsl:param>
      <xsl:element name='input'>
         <xsl:attribute name='type'><xsl:value-of
select='$tipus'/></xsl:attribute>
         <xsl:attribute name='name'><xsl:value-of
select='$id'/></xsl:attribute>
         <xsl:attribute name='valor'><xsl:value-of
select='$valor'/></xsl:attribute>
      </xsl:element>
   </xsl:template>

Any idea to do only one call-template
having that conditional parameter?
(in this case is only two values but it
 could have more so code will grow up fast)

Thank you in advance!!! :)

---------------------------
Carles Fragoso i Mariscal
Supercomputing Center of Catalonia
Communications & Operations Dept.
E-Mail: <cfragoso@xxxxxxxx>


 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-2007 All Rights Reserved.