gpt4 book ai didi

xml - XPath 1.0 中数字文字的官方定义是什么?

转载 作者:行者123 更新时间:2023-12-03 03:33:01 24 4
gpt4 key购买 nike

我正在尝试找出 XPath 1.0 语法中允许使用哪种数字的官方定义。

通过反复试验,我相信我已经将其确定为:

^-?[0-9]*\.?[0-9]+$

换句话说:

  • 可选-
  • 不允许使用前导 +
  • 无指数
  • 小数点前后的多余零可以省略

对于数字文字和将 number() 与字符串值一起使用似乎都是如此,只不过 number() 允许前导和尾随空格。

除了第二个项目符号之外,这似乎与 xsd:decimal 相同,但我在 Numbers 部分找不到任何提及它的内容或任何与其对应的 XSD 类型的提及。

这实际上是在任何地方定义的吗?如果是的话,在哪里?

最佳答案

通过输入这个问题的 80%,我找到了答案,所以我想我应该继续下去并将其发布在这里,以防其他人正在寻找这个晦涩的琐事。

Number的产生s 定义于 Lexical Structure部分:

[30] Number ::= Digits ('.' Digits?)? | '.' Digits
[31] Digits ::= [0-9]+

前导减号在 UnaryExpr 中处理生产:

[27] UnaryExpr ::= UnionExpr | '-' UnaryExpr

number() 接受的值集在该函数的定义中定义:

a string that consists of optional whitespace followed by an optional minus sign followed by a Number followed by whitespace is converted to the IEEE 754 number that is nearest [(according to the IEEE 754 round-to-nearest rule) to the mathematical value represented by the string; any other string is converted to NaN

这里的“Number”指的是上面的词汇产生式[30]。

关于xml - XPath 1.0 中数字文字的官方定义是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27795917/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com