Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.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
Xml 评估属性值是否可解析为xs:int_Xml_Xpath_Xquery_Xquery 3.0 - Fatal编程技术网

Xml 评估属性值是否可解析为xs:int

Xml 评估属性值是否可解析为xs:int,xml,xpath,xquery,xquery-3.0,Xml,Xpath,Xquery,Xquery 3.0,背景: 我正在尝试对属性值(attrname)执行查询(使用XQuery 3.0),该属性值可能是xs:string或xs:int,我们将其称为$a 如果$a能够被解析为xs:int,那么我想将它与xs:int变量$v(可以使用If($castable as xs:int)然后使用表达式1 else表达式2可以使用If($castable as xs:int)然后表达式1其他表达式2谢谢,它就像一个符咒一样有效。我现在觉得有点愚蠢,因为我在文档中发现了它。谢谢,它就像一个符咒一样有效。我现在觉得

背景:

我正在尝试对属性值(
attrname
)执行查询(使用XQuery 3.0),该属性值可能是
xs:string
xs:int
,我们将其称为
$a


如果
$a
能够被解析为
xs:int
,那么我想将它与
xs:int
变量
$v
可以使用
If($castable as xs:int)然后使用表达式1 else表达式2
可以使用
If($castable as xs:int)然后表达式1其他表达式2

谢谢,它就像一个符咒一样有效。我现在觉得有点愚蠢,因为我在文档中发现了它。谢谢,它就像一个符咒一样有效。我现在觉得有点愚蠢,因为我在文档中发现了它。
<root>
  <element attrname="1">this is an xs:int</element>
  <element attrname="A">this is an xs:string</element>
</root>
IF $a IS xs:int THEN
  DO SOMETHING
ELSE IF $a IS xs:string THEN
  DO SOMETHING ELSE