Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
XSLT-检查子字符串_Xslt_Substring - Fatal编程技术网

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

我有两个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/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>