[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Problem in XSL transformation


Subject: [xsl] Problem in XSL transformation
From: <Ambika.Das@xxxxxxxxxxxxxxxxxx>
Date: Wed, 6 Sep 2006 14:05:05 +0530

Hi All,

We want to transform a particular XML file which contains elements in a loop.
We want to append a symbol as the header for each iteration. The symbol list
is a string which contains individual symbols separated by pipeline (|).

For example, if the symbol list is abc|def, in first iteration we want abc as
the header and in the second iteration, we want def as the header. The code
which we are using is as follows.


<xsl:template name="add_symbol_to_output">

     <xsl:param name="str"/>
      <xsl:choose>
        <xsl:when test="contains($str,'|')">
          <xsl:value-of
    		select="substring-before($str,'|')"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$str"/>
        </xsl:otherwise>
      </xsl:choose>

    </xsl:template>

<xsl:for-each select="root/firstChild">

 	<xsl:variable name="inputParam" select="$inputSymbol"/>

  	<xsl:call-template name="add_symbol_to_output">
              	<xsl:with-param name="str" select="$inputParam"/>
  	</xsl:call-template>

  	<xsl:variable name="inputSymbol"
select="substring-after($inputSymbol,'|')"/>

	  					<xsl:text>,</xsl:text>
	  					<xsl:value-of select="fid[@id='SAMPLEID_1']"/>
	  					<xsl:text>,</xsl:text>

We are getting the same header, i.e. abc for all iterations.

Any clues?



Thanks & Regards,
Ambika Prasad Das
 


Current Thread
Keywords
xml