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

xsl question

Subject: xsl question
From: "Mikael Petterson (KI/EAB)" <mikael.petterson@xxxxxxxxxxxx>
Date: Wed, 1 Oct 2003 08:22:18 +0200
xsl if test parameter
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 question
    • Mikael Petterson (KI/EAB) - Wed, 1 Oct 2003 02:24:52 -0400 (EDT) <=
      • mr . g - Wed, 1 Oct 2003 02:50:36 -0400 (EDT)

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.