【问题标题】:Usage of & in xquery concatxquery concat 中 & 的使用
【发布时间】:2019-07-09 19:51:41
【问题描述】:

如何在 XQuery concat 语句中使用 &(与号字符)?我正在使用 eXist DB,这很有效:

concat("Marvin ", "and", " Peter")

但这不是:

concat("Marvin ", "&", " Peter")

我收到错误消息:expecting '"', found '&'

\ 转义 & 符号不起作用。

【问题讨论】:

  • 有趣的是,来自 SO 的通知邮件提供了解决方案。您的问题显示为:How can I use & (the ampersand character) in an Xquery concat statement? I'm using eXist DB and this works: concat("Marvin ", "and", " Peter") but this doesn't: concat("Marvin ", "&", " ...

标签: xquery exist-db


【解决方案1】:

由于&XML character and entity references 的转义字符,它不能用作XML 或XQuery 字符串中的文字字符。您必须使用实体对其进行编码。您可以使用预定义的&,或者通过其Unicode 代码点使用&#[...];(十进制)或&#x[...];(十六进制)引用它:

concat("Marvin ", "&", " Peter"),
concat("Marvin ", "&", " Peter"),
concat("Marvin ", "&", " Peter")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-25
    • 2012-06-20
    • 1970-01-01
    相关资源
    最近更新 更多