XSLT/XPath:MSXML 4.0 中没有大写函数?

发布于 2024-07-30 06:08:00 字数 150 浏览 3 评论 0原文

我尝试在 XPATH 中使用 upper-case(),我的解析器是 MSXML 4.0,我得到:

upper-case is not a valid XSLT or XPath function.

它真的没有实现吗?

I try to use upper-case() in an XPATH, my parser is MSXML 4.0, and I get :

upper-case is not a valid XSLT or XPath function.

Is it really not implemented ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

想念有你 2024-08-06 06:08:00

xslt 1.0 中没有用于转换为大写或小写的函数。 相反,请执行以下操作:

如果很多地方都需要:

声明这两个 xsl 变量(这是为了使 xslt 更具可读性)

<!-- xsl variables up and lo and translate() are used to change case -->
  <xsl:variable name="up" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
  <xsl:variable name="lo" select="'abcdefghijklmnopqrstuvwxyz'"/>

并在翻译函数中使用它们来更改大小写

<xsl:value-of select="translate(@name,$lo,$up)"/>

如果只需要在一处使用,则无需声明变量

<xsl:value-of select="translate(@name,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>

There are no functions in xslt 1.0 to convert to uppercase or lowercase. Instead do the following:

If it is required in a lot of places:

Declare these two xsl variables (this is to make the xslt more readable)

<!-- xsl variables up and lo and translate() are used to change case -->
  <xsl:variable name="up" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
  <xsl:variable name="lo" select="'abcdefghijklmnopqrstuvwxyz'"/>

And use them in your translate function to change the case

<xsl:value-of select="translate(@name,$lo,$up)"/>

If you need to use it in just one place, no need to declare variables

<xsl:value-of select="translate(@name,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
叹梦 2024-08-06 06:08:00

也许这可以帮助您:

translate(string, string, string)

翻译函数接受一个字符串,并逐个字符地将与第二个字符串匹配的字符翻译为第三个字符串中的相应字符。 这是 XPath 中从小写转换为大写的唯一方法。 看起来像这样(为了可读性添加了额外的空白)。 此代码会将员工的姓氏转换为大写,然后选择姓氏以 A 开头的员工。

descendant::employee[
 starts-with(
  translate(@last-name, 
      "abcdefghijklmnopqrstuvwxyz", 
      "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 
  "A"
 ) 
]

如果第二个字符串的字符数多于第三个字符串,则这些多余的字符将从第一个字符串中删除。 如果第三个字符串的字符数多于第二个字符串,则多余的字符将被忽略。

(来自 http://tutorials.beginners.co.uk/professional-visual-basic-6-xml-part-1-using-xml-queries-and-transformations.htm?p=3)

Maybe this can help you:

translate(string, string, string)

The translate function takes a string and, character-by-character, translates characters which match the second string into the corresponding characters in the third string. This is the only way to convert from lower to upper case in XPath. That would look like this (with extra white space added for readability). This code would translate the employee last names to upper case and then select those employees whose last names begin with A.

descendant::employee[
 starts-with(
  translate(@last-name, 
      "abcdefghijklmnopqrstuvwxyz", 
      "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 
  "A"
 ) 
]

If the second string has more characters than the third string, these extra characters will be removed from the first string. If the third string has more characters than the second string, the extra characters are ignored.

(from http://tutorials.beginners.co.uk/professional-visual-basic-6-xml-part-1-using-xml-queries-and-transformations.htm?p=3)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文