1

My code was unable to return a value from the input XML. The variable name is mapped in a separate xml based on a string.

Step 1: I need to extract the XML tag from the another mapping XML. (This I got it)

Step 2: XML tag is saved in a variable and using the root tag, I am not able to get the value

This is the XSLT:

    <xsl:template match="SUBSCRIBER">

            <xsl:variable name="expiry_date" select="$docStringAccountMapping/STRING_ACCOUNTS_LIST/STRING_ACCOUNTS_INFO[NSN_STRING='ThirdAccount']/AEXPIRY_DATE"/>

    <!-- this returns a string "EXPIRY_DATE_1" -->

            <xsl:value-of select="SUBSCRIBER/$expiry_date"/>


        </xsl:template>

This is the XML:

    <SUBSCRIBER>
        <EXPIRY_DATE_1>2014-07-09 23:59:59</EXPIRY_DATE_1>
    </SUBSCRIBER>
kjhughes
  • 106,133
  • 27
  • 181
  • 240
Hari
  • 397
  • 1
  • 9
  • 23

1 Answers1

4

First, you probably do not want to select "SUBSCRIBER...anything" if your template is matching SUBSCRIBER. The current node will be a SUBSCRIBER element, so start your XPath from there. Then...

If $expiry_date includes the full element name including the namespace component:

<xsl:value-of select="*[name()= $expiry_date]"/>

If $expiry_date includes only the element's local name excluding the namespace component:

<xsl:value-of select="*[local-name()= $expiry_date]"/>
kjhughes
  • 106,133
  • 27
  • 181
  • 240