是否有类似于 local-name 的 local-path 函数? [英] Is there a local-path function similar to local-name?

查看:27
本文介绍了是否有类似于 local-name 的 local-path 函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在之前的 SO 帖子中:XML 数据类型方法值"的参数 1必须是字符串文字我没找到解决方案,但如果有人能回答这个问题,我就可以解决之前的问题.

in a previous SO post: The argument 1 of the XML data type method "value" must be a string literal I failed to figure out a solution but if anyone can answer this question, I can solve that previous problem.

问题:如何以检索给定节点的名称的方式检索给定节点的完整路径?

Question: how do I retrieve the full path of a given node, in the way that I can retrieve the name of a given node?

declare @x xml; set @x='<ROOT><a>111</a></ROOT>'
SELECT @x.value('local-name((/ROOT/a)[1])', 'varchar(256)')

以上将返回'a'.我如何返回/ROOT/a"?

the above will return 'a'. how do I return '/ROOT/a'?

推荐答案

目前(从 SQL Server 2008 开始)没有解决这个问题的方法,仅仅是因为 SQL 引擎不支持整个 XQuery 语言.根据规范,有些函数可用于获取祖先并使用 FLWOR 可以构建路径,但祖先函数尚未实现.很遗憾.

there is no solution to this problem at present (as of SQL Server 2008) simply because the SQL engine does not support the entire XQuery language. there are functions, as per the spec, that could be used to get ancestors and using FLWOR the path could be constructed, but the ancestry functions have not been implemented. sadly.

但是,至于让我开始的问题(请参阅我原来的 SO 帖子)-找到了可接受的解决方案

however, as for the issue that got me here to begin with (see my original SO post) - that found an acceptable solution

这篇关于是否有类似于 local-name 的 local-path 函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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