【问题标题】:Exist-db: extracting name from _eXist_xmldb_user stringExist-db:从 _eXist_xmldb_user 字符串中提取名称
【发布时间】:2021-07-14 20:38:58
【问题描述】:

@lovemeansnothing 很久以前就问过这个问题。答案是函数:xmldb:get-current-user()。但是,该函数不再在命名空间中定义,并且已从存在数据库文档中删除。原始问题中的陈述仍然存在,因此我逐字引用:

"我需要获取当前会话的用户名作为字符串

这个:

session:get-attribute('_eXist_xmldb_user')

返回这个:

但我只想要在这个例子中的用户名:

foobar

有什么办法吗?”

感谢您的帮助

拉尔夫

【问题讨论】:

  • 我目前没有安装 eXist 来测试,但是如果函数返回一个 xml 节点,你不能简单地引用 session:get-attribute('_eXist_xmldb_user')/@namedata(session:get-attribute('_eXist_xmldb_user')/@name) 之类的属性吗?
  • 嗨@DavidDenenberg,不幸的是它没有返回节点集或可以编辑为一个的字符串。虽然信息都在那里,但实际上毫无用处。

标签: xquery exist-db


【解决方案1】:

试试

xquery version "3.1";

import module namespace sm = "http://exist-db.org/xquery/securitymanager";

sm:id()//sm:real/sm:username/text()

【讨论】:

  • 谢谢@loren-cahlander,这是一种享受!
猜你喜欢
  • 1970-01-01
  • 2013-06-18
  • 1970-01-01
  • 1970-01-01
  • 2022-08-12
  • 1970-01-01
  • 2019-08-22
  • 2015-05-12
  • 2021-09-03
相关资源
最近更新 更多