我有以下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>
现在,我想仅当<service>
标记中的任何一个<name>
为memberSummary
且<version>
为3
时才使用XSLT修改上述xml 。我正在尝试以下条件,但它不起作用。
<xsl:choose>
<xsl:when test="//ClaimSystemConfig/Amisys/WADL/services/service[name='memberSummary' and version=3]">
......do something.....
</xsl:when>
<xsl:otherwise>
...do nothing...
</xsl:otherwise>
</xsl:choose>
任何人都可以帮我构建正确的条件吗?
这是部分XSLT:
<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">
</ver:routeData>
</inputSchema>
<parms>
<parm>
<name>eao</name>
<value><xsl:value-of select="eao"/></value>
</parm>
</parms>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
答案 0 :(得分:2)
目前,当您在XML上运行以下XSLT时,结果确实是“......做某事......”
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
<xsl:choose>
<xsl:when test="//ClaimSystemConfig/Amisys/WADL/services/service[3][name='memberSummary' and version=3]">
......do something.....
</xsl:when>
<xsl:otherwise>
...do nothing...
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
但如果有问题的service
元素是列表中的第三个元素,它只会“做某事”。所以,您需要将其更改为:
<xsl:when test="//ClaimSystemConfig/Amisys/WADL/services/service[name='memberSummary' and version=3]">