简体   繁体   English

XQuery:如何输出字符串文字和属性值

[英]XQuery: How to output string literal & in value of attribute

test.xqy: test.xqy:

element test
{
  attribute haha {"&"}
}

command line: 命令行:

$ basex test.xqy
<test haha="&amp;"/>

And I need the output to be: <test haha="&"/> . 我需要输出: <test haha="&"/> The XML entity is not processed by BaseX? BaseX不处理XML实体?

The document <test haha="&"/> is not well-formed, so there's no chance to get this output with BaseX or any other XML processor. 文档<test haha="&"/>格式不正确,因此没有机会使用BaseX或任何其他XML处理器获得此输出。 However, the value of haha is indeed '&'; 然而,哈哈的价值确实是'&'; you will see this if you return the attribute value as string: 如果将属性值作为字符串返回,您将看到这个:

string(<test haha="&amp;"/>/@haha)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM