I asked a question a few days ago that was answered perfectly but had forgotten to include one crucial requirement which throws a wrench in the selected solution. The question can be found here:
Change output based on value in xsl:key in XSLT 1.0
NEW INPUT XML:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<EligibilityRecords xmlns="http://Eligibility_LSDD">
<Eligibility_Detail_Record xmlns="">
<PT_PARTICIPANT_FILE_IMP_ID></PT_PARTICIPANT_FILE_IMP_ID>
<PT_PARTICIPANT_STATUS>Active</PT_PARTICIPANT_STATUS>
<PT_LST_NM>VALLE</PT_LST_NM>
<PT_FRST_NM>FRANKIE</PT_FRST_NM>
<EN_PLAN_NAME>Health Reimbursement Arrangement</EN_PLAN_NAME>
<EN_MBRSHP_EFF_STRT_DT>01012017</EN_MBRSHP_EFF_STRT_DT>
<EN_MBRSHP_EFF_END_DT></EN_MBRSHP_EFF_END_DT>
<EN_PLAN_YEAR_STRT_DT>01012017</EN_PLAN_YEAR_STRT_DT>
<DP_PARTICIPANT_FILE_IMP_ID></DP_PARTICIPANT_FILE_IMP_ID>
<DP_DEPENDENT_FILE_IMP_ID></DP_DEPENDENT_FILE_IMP_ID>
<DP_RELATIONSHIP></DP_RELATIONSHIP>
</Eligibility_Detail_Record>
<Eligibility_Detail_Record xmlns="">
<PT_PARTICIPANT_FILE_IMP_ID>123456</PT_PARTICIPANT_FILE_IMP_ID>
<PT_PARTICIPANT_STATUS>Active</PT_PARTICIPANT_STATUS>
<PT_LST_NM>BULLOCK</PT_LST_NM>
<PT_FRST_NM>SANDRA</PT_FRST_NM>
<EN_PLAN_NAME></EN_PLAN_NAME>
<EN_MBRSHP_EFF_STRT_DT>01012017</EN_MBRSHP_EFF_STRT_DT>
<EN_MBRSHP_EFF_END_DT></EN_MBRSHP_EFF_END_DT>
<EN_PLAN_YEAR_STRT_DT>01012017</EN_PLAN_YEAR_STRT_DT>
<DP_PARTICIPANT_FILE_IMP_ID></DP_PARTICIPANT_FILE_IMP_ID>
<DP_DEPENDENT_FILE_IMP_ID></DP_DEPENDENT_FILE_IMP_ID>
<DP_RELATIONSHIP></DP_RELATIONSHIP>
</Eligibility_Detail_Record>
<Eligibility_Detail_Record xmlns="">
<PT_PARTICIPANT_FILE_IMP_ID>553739837</PT_PARTICIPANT_FILE_IMP_ID>
<PT_PARTICIPANT_STATUS>Retired</PT_PARTICIPANT_STATUS>
<PT_LST_NM>DOE</PT_LST_NM>
<PT_FRST_NM>JANE</PT_FRST_NM>
<EN_PLAN_NAME>Health Reimbursement Arrangement</EN_PLAN_NAME>
<EN_MBRSHP_EFF_STRT_DT>01012017</EN_MBRSHP_EFF_STRT_DT>
<EN_MBRSHP_EFF_END_DT></EN_MBRSHP_EFF_END_DT>
<EN_PLAN_YEAR_STRT_DT>01012017</EN_PLAN_YEAR_STRT_DT>
<DP_PARTICIPANT_FILE_IMP_ID></DP_PARTICIPANT_FILE_IMP_ID>
<DP_DEPENDENT_FILE_IMP_ID></DP_DEPENDENT_FILE_IMP_ID>
<DP_RELATIONSHIP></DP_RELATIONSHIP>
</Eligibility_Detail_Record>
<Eligibility_Detail_Record xmlns="">
<PT_PARTICIPANT_FILE_IMP_ID>610051908</PT_PARTICIPANT_FILE_IMP_ID>
<PT_PARTICIPANT_STATUS>COB</PT_PARTICIPANT_STATUS>
<PT_LST_NM>JACKSON</PT_LST_NM>
<PT_FRST_NM>MICHAEL</PT_FRST_NM>
<EN_PLAN_NAME>Health Reimbursement Arrangement</EN_PLAN_NAME>
<EN_MBRSHP_EFF_STRT_DT>01012017</EN_MBRSHP_EFF_STRT_DT>
<EN_MBRSHP_EFF_END_DT></EN_MBRSHP_EFF_END_DT>
<EN_PLAN_YEAR_STRT_DT>01012017</EN_PLAN_YEAR_STRT_DT>
<DP_PARTICIPANT_FILE_IMP_ID>610051908</DP_PARTICIPANT_FILE_IMP_ID>
<DP_DEPENDENT_FILE_IMP_ID>NC110015202761</DP_DEPENDENT_FILE_IMP_ID>
<DP_RELATIONSHIP>Spouse</DP_RELATIONSHIP>
<DP_LST_NM>JACKSON</DP_LST_NM>
<DP_FRST_NM>MELISSA</DP_FRST_NM>
</Eligibility_Detail_Record>
<Eligibility_Detail_Record xmlns="">
<PT_PARTICIPANT_FILE_IMP_ID>561859010</PT_PARTICIPANT_FILE_IMP_ID>
<PT_PARTICIPANT_STATUS>Terminated</PT_PARTICIPANT_STATUS>
<PT_LST_NM>MCLEOD</PT_LST_NM>
<PT_FRST_NM>CONOR</PT_FRST_NM>
<EN_PLAN_NAME>Health Reimbursement Arrangement</EN_PLAN_NAME>
<EN_MBRSHP_EFF_STRT_DT>01012016</EN_MBRSHP_EFF_STRT_DT>
<EN_MBRSHP_EFF_END_DT></EN_MBRSHP_EFF_END_DT>
<EN_PLAN_YEAR_STRT_DT>01012016</EN_PLAN_YEAR_STRT_DT>
<DP_PARTICIPANT_FILE_IMP_ID>561859010</DP_PARTICIPANT_FILE_IMP_ID>
<DP_DEPENDENT_FILE_IMP_ID>SC000018241906</DP_DEPENDENT_FILE_IMP_ID>
<DP_RELATIONSHIP>Dependent</DP_RELATIONSHIP>
<DP_LST_NM>MCLEOD</DP_LST_NM>
<DP_FRST_NM>DUNCAN</DP_FRST_NM>
</Eligibility_Detail_Record>
<Eligibility_Detail_Record xmlns="">
<PT_PARTICIPANT_FILE_IMP_ID>573794953</PT_PARTICIPANT_FILE_IMP_ID>
<PT_PARTICIPANT_STATUS>Active</PT_PARTICIPANT_STATUS>
<PT_LST_NM>GABRIEL</PT_LST_NM>
<PT_FRST_NM>PETER</PT_FRST_NM>
<EN_PLAN_NAME>Health Reimbursement Arrangement</EN_PLAN_NAME>
<EN_MBRSHP_EFF_STRT_DT>01012016</EN_MBRSHP_EFF_STRT_DT>
<EN_MBRSHP_EFF_END_DT></EN_MBRSHP_EFF_END_DT>
<EN_PLAN_YEAR_STRT_DT>01012016</EN_PLAN_YEAR_STRT_DT>
<DP_PARTICIPANT_FILE_IMP_ID></DP_PARTICIPANT_FILE_IMP_ID>
<DP_DEPENDENT_FILE_IMP_ID></DP_DEPENDENT_FILE_IMP_ID>
<DP_RELATIONSHIP></DP_RELATIONSHIP>
</Eligibility_Detail_Record>
<Eligibility_Detail_Record xmlns="">
<PT_PARTICIPANT_FILE_IMP_ID>553739837</PT_PARTICIPANT_FILE_IMP_ID>
<PT_PARTICIPANT_STATUS>Retired</PT_PARTICIPANT_STATUS>
<PT_LST_NM>DOE</PT_LST_NM>
<PT_FRST_NM>JANE</PT_FRST_NM>
<EN_PLAN_NAME>Health Reimbursement Arrangement</EN_PLAN_NAME>
<EN_MBRSHP_EFF_STRT_DT>01012016</EN_MBRSHP_EFF_STRT_DT>
<EN_MBRSHP_EFF_END_DT></EN_MBRSHP_EFF_END_DT>
<EN_PLAN_YEAR_STRT_DT>01012016</EN_PLAN_YEAR_STRT_DT>
<DP_PARTICIPANT_FILE_IMP_ID>553739837</DP_PARTICIPANT_FILE_IMP_ID>
<DP_DEPENDENT_FILE_IMP_ID>NC110012077673</DP_DEPENDENT_FILE_IMP_ID>
<DP_RELATIONSHIP>Spouse</DP_RELATIONSHIP>
<DP_LST_NM>DOE</DP_LST_NM>
<DP_FRST_NM>JOHN</DP_FRST_NM>
</Eligibility_Detail_Record>
<Eligibility_Detail_Record xmlns="">
<PT_PARTICIPANT_FILE_IMP_ID>553739837</PT_PARTICIPANT_FILE_IMP_ID>
<PT_PARTICIPANT_STATUS>Retired</PT_PARTICIPANT_STATUS>
<PT_LST_NM>DOE</PT_LST_NM>
<PT_FRST_NM>JANE</PT_FRST_NM>
<EN_PLAN_NAME>Health Reimbursement Arrangement</EN_PLAN_NAME>
<EN_MBRSHP_EFF_STRT_DT>01012016</EN_MBRSHP_EFF_STRT_DT>
<EN_MBRSHP_EFF_END_DT></EN_MBRSHP_EFF_END_DT>
<EN_PLAN_YEAR_STRT_DT>01012016</EN_PLAN_YEAR_STRT_DT>
<DP_PARTICIPANT_FILE_IMP_ID>553739837</DP_PARTICIPANT_FILE_IMP_ID>
<DP_DEPENDENT_FILE_IMP_ID>NC110012077680</DP_DEPENDENT_FILE_IMP_ID>
<DP_RELATIONSHIP>Dependent</DP_RELATIONSHIP>
<DP_LST_NM>DOE</DP_LST_NM>
<DP_FRST_NM>JIMMY</DP_FRST_NM>
</Eligibility_Detail_Record>
<Eligibility_Detail_Record xmlns="">
<PT_PARTICIPANT_FILE_IMP_ID>553739837</PT_PARTICIPANT_FILE_IMP_ID>
<PT_PARTICIPANT_STATUS>Retired</PT_PARTICIPANT_STATUS>
<PT_LST_NM>DOE</PT_LST_NM>
<PT_FRST_NM>JANE</PT_FRST_NM>
<EN_PLAN_NAME>Health Reimbursement Arrangement</EN_PLAN_NAME>
<EN_MBRSHP_EFF_STRT_DT>01012016</EN_MBRSHP_EFF_STRT_DT>
<EN_MBRSHP_EFF_END_DT></EN_MBRSHP_EFF_END_DT>
<EN_PLAN_YEAR_STRT_DT>01012016</EN_PLAN_YEAR_STRT_DT>
<DP_PARTICIPANT_FILE_IMP_ID>553739837</DP_PARTICIPANT_FILE_IMP_ID>
<DP_DEPENDENT_FILE_IMP_ID>NC110012077681</DP_DEPENDENT_FILE_IMP_ID>
<DP_RELATIONSHIP>Dependent</DP_RELATIONSHIP>
<DP_LST_NM>DOE</DP_LST_NM>
<DP_FRST_NM>JESSICA</DP_FRST_NM>
</Eligibility_Detail_Record>
<Eligibility_Detail_Record xmlns="">
<PT_PARTICIPANT_FILE_IMP_ID>583736677</PT_PARTICIPANT_FILE_IMP_ID>
<PT_PARTICIPANT_STATUS>Active</PT_PARTICIPANT_STATUS>
<PT_LST_NM>RIBEYE</PT_LST_NM>
<PT_FRST_NM>COWBOY</PT_FRST_NM>
<EN_PLAN_NAME>Health Savings Account</EN_PLAN_NAME>
<EN_MBRSHP_EFF_STRT_DT>01012016</EN_MBRSHP_EFF_STRT_DT>
<EN_MBRSHP_EFF_END_DT></EN_MBRSHP_EFF_END_DT>
<EN_PLAN_YEAR_STRT_DT>01012016</EN_PLAN_YEAR_STRT_DT>
<DP_PARTICIPANT_FILE_IMP_ID>583736677</DP_PARTICIPANT_FILE_IMP_ID>
<DP_DEPENDENT_FILE_IMP_ID>NC110012077681</DP_DEPENDENT_FILE_IMP_ID>
<DP_RELATIONSHIP>Dependent</DP_RELATIONSHIP>
<DP_LST_NM>RIBEYE</DP_LST_NM>
<DP_FRST_NM>CLASSIC</DP_FRST_NM>
</Eligibility_Detail_Record>
</EligibilityRecords>
NEW REQUIREMENT
- If PT_PARTICIPANT_STATUS is "Retired" or "COB" change to "Active"
OUTPUT XML:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<ns0:EligibilityRecords xmlns="http://Eligibility_LSDD_Internal">
<Eligibility_Detail_Record xmlns="">
<PT_PARTICIPANT_FILE_IMP_ID>553739837</PT_PARTICIPANT_FILE_IMP_ID>
<PT_PARTICIPANT_STATUS>Active</PT_PARTICIPANT_STATUS>
<PT_LST_NM>DOE</PT_LST_NM>
<PT_FRST_NM>JANE</PT_FRST_NM>
<EN_PLAN_NAME>Health Reimbursement Arrangement</EN_PLAN_NAME>
<EN_PLAN_TYPE>Family</EN_PLAN_TYPE>
<EN_MBRSHP_EFF_STRT_DT>01012017</EN_MBRSHP_EFF_STRT_DT>
<EN_MBRSHP_EFF_END_DT></EN_MBRSHP_EFF_END_DT>
<EN_PLAN_YEAR_STRT_DT>01012017</EN_PLAN_YEAR_STRT_DT>
<Dependent_Record>
<DP_PARTICIPANT_FILE_IMP_ID>553739837</DP_PARTICIPANT_FILE_IMP_ID>
<DP_DEPENDENT_FILE_IMP_ID>NC110012077673</DP_DEPENDENT_FILE_IMP_ID>
<DP_RELATIONSHIP>Spouse</DP_RELATIONSHIP>
<DP_LST_NM>DOE</DP_LST_NM>
<DP_FRST_NM>JOHN</DP_FRST_NM>
</Dependent_Record>
<Dependent_Record>
<DP_PARTICIPANT_FILE_IMP_ID>553739837</DP_PARTICIPANT_FILE_IMP_ID>
<DP_DEPENDENT_FILE_IMP_ID>NC110012077680</DP_DEPENDENT_FILE_IMP_ID>
<DP_RELATIONSHIP>Dependent</DP_RELATIONSHIP>
<DP_LST_NM>DOE</DP_LST_NM>
<DP_FRST_NM>JIMMY</DP_FRST_NM>
</Dependent_Record>
<Dependent_Record>
<DP_PARTICIPANT_FILE_IMP_ID>553739837</DP_PARTICIPANT_FILE_IMP_ID>
<DP_DEPENDENT_FILE_IMP_ID>NC110012077681</DP_DEPENDENT_FILE_IMP_ID>
<DP_RELATIONSHIP>Dependent</DP_RELATIONSHIP>
<DP_LST_NM>DOE</DP_LST_NM>
<DP_FRST_NM>JESSICA</DP_FRST_NM>
</Dependent_Record>
</Eligibility_Detail_Record>
<Eligibility_Detail_Record xmlns="">
<PT_PARTICIPANT_FILE_IMP_ID>610051908</PT_PARTICIPANT_FILE_IMP_ID>
<PT_PARTICIPANT_STATUS>Active</PT_PARTICIPANT_STATUS>
<PT_LST_NM>JACKSON</PT_LST_NM>
<PT_FRST_NM>MICHAEL</PT_FRST_NM>
<EN_PLAN_NAME>Health Reimbursement Arrangement</EN_PLAN_NAME>
<EN_PLAN_TYPE>IndSpouse</EN_PLAN_TYPE>
<EN_MBRSHP_EFF_STRT_DT>01012017</EN_MBRSHP_EFF_STRT_DT>
<EN_MBRSHP_EFF_END_DT></EN_MBRSHP_EFF_END_DT>
<EN_PLAN_YEAR_STRT_DT>01012017</EN_PLAN_YEAR_STRT_DT>
<Dependent_Record>
<DP_PARTICIPANT_FILE_IMP_ID>610051908</DP_PARTICIPANT_FILE_IMP_ID>
<DP_DEPENDENT_FILE_IMP_ID>NC110015202761</DP_DEPENDENT_FILE_IMP_ID>
<DP_RELATIONSHIP>Spouse</DP_RELATIONSHIP>
<DP_LST_NM>JACKSON</DP_LST_NM>
<DP_FRST_NM>MELISSA</DP_FRST_NM>
</Dependent_Record>
</Eligibility_Detail_Record>
<Eligibility_Detail_Record xmlns="">
<PT_PARTICIPANT_FILE_IMP_ID>561859010</PT_PARTICIPANT_FILE_IMP_ID>
<PT_PARTICIPANT_STATUS>Terminated</PT_PARTICIPANT_STATUS>
<PT_LST_NM>MCLEOD</PT_LST_NM>
<PT_FRST_NM>CONOR</PT_FRST_NM>
<EN_PLAN_NAME>Health Reimbursement Arrangement</EN_PLAN_NAME>
<EN_PLAN_TYPE>IndChild</EN_PLAN_TYPE>
<EN_MBRSHP_EFF_STRT_DT>01012016</EN_MBRSHP_EFF_STRT_DT>
<EN_MBRSHP_EFF_END_DT></EN_MBRSHP_EFF_END_DT>
<EN_PLAN_YEAR_STRT_DT>01012016</EN_PLAN_YEAR_STRT_DT>
<Dependent_Record>
<DP_PARTICIPANT_FILE_IMP_ID>561859010</DP_PARTICIPANT_FILE_IMP_ID>
<DP_DEPENDENT_FILE_IMP_ID>SC000018241906</DP_DEPENDENT_FILE_IMP_ID>
<DP_RELATIONSHIP>Dependent</DP_RELATIONSHIP>
<DP_LST_NM>MCLEOD</DP_LST_NM>
<DP_FRST_NM>DUNCAN</DP_FRST_NM>
</Dependent_Record>
</Eligibility_Detail_Record>
<Eligibility_Detail_Record xmlns="">
<PT_PARTICIPANT_FILE_IMP_ID>573794953</PT_PARTICIPANT_FILE_IMP_ID>
<PT_PARTICIPANT_STATUS>Active</PT_PARTICIPANT_STATUS>
<PT_LST_NM>GABRIEL</PT_LST_NM>
<PT_FRST_NM>PETER</PT_FRST_NM>
<EN_PLAN_NAME>Health Reimbursement Arrangement</EN_PLAN_NAME>
<EN_MBRSHP_EFF_STRT_DT>01012016</EN_MBRSHP_EFF_STRT_DT>
<EN_MBRSHP_EFF_END_DT></EN_MBRSHP_EFF_END_DT>
<EN_PLAN_YEAR_STRT_DT>01012016</EN_PLAN_YEAR_STRT_DT>
<EN_PLAN_TYPE>Ind</EN_PLAN_TYPE>
</Eligibility_Detail_Record>
<Eligibility_Detail_Record xmlns="">
<PT_PARTICIPANT_FILE_IMP_ID>583736677</PT_PARTICIPANT_FILE_IMP_ID>
<PT_PARTICIPANT_STATUS>Active</PT_PARTICIPANT_STATUS>
<PT_LST_NM>RIBEYE</PT_LST_NM>
<PT_FRST_NM>COWBOY</PT_FRST_NM>
<EN_PLAN_NAME>Health Savings Account</EN_PLAN_NAME>
<EN_HDHP_COVERAGE_LEVEL>Family</EN_HDHP_COVERAGE_LEVEL>
<EN_MBRSHP_EFF_STRT_DT>01012016</EN_MBRSHP_EFF_STRT_DT>
<EN_MBRSHP_EFF_END_DT></EN_MBRSHP_EFF_END_DT>
<EN_PLAN_YEAR_STRT_DT>01012016</EN_PLAN_YEAR_STRT_DT>
<Dependent_Record>
<DP_PARTICIPANT_FILE_IMP_ID>583736677</DP_PARTICIPANT_FILE_IMP_ID>
<DP_DEPENDENT_FILE_IMP_ID>NC110012077681</DP_DEPENDENT_FILE_IMP_ID>
<DP_RELATIONSHIP>Dependent</DP_RELATIONSHIP>
<DP_LST_NM>RIBEYE</DP_LST_NM>
<DP_FRST_NM>CLASSIC</DP_FRST_NM>
</Dependent_Record>
</Eligibility_Detail_Record>
</ns0:EligibilityRecords>
The original answer found in the link above made use of an xsl:copy-of to copy all nodes that had a name starting with a specific character string as no logic needed to be run on those sets of nodes. Because PT_PARTICIPANT_STATUS occurs in the middle of one of those sets of nodes this no longer works.
I modified the XSLT to use an xsl:template approach instead and all the original logic, and the new logic work with one caveat. The Eligibility_Detail_Record nodes are being duplicated multiple times.
XSLT:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" exclude-result-prefixes="msxsl var s0 ns0" version="1.0" xmlns:s0="http://Eligibility_LSDD" xmlns:ns0="http://Eligibility_LSDD_Internal">
<xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
<xsl:key name="participants" match="Eligibility_Detail_Record" use="PT_PARTICIPANT_FILE_IMP_ID"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="EligibilityRecords">
<ns0:EligibilityRecords>
<xsl:apply-templates select="Eligibility_Detail_Record"/>
</ns0:EligibilityRecords>
</xsl:template>
<xsl:template match="Eligibility_Detail_Record">
<!--Strip all Eligibility_Detail_Records that have a blank PT_PARTICIPANT_FILE_IMP_ID AND The EN_PLAN_NAME node is not "Health Reimbursement Arrangement" or "Health Savings Account"-->
<xsl:for-each select="../Eligibility_Detail_Record[string(PT_PARTICIPANT_FILE_IMP_ID) and (EN_PLAN_NAME='Health Reimbursement Arrangement' or EN_PLAN_NAME='Health Savings Account')]
[count(.|key('participants',PT_PARTICIPANT_FILE_IMP_ID)[1])=1]">
<xsl:variable name="participantCount" select="count(key('participants',PT_PARTICIPANT_FILE_IMP_ID))"/>
<Eligibility_Detail_Record>
<xsl:variable name="participantStatus" select="PT_PARTICIPANT_STS"/>
<xsl:apply-templates select="@*|node()|PT_PARTICIPANT_STS|EN_PLAN_NAME">
<xsl:with-param name="participantStatus" select="$participantStatus"/>
<xsl:with-param name="participantCount" select="$participantCount"/>
</xsl:apply-templates>
<!--Create a new Dependent_Record that is a child record of Eligibility_Detail_Record for each DP_PARTICIPANT_FILE_IMP_ID that matches a PT_PARTICIPANT_FILE_IMP_ID-->
<xsl:for-each select="key('participants',PT_PARTICIPANT_FILE_IMP_ID)[string(DP_PARTICIPANT_FILE_IMP_ID)]">
<Dependent_Detail_Record>
<xsl:copy-of select="*[starts-with(name(),'DP_')]"/>
<xsl:copy-of select="PT_EMPLOYER_CD"/>
</Dependent_Detail_Record>
</xsl:for-each>
</Eligibility_Detail_Record>
<!--</xsl:if>-->
</xsl:for-each>
</xsl:template>
<xsl:template match="PT_PARTICIPANT_STS">
<xsl:param name="participantStatus"/>
<PT_PARTICIPANT_STS>
<xsl:choose>
<xsl:when test="$participantStatus = 'Retired' or $participantStatus = 'COB'">Active</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$participantStatus"/>
</xsl:otherwise>
</xsl:choose>
</PT_PARTICIPANT_STS>
</xsl:template>
<xsl:template match="EN_PLAN_NAME">
<xsl:param name="participantCount"/>
<xsl:copy-of select="self::EN_PLAN_NAME"/>
<xsl:choose>
<!--Add an EN_PLAN_TYPE field for each Record that has an EN_PLAN_NAME of "Health Reimbursement Arrangement" that reads:-->
<xsl:when test="self::EN_PLAN_NAME='Health Reimbursement Arrangement'">
<xsl:call-template name="HRA">
<xsl:with-param name="participantCount" select="$participantCount"/>
</xsl:call-template>
</xsl:when>
<!--Add an EN_HDHP_COVERAGE_LEVEL field for each Record that has en EN_PLAN_NAME of "Health Savings Account" that reads:-->
<xsl:when test="self::EN_PLAN_NAME='Health Savings Account'">
<xsl:call-template name="HSA">
<xsl:with-param name="participantCount" select="$participantCount"/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="*[starts-with(name(),'DP_')]" />
<xsl:template name="HRA">
<xsl:param name="participantCount"/>
<EN_PLAN_TYPE>
<xsl:choose>
<xsl:when test="$participantCount > 1">Family</xsl:when>
<xsl:when test="$participantCount = 1 and ../DP_RELATIONSHIP = 'Dependent'">IndChild</xsl:when>
<xsl:when test="$participantCount = 1 and ../DP_RELATIONSHIP = 'Spouse'">IndSpouse</xsl:when>
<xsl:when test="$participantCount = 1">Ind</xsl:when>
</xsl:choose>
</EN_PLAN_TYPE>
</xsl:template>
<xsl:template name="HSA">
<xsl:param name="participantCount"/>
<EN_HDHP_COVERAGE_LEVEL>
<xsl:choose>
<xsl:when test="$participantCount > 1 or
$participantCount = 1 and string(../DP_RELATIONSHIP)">Family</xsl:when>
<xsl:when test="$participantCount = 1">Single</xsl:when>
</xsl:choose>
</EN_HDHP_COVERAGE_LEVEL>
</xsl:template>
</xsl:stylesheet>