I have an xml, expecting an processed xml via XSLT. Here, I could generate the xml by applying template and now I want to use this template output as an input(dynamically) for the another input within the same XSL.
i.e. I want to pass the current output as input to the template output2.
Output1 : first Template, resulting R1
Output2 : second Template, needs to generate the final output.
INPUT XML
<rules>
<emie>
<domain exclude="true">sww-epw3.testing.com</domain>
<domain>sww-epw3.testing.com
<path docMode="7" comment="APEXID:102994;AppName:Physical Records Management;StepOut:22 May 2015;StepIn:22 May 2016;Requester:Per Roseth;BusinessUnit:Upstream;PortfolioManager:Junfeng Liang">/Apps/dsprm</path>
<path docMode="7" comment="APEXID:102994;AppName:Physical Records Management;StepOut:22 May 2015;StepIn:22 May 2016;Requester:Per Roseth;BusinessUnit:Upstream;PortfolioManager:Junfeng Liang">/Apps/uaprm</path>
<path docMode="7" comment="APEXID:102994;AppName:Physical Records Management;StepOut:22 May 2015;StepIn:22 May 2016;Requester:Per Roseth;BusinessUnit:Upstream;PortfolioManager:Junfeng Liang">/Apps/ptprm</path>
<path docMode="7" comment="APEXID:141923;MyRequestID:7512579;AppName:Production Revenue Accounting-PRA;StepOut:4 March 2016;StepIn:28 February 2017;Requester:[email protected];BusinessUnit:UI;PortfolioManager:[email protected];Remarks:On Board Application">/apps/doto</path>
<path docMode="7" comment="APEXID:;MyRequestID:7219068;AppName:;StepOut:9 December 2015;StepIn:;Requester:[email protected];BusinessUnit:UA;PortfolioManager:;Remarks:Technical Assessment">/apps/seprm</path>
<path docMode="7" comment="APEXID:;MyRequestID:7219068;AppName:;StepOut:9 Dec 2015;StepIn:;Requester:[email protected];BusinessUnit:UA;PortfolioManager:;Remarks:Technical Assessment">/apps/gfprm</path>
</domain>
</emie>
</rules>
**XSLT **
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:output method="xml" encoding="utf-8" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:copy-of select="$R2"/>
</xsl:template>
<xsl:variable name="R1">
<xsl:call-template name="output1" />
</xsl:variable>
<xsl:variable name="R2">
<xsl:call-template name="output2" />
</xsl:variable>
<xsl:template name="output2">
<xsl:element name="DOMAIN">
<xsl:element name="APEXID"></xsl:element>
<xsl:element name="MYREQUESTID"></xsl:element>
<xsl:element name="APPLICATION_NAME"></xsl:element>
<xsl:element name="URL"></xsl:element>
<xsl:element name="MODE"></xsl:element>
<xsl:element name="STEPOUT"></xsl:element>
<xsl:element name="STEPIN"></xsl:element>
<xsl:element name="BU"></xsl:element>
<xsl:element name="PORTFOLIO_MGR"></xsl:element>
<xsl:element name="REMARKS"></xsl:element>
<xsl:element name="RAG_STATUS"></xsl:element>
<xsl:element name="APEX_DATA_PORTAL_URL"></xsl:element>
</xsl:element>
</xsl:template>
<xsl:template name="output1">
<xsl:variable name="site">
<xsl:value-of select="rules/emie/domain/text()"/>
</xsl:variable>
<emie>
<xsl:for-each select="rules/emie/domain/path">
<domain>
<xsl:element name="URL">
<xsl:value-of select="concat($site,text())" />
</xsl:element>
<xsl:apply-templates select="@comment"/>
</domain>
</xsl:for-each>
<xsl:for-each select="domain">
<domain>
<xsl:element name="URL">
<xsl:value-of select="concat($site,text())" />
</xsl:element>
<xsl:apply-templates select="@comment"/>
</domain>
</xsl:for-each>
</emie>
</xsl:template>
<xsl:template match="@comment" name="tokenize">
<xsl:param name="text" select="."/>
<xsl:param name="separator" select="';'"/>
<xsl:param name="separator2" select="':'"/>
<xsl:choose>
<xsl:when test="not(contains($text, $separator))">
<xsl:choose>
<xsl:when test="(contains($text, $separator2))">
<xsl:variable name="token" select="normalize-space(substring-before($text, $separator2))" />
<xsl:element name="{$token}">
<xsl:value-of select="normalize-space(substring-after($text, $separator2))"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="AppName">
<xsl:value-of select="$text"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="tokenize">
<xsl:with-param name="text" select="substring-before($text, $separator)"/>
</xsl:call-template>
<xsl:call-template name="tokenize">
<xsl:with-param name="text" select="substring-after($text, $separator)"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
CURRENT OUTPUT
<emie>
<domain>
<URL>sww-epw3.testing.com/Apps/dsprm</URL>
<APEXID>102994</APEXID>
<AppName>Physical Records Management</AppName>
<StepOut>22 May 2015</StepOut>
<StepIn>22 May 2016</StepIn>
<Requester>Per Roseth</Requester>
<BusinessUnit>Upstream</BusinessUnit>
<PortfolioManager>Junfeng Liang</PortfolioManager>
</domain>
<domain>
<URL>sww-epw3.testing.com/Apps/uaprm</URL>
<APEXID>102994</APEXID>
<AppName>Physical Records Management</AppName>
<StepOut>22 May 2015</StepOut>
<StepIn>22 May 2016</StepIn>
<Requester>Per Roseth</Requester>
<BusinessUnit>Upstream</BusinessUnit>
<PortfolioManager>Junfeng Liang</PortfolioManager>
</domain>
<domain>
<URL>sww-epw3.testing.com/Apps/ptprm</URL>
<APEXID>102994</APEXID>
<AppName>Physical Records Management</AppName>
<StepOut>22 May 2015</StepOut>
<StepIn>22 May 2016</StepIn>
<Requester>Per Roseth</Requester>
<BusinessUnit>Upstream</BusinessUnit>
<PortfolioManager>Junfeng Liang</PortfolioManager>
</domain>
<domain>
<URL>sww-epw3.testing.com/apps/doto</URL>
<APEXID>141923</APEXID>
<MyRequestID>7512579</MyRequestID>
<AppName>Production Revenue Accounting-PRA</AppName>
<StepOut>4 March 2016</StepOut>
<StepIn>28 February 2017</StepIn>
<Requester>[email protected]</Requester>
<BusinessUnit>UI</BusinessUnit>
<PortfolioManager>[email protected]</PortfolioManager>
<Remarks>On Board Application</Remarks>
</domain>
<domain>
<URL>sww-epw3.testing.com/apps/seprm</URL>
<APEXID></APEXID>
<MyRequestID>7219068</MyRequestID>
<AppName></AppName>
<StepOut>9 December 2015</StepOut>
<StepIn></StepIn>
<Requester>[email protected]</Requester>
<BusinessUnit>UA</BusinessUnit>
<PortfolioManager></PortfolioManager>
<Remarks>Technical Assessment</Remarks>
</domain>
<domain>
<URL>sww-epw3.testing.com/apps/gfprm</URL>
<APEXID></APEXID>
<MyRequestID>7219068</MyRequestID>
<AppName></AppName>
<StepOut>9 Dec 2015</StepOut>
<StepIn></StepIn>
<Requester>[email protected]</Requester>
<BusinessUnit>UA</BusinessUnit>
<PortfolioManager></PortfolioManager>
<Remarks>Technical Assessment</Remarks>
</domain>
</emie>
EXPECTED OUTPUT- Need to include more new elements and process the data of input xml (output1) e.g date formating
<emie><domain>
<URL>sww-epw3.testing.com/apps/gfprm</URL>
<APEXID></APEXID>
<MyRequestID>7219068</MyRequestID>
<AppName></AppName>
<StepOut>9 Dec 2015</StepOut>
<StepIn></StepIn>
<Requester>[email protected]</Requester>
<BusinessUnit>UA</BusinessUnit>
<PortfolioManager></PortfolioManager>
<Remarks>Technical Assessment</Remarks> <APEX_DATA_PORTAL_URL>somesite</APEX_DATA_PORTAL_URL>
</domain>
<domain>
<URL>sww-epw3.testing.com/apps/gfprm</URL>
<APEXID></APEXID>
<MyRequestID>7219068</MyRequestID>
<AppName></AppName>
<StepOut>9 Dec 2015</StepOut>
<StepIn></StepIn>
<Requester>[email protected]</Requester>
<BusinessUnit>UA</BusinessUnit>
<PortfolioManager></PortfolioManager>
<Remarks>Technical Assessment</Remarks> <APEX_DATA_PORTAL_URL>somesite</APEX_DATA_PORTAL_URL>
</domain>
<domain>
<URL>sww-epw3.testing.com/apps/gfprm</URL>
<APEXID></APEXID>
<MyRequestID>7219068</MyRequestID>
<AppName></AppName>
<StepOut>9 Dec 2015</StepOut>
<StepIn></StepIn>
<Requester>[email protected]</Requester>
<BusinessUnit>UA</BusinessUnit>
<PortfolioManager></PortfolioManager>
<Remarks>Technical Assessment</Remarks> <APEX_DATA_PORTAL_URL>somesite</APEX_DATA_PORTAL_URL>
</domain></emie>