我已尝试过这几种方法,但我显然不太了解匹配和测试元素。
这第一位有效。它排除了整个EligibilityBenefit元素IF包含的子元素EligibilityorBenefitInformation等于' I'。
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8" indent="yes"/>
<!-- Identity template : copy all text nodes, elements and attributes -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="EligibilityorBenefit[EligibilityorBenefitInformation='I']" />
</xsl:stylesheet>
问题在于我尝试使选择更具限制性。
我已尝试过这些并且他们没有工作
match="EligibilityorBenefit[EligibilityorBenefitInformation='I' and ServiceTypeCode='35']"
match="EligibilityorBenefit[EligibilityorBenefitInformation='I'] and EligibilityorBenefit[ServiceTypeCode='35']"
我还试图像这样使用一场比赛
<xsl:template match="EligibilityorBenefit">
<xsl:choose>
<xsl:when test="EligibilityorBenefitInformation='I' and ServiceTypeCode='35'">
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="@*|node()" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
这就是我所拥有的
<Eligibility217>
<Loop2110>
<EligibilityorBenefit>
<EligibilityorBenefitInformation>I</EligibilityorBenefitInformation>
<CoverageLevelCode />
<ServiceTypeCode>30</ServiceTypeCode>
<InsuranceTypeCode>EP</InsuranceTypeCode>
</EligibilityorBenefit>
</Loop2110>
<Loop2110>
<EligibilityorBenefit>
<EligibilityorBenefitInformation>A</EligibilityorBenefitInformation>
<CoverageLevelCode>IND</CoverageLevelCode>
<ServiceTypeCode>33</ServiceTypeCode>
</EligibilityorBenefit>
<EligibilityorBenefit>
<EligibilityorBenefitInformation>I</EligibilityorBenefitInformation>
<CoverageLevelCode>IND</CoverageLevelCode>
<ServiceTypeCode>35</ServiceTypeCode>
</EligibilityorBenefit>
<Message>
<MessageText>Specialist</MessageText>
</Message>
<Loop2115>
<Information>
<CodeListQualifierCode>ZZ</CodeListQualifierCode>
<IndustryCode>11</IndustryCode>
</Information>
</Loop2115>
</Loop2110>
</Eligibility217>
这就是我想要的
<Eligibility217>
<Loop2110>
<EligibilityorBenefit>
<EligibilityorBenefitInformation>I</EligibilityorBenefitInformation>
<CoverageLevelCode />
<ServiceTypeCode>30</ServiceTypeCode>
<InsuranceTypeCode>EP</InsuranceTypeCode>
</EligibilityorBenefit>
</Loop2110>
<Loop2110>
<EligibilityorBenefit>
<EligibilityorBenefitInformation>A</EligibilityorBenefitInformation>
<CoverageLevelCode>IND</CoverageLevelCode>
<ServiceTypeCode>33</ServiceTypeCode>
</EligibilityorBenefit>
<Message>
<MessageText>Specialist</MessageText>
</Message>
<Loop2115>
<Information>
<CodeListQualifierCode>ZZ</CodeListQualifierCode>
<IndustryCode>11</IndustryCode>
</Information>
</Loop2115>
</Loop2110>
</Eligibility217>
答案 0 :(得分:0)
在我的例子中,我无意中发布了答案。
出于某种原因,我不相信它有效。再次检查后,我现在看到我从一开始就有了解决方案。
match="EligibilityorBenefit[EligibilityorBenefitInformation='I' and ServiceTypeCode='35']"