Sammy
Sammy

Reputation: 121

Why I am not getting the value

My input XML is:

<urp>

    <pRespId>2345</pRespId>
    <pRespApplId>800</pRespApplId>
    <pSecurityGroupID>0</pSecurityGroupID>

</urp>

I am trying to populate some variable value using the below XSL:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="/">
        <xsl:variable name="pRespId" select="urp/pRespId" />
        <xsl:variable name="pRespApplId" select="urp/pRespApplId" />
        <xsl:variable name="pSecurityGroupID" select="urp/pSecurityGroupID" />
        <xsl:variable name="newURI" select = "'pRespId=$pRespId&amp;pRespApplId=$pRespApplId&amp;pSecurityGroupID=$pSecurityGroupID'"/>
    </xsl:template>

</xsl:stylesheet>

But somehow I am not able to get the of pRespId, pRespApplId & pSecurityGroupID in newURI. It is always showing me

pRespId=$pRespId&pRespApplId=$pRespApplId&pSecurityGroupID=$pSecurityGroupID

Instead of:

pRespId=2345&pRespApplId=800&pSecurityGroupID=0

I know I am missing something in this line:

<xsl:variable name="newURI" select = "'pRespId=$pRespId&amp;pRespApplId=$pRespApplId&amp;pSecurityGroupID=$pSecurityGroupID'"

Can someone rectify what I am missing here?

Upvotes: 0

Views: 34

Answers (1)

Tim C
Tim C

Reputation: 70648

Your variable newURI is just setting a string value. It is not going to evaluate any variable references in the string.

You could try using the concat function and have separate arguments for the variables you want to evaluate

<xsl:variable
     name="newURI" 
     select="concat('pRespId=', $pRespId, '&amp;pRespApplId=', $pRespApplId, '&amp;pSecurityGroupID=', $pSecurityGroupID)"/>

Upvotes: 1

Related Questions