我正在尝试将特定节点(EN_PLAN_NAME)中的文本与字符串列表进行比较,因此我只能输出包含与其中一个字符串匹配的文本的节点。我尝试使用这个类似问题的答案:
输入 XML
<EligibilityRecords xmlns="http://CDHC_Eligibility_LSDD">
<Eligibility_Detail_Record xmlns="">
<EN_PLAN_NAME>Health Savings Account</EN_PLAN_NAME>
<EN_MBRSHP_EFF_STRT_DT>01012017</EN_MBRSHP_EFF_STRT_DT>
</Eligibility_Detail_Record>
<Eligibility_Detail_Record xmlns="">
<EN_PLAN_NAME>zzHealth Reimbursement Arrangement</EN_PLAN_NAME>
<EN_MBRSHP_EFF_STRT_DT>01012017</EN_MBRSHP_EFF_STRT_DT>
</Eligibility_Detail_Record>
<Eligibility_Detail_Record xmlns="">
<EN_PLAN_NAME>Health Reimbursement Arrangement 233</EN_PLAN_NAME>
<EN_MBRSHP_EFF_STRT_DT>01012017</EN_MBRSHP_EFF_STRT_DT>
</Eligibility_Detail_Record>
<Eligibility_Detail_Record xmlns="">
<EN_PLAN_NAME>HRA</EN_PLAN_NAME>
<EN_MBRSHP_EFF_STRT_DT>01012017</EN_MBRSHP_EFF_STRT_DT>
</Eligibility_Detail_Record>
<Eligibility_Detail_Record xmlns="">
<EN_PLAN_NAME>BASE HRA</EN_PLAN_NAME>
<EN_MBRSHP_EFF_STRT_DT>01012017</EN_MBRSHP_EFF_STRT_DT>
</Eligibility_Detail_Record>
<Eligibility_Detail_Record xmlns="">
<EN_PLAN_NAME>FSA</EN_PLAN_NAME>
<EN_MBRSHP_EFF_STRT_DT>01012017</EN_MBRSHP_EFF_STRT_DT>
</Eligibility_Detail_Record>
</EligibilityRecords>
预期输出 XML
<EligibilityRecords xmlns="CDHC_Eligibility_LSDD_Internal">
<Eligibility_Detail_Record xmlns="">
<EN_PLAN_NAME>zzHealth Reimbursement Arrangement</EN_PLAN_NAME>
<EN_MBRSHP_EFF_STRT_DT>01012017</EN_MBRSHP_EFF_STRT_DT>
</Eligibility_Detail_Record>
<Eligibility_Detail_Record xmlns="">
<EN_PLAN_NAME>Health Reimbursement Arrangement 233</EN_PLAN_NAME>
<EN_MBRSHP_EFF_STRT_DT>01012017</EN_MBRSHP_EFF_STRT_DT>
</Eligibility_Detail_Record>
<Eligibility_Detail_Record xmlns="">
<EN_PLAN_NAME>HRA</EN_PLAN_NAME>
<EN_MBRSHP_EFF_STRT_DT>01012017</EN_MBRSHP_EFF_STRT_DT>
</Eligibility_Detail_Record>
<Eligibility_Detail_Record xmlns="">
<EN_PLAN_NAME>BASE HRA</EN_PLAN_NAME>
<EN_MBRSHP_EFF_STRT_DT>01012017</EN_MBRSHP_EFF_STRT_DT>
</Eligibility_Detail_Record>
</EligibilityRecords>
XSLT
<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="CDHC_Eligibility_LSDD"
xmlns:ns0="CDHC_Eligibility_LSDD_Internal">
<xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
<xsl:param name="HRAPlanNames">
<PlanName>Health Reimbursement Arrangement</PlanName>
<PlanName>HRA</PlanName>
</xsl:param>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/*">
<ns0:EligibilityRecords>
<xsl:for-each select="Eligibility_Detail_Record">
<xsl:if test="contains(EN_PLAN_NAME,msxsl:node-set($HRAPlanNames)/*)">
<Eligibility_Detail_Record>
<xsl:copy-of select="EN_PLAN_NAME"/>
</Eligibility_Detail_Record>
</xsl:if>
</xsl:for-each>
</ns0:EligibilityRecords>
</xsl:template>
</xsl:stylesheet>
XSLT输出任何具有包含“健康报销安排”的文本但不输出任何包含“HRA”的节点的EN_PLAN_NAME 。我不确定我做错了什么。