Parsing xsl variable to another xsl variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phpmagesh
    New Member
    • Nov 2008
    • 119

    #1

    Parsing xsl variable to another xsl variable

    Hi all,

    I am trying to pharse a xsl variable like below

    declared xsl variables like
    Code:
    <xsl:variable name="USD">
        <xsl:value-of select="'$'" />
      </xsl:variable>
    <xsl:variable name="EUR">
        <xsl:value-of select="'€'" />
      </xsl:variable>
    My xslt file will have below value to get the above declared values

    Code:
    file name: xsltest.xsl
    <xsl:variable name="code" select="string(src:currencyCode)" />
    <xsl:value-of disable-output-escaping="yes" select="'$' + code"/>
    and my payload is given below

    Code:
    file name: test.xml
    <src:Testmessage xmlns:src="testtemplate">
      <src:currencyCode>USD</src:currencyCode>
    </src:Testmessage>
    when i am trying to do is, i want the get the currencycode by phrasing xsl with xml?

    if my currency code is USD the i have to display as --> $

    based on the currencycode xml value i have to get the result here.

    can anyone help in to sort out this problem,

    Thanks in advance,

    Regards,
    Magesh
    Last edited by phpmagesh; Sep 30 '10, 01:40 PM. Reason: xsl:value-of value changed
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    You can't dynamically access variables, but you can do something like this:
    Code:
    <my:mapping xmlns:my="internal">
      <currency type="USD" symbol="$"/> 
      <currency type="EUR" symbol="€"/> 
    </my:mapping>
    
    <xsl:value-of select="document('')//currency[@type=$code]/@symbol"/>
    my namespace chosen randomly.

    Comment

    Working...