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]

Problem with conditional parameter in call-template


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@cesca.es>


 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]