I have to to modify an XML document using XSLT. Here the problem is: I have to modify the XML based on the node values of the another XML file. I have to use the following condition framed using the second XML.
//ClaimSystemConfig/Amisys/WADL/services/service[name='memberSummary' and version=3]
First xml:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP:Body>
<performJob loadfromcache="yes">
<jobName>PQLegacySecurity</jobName>
<whiteboard>
<PQ>
<LegacySecurity>
<businessArea>CSAAQA</businessArea>
<LegacySystem>Amisys</LegacySystem>
<LegacyUserID>test</LegacyUserID>
<LegacyPassword>test@123</LegacyPassword>
<OtherLogin />
<OtherPassword />
<AddSecurLogin />
<AddSecurPassword />
</LegacySecurity>
</PQ>
</whiteboard>
<requestNodeName>//PQ</requestNodeName>
<responseNodeName>//PQ</responseNodeName>
<jobDB>
<name>PQCustomerService</name>
<userID>sa</userID>
<password>password</password>
</jobDB>
</performJob>
</SOAP:Body>
</SOAP:Envelope>
Second xml:
<?xml version="1.0" encoding="UTF-8"?>
<ClaimSystemConfig>
<MHC>
<businessArea>Test2</businessArea>
</MHC>
<MHC>
<businessArea>Test1</businessArea>
</MHC>
<PowerSTEPP>
<businessArea>Test3</businessArea>
</PowerSTEPP>
<Amisys>
<businessArea>CSAAQA</businessArea>
<WADL>
<url>Blah</url>
<services>
<service>
<name>authSearch</name>
<tenant>rest/clientd/</tenant>
<version>1</version>
</service>
<service>
<name>memberSearch</name>
<tenant>rest/clientd/</tenant>
<version>1</version>
</service>
<service>
<name>memberSummary</name>
<tenant>rest/clientd/</tenant>
<version>3</version>
</service>
</services>
</WADL>
</Amisys>
</ClaimSystemConfig>
XSLT code(something like below):
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<PQClaimSystemRequest>
<xsl:apply-templates select="//LegacySecurity" />
</PQClaimSystemRequest>
</xsl:template>
<xsl:template match="LegacySecurity">
<request>
<USERID>
<xsl:value-of select="LegacyUserID" />
</USERID>
<PASSWORD>
<xsl:value-of select="LegacyPassword" />
</PASSWORD>
<xsl:copy-of select="OtherLogin" />
<xsl:copy-of select="OtherPassword" />
<xsl:copy-of select="AddSecurLogin" />
<xsl:copy-of select="AddSecurPassword" />
<system>
<xsl:value-of select="LegacySystem" />
</system>
<xsl:copy-of select="businessArea" />
<xsl:choose>
<xsl:when test="LegacySystem = 'Amisys'">
<xsl:choose>
<xsl:when test="//ClaimSystemConfig/Amisys/WADL/services/service[name='memberSummary' and version=3]">
<type>WADL</type>
<METHOD>POST</METHOD>
<service>memberSummary</service>
<requestSpecific>healthplan/memberstatuses</requestSpecific>
<inputSchema>
<ver:routeData xmlns:ver="version3" />
</inputSchema>
<parms>
<parm>
<name>eao</name>
<value>
<xsl:value-of select="eao" />
</value>
</parm>
</parms>
</xsl:when>
<xsl:otherwise>
<type>WADL</type>
<METHOD>GET</METHOD>
<service>memberSummary</service>
<requestSpecific>healthplan/memberstatuses</requestSpecific>
<parms>
<parm>
<name>eao</name>
<value>
<xsl:value-of select="eao" />
</value>
</parm>
<parm>
<name>codeMatch</name>
<value />
</parm>
<parm>
<name>descriptionMatch</name>
<value />
</parm>
</parms>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
</request>
</xsl:template>
</xsl:stylesheet>
The condition //ClaimSystemConfig/Amisys/WADL/services/service[name='memberSummary' and version=3]
must be passed for the second xml to go inside the when
Please let me know if my question is not clear.