“仅字符”检入xsl字符串? [英] 'Characters only' check in xsl string?

查看:158
本文介绍了“仅字符”检入xsl字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查字符串是否只包含字符(XSLT文件)?

 < xsl:variable name = IsValid1> 
< xsl:choose>
< xsl:当test =string-length(// FirstName)& gt; 0和string-length(// LastName)& gt; 0和substring(// FirstName, !='TST'and XXXX // FirtName only charactersXXXXX>
< / xsl:when>
< xsl:otherwise>
< / xsl:otherwise>
< / xsl:choose>
< / xsl:variable>

在XPath 1.0(XSLT 1.0)中,您可以使用 code> contains()。在XPath 2.0(XSLT 2.0)中,您使用 matches()



您可能需要检查字母字符只有(没有数字,没有其他符号,没有空格):

  matches(// FirstName,'^ [a- Z] + $')

或字母数字,

  matches(// FirstName,'^ [a-zA-Z0-9] + $')


How can i check if a string include only characters (XSLT File)?

<xsl:variable name="IsValid1">
  <xsl:choose>
    <xsl:when test="string-length(//FirstName) &gt; 0 and string-length(//LastName) &gt; 0 and substring(//FirstName, 1, 3) != 'TST' and XXXX//FirtName only charactersXXXXX ">
    </xsl:when>
    <xsl:otherwise>
    </xsl:otherwise>
  </xsl:choose>
</xsl:variable>

解决方案

In XPath 1.0 (XSLT 1.0) you can use contains(). In XPath 2.0 (XSLT 2.0) you use matches().

You may want for example check for alphabetic characters only (no numerics, no other signs, no spaces):

matches(//FirstName, '^[a-zA-Z]+$')

or alphanumeric,

matches(//FirstName, '^[a-zA-Z0-9]+$')

这篇关于“仅字符”检入xsl字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆