XSLT-检查子字符串
我有两个XSLT变量,如下所示:XSLT-检查子字符串,xslt,substring,Xslt,Substring,我有两个XSLT变量,如下所示: <xsl:variable name="staticBaseUrl" select="'https://www.hello.com/htapi/PrintApp.asmx/getGames?contentId=id_sudoku&uniqueId="123456"&pageformat=a4'" /> <xsl:variable name="dynamicUrl" select="'https://www.hello.com
<xsl:variable name="staticBaseUrl" select="'https://www.hello.com/htapi/PrintApp.asmx/getGames?contentId=id_sudoku&uniqueId="123456"&pageformat=a4'" />
<xsl:variable name="dynamicUrl" select="'https://www.hello.com/htapi/PrintApp.asmx/getGames'" />
如何检查第二个字符串(dynamiccurl)是否是第一个字符串(staticBaseUrl)的子字符串?要检查一个字符串是否包含在另一个字符串中,请使用函数 例如:
<xsl:if test="contains($staticBaseUrl,$dynamicUrl)">
<xsl:text>Yes!</xsl:text>
</xsl:if>
@dogbane:谢谢你的宝贵帮助。但是消息框没有显示。@dogbane:我该怎么做才能不区分大小写地检查它。@1355尝试使用
contains(大写($staticBaseUrl),大写($dynamiccurl))
。这仅在使用xslt2.0时有效。
<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<xsl:template match="/">
<xsl:if
test="contains(translate($staticBaseUrl,$smallcase,$uppercase), translate($dynamicUrl,$smallcase,$uppercase))">
<xsl:text>Yes!</xsl:text>
</xsl:if>
</xsl:template>