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 - Fatal编程技术网

匹配xslt中的特定模式

匹配xslt中的特定模式,xslt,Xslt,我有一个类似于: <test> <email>youyue19910410@gmail.com</email> <test> youyue19910410@gmail.com 问题是,当我想检查此电子邮件是否有效时,如何编写测试条件,即电子邮件地址应遵循该模式xxxxx@xxx.com. 我编写了以下xslt: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w

我有一个类似于:

<test>
    <email>youyue19910410@gmail.com</email>
<test>

youyue19910410@gmail.com
问题是,当我想检查此电子邮件是否有效时,如何编写测试条件,即电子邮件地址应遵循该模式xxxxx@xxx.com.

我编写了以下xslt:

<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>

<xsl:variable name="email"><xsl:value-of select="/test/email"/></xsl:variable>

<xsl:template match="test">
     <xsl:choose>
          <xsl:when test="need your help here!">
               <message>This email is valid!</message>
          <xsl:otherwise>
               <message>This email is not valid</message>
          </xsl:otherwise>
</xsl:template>
</xsl:stylesheet>

此电子邮件有效!
此电子邮件无效

谢谢大家!

只有XSLT2.0及更高版本的正则表达式与
matches
函数匹配。您是否使用像Saxon 9或XmlPrime这样的XSLT2.0处理器?对于XSLT 1.0,有一个
包含
函数,允许您检查
,并使用一些子字符串可以测试最后四个字母是否为
.com
。这是否是一个好主意,以找到有效的电子邮件地址是一个不同的问题。谢谢你的答复。我使用XSLT1.0。我将尝试使用contains并以function结尾。再次感谢!