xsl code question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mikael Petterson

    #1

    xsl code question

    Hi,

    I am trying to produce the following in javacode;

    public void action<An actionName>(Str ing value1, int value
    2....,Coordinat or 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?

    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>
    <raisesExceptio n name="InternalE rrorException"/>
    <raisesExceptio n name="MoDisable dException"/>
    <raisesExceptio n name="AlreadyAc tiveException"/>
    </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="returnTyp e/void">
    public void action<xsl:call-template name="CapFirstL etterOfAttr">
    <xsl:with-param name="x"
    select="@name"/></xsl:call-template><xsl:i f test="parameter ">
    <xsl:for-each select="paramet er">
    <xsl:apply-templates select="paramet er"/>
    </xsl:for-each>
    </xsl:if>
    (Coordinator c) throws MoAccessExcepti on<xsl:if
    test="raisesExc eption">
    <xsl:text>,</xsl:text></xsl:if><xsl:tex t>
    </xsl:text><xsl:f or-each select="raisesE xception"><xsl: value-of
    select="@name"/>
    <xsl:if test="not(posit ion()=last())"> ,<xsl:text>
    </xsl:text> </xsl:if></xsl:for-each>;
    </xsl:when>
    <xsl:when test="returnTyp e/structRef">
    public Struct action<xsl:call-template name="CapFirstL etterOfAttr">
    <xsl:with-param name="x"
    select="@name"/></xsl:call-template>(Coord inator c) throws
    MoAccessExcepti on<xsl:if test="raisesExc eption">
    <xsl:text>,</xsl:text></xsl:if><xsl:tex t>
    </xsl:text><xsl:f or-each select="raisesE xception"><xsl: value-of
    select="@name"/>
    <xsl:if test="not(posit ion()=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="paramete r">
    <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>

Working...