[xsl] xsl question

Subject: [xsl] xsl question
From: "Mikael Petterson (KI/EAB)" <mikael.petterson@xxxxxxxxxxxx>
Date: Wed, 1 Oct 2003 08:22:18 +0200
Hi,

I am trying to produce the following in javacode;

public void action<An actionName>(String value1, int value 
2....,Coordinator c) throws Exception;

The arguments to the actionXXX could be from only a Coordiantor and up 
to any number of int:s and Strings before ( however not to many in 
practice).

My problem is when I have found the parameter element (that is, extra 
parameters besides the Coordinator) is it possible "produce" the extra
parameters within the (......................) ? Is it a good idea to 
have it in a separate template? When I run my transformation it seems 
like I never get to the parameter template. Any ideas why? Can I use the <xsl:for-each>
to check if there is a parameter or must I have the <xsl:if>?

All help and time spent on this matter is greatly appreciated.

//Mikael

an action in xml file could look like this:
===========================================
<action name="startPn">
             <description>PN generation is started on Pch and pnlsActive 
is set TRUE.Ref. [FS_UPT]</description>
             <returnType>
                 <void/>
             </returnType>
             <parameter name="pnTfi">
                 <in/>
                 <dataType>
                     <long/>
                 </dataType>
             </parameter>
             <raisesException name="InternalErrorException"/>
             <raisesException name="MoDisabledException"/>
             <raisesException name="AlreadyActiveException"/>
         </action>
xsl template for action looks like this ( from row 7)
=====================================================

<xsl:template match="action" mode="action">
  <xsl:for-each select=".">
      <xsl:choose>
       <xsl:when test="returnType/void">
     public void action<xsl:call-template name="CapFirstLetterOfAttr">
      <xsl:with-param name="x" 
select="@name"/></xsl:call-template><xsl:if test="parameter">
       <xsl:for-each select="parameter">
        <xsl:apply-templates select="parameter"/>
       </xsl:for-each>
       </xsl:if>
      (Coordinator c) throws MoAccessException<xsl:if 
test="raisesException">
      <xsl:text>,</xsl:text></xsl:if><xsl:text>
      </xsl:text><xsl:for-each select="raisesException"><xsl:value-of 
select="@name"/>
      <xsl:if test="not(position()=last())">,<xsl:text>
      </xsl:text> </xsl:if></xsl:for-each>;
         </xsl:when>
       <xsl:when test="returnType/structRef">
     public Struct action<xsl:call-template name="CapFirstLetterOfAttr">
      <xsl:with-param name="x" 
select="@name"/></xsl:call-template>(Coordinator c) throws 
MoAccessException<xsl:if test="raisesException">
      <xsl:text>,</xsl:text></xsl:if><xsl:text>
      </xsl:text><xsl:for-each select="raisesException"><xsl:value-of 
select="@name"/>
      <xsl:if test="not(position()=last())">,<xsl:text>
      </xsl:text> </xsl:if></xsl:for-each>;
       </xsl:when>
       </xsl:choose>
  </xsl:for-each>
</xsl:template>

The template xsl
================

<xsl:template match="parameter">
     <xsl:value-of select="@name"/>
      <xsl:choose>
       <xsl:when test="in/dataType/string">
       Sting <xsl:value-of select="@name"/>,
       </xsl:when>
       <xsl:when test="in/dataType/long">
       int <xsl:value-of select="@name"/>,
       </xsl:when>
      </xsl:choose>
    </xsl:template>



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


Current Thread
  • [xsl] xsl question
    • Mikael Petterson (KI/EAB) - Wed, 1 Oct 2003 08:22:18 +0200 <=
      • mr . g - Wed, 1 Oct 2003 09:50:18 +0300