BaseX 属性无法序列化 [英] BaseX attributes cannot be serialized

查看:21
本文介绍了BaseX 属性无法序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个简单的 XML 文件:

I have this simple XML file:

<catalog>
  <product dept="WMN">
    <number>557</number>
    <name language="en">Fleece Pullover</name>
    <colorChoices>navy black</colorChoices>
  </product>
  <product dept="ACC">
    <number>563</number>
    <name language="en">Floppy Sun Hat</name>
  </product>
  <product dept="ACC">
    <number>443</number>
    <name language="en">Deluxe Travel Bag</name>
  </product>
  <product dept="MEN">
    <number>784</number>
    <name language="en">Cotton Dress Shirt</name>
    <colorChoices>white gray</colorChoices>
    <desc>Our<i>favorite</i>shirt!</desc>
  </product>
</catalog>

我正在阅读一本名为 Priscila Walmsley 的 XQuery 并说要输入命令:

I am reading a book called XQuery by Priscila Walmsley and it says to type the command:

doc("catalog.xml")/*/product/@dept

所以我输入 BaseX

so I type in BaseX

xquery doc("catalog.xml")/*/product/@dept

我收到此错误:

Error:
[SENR0001] Attributes cannot be serialized:attribute dept { "WMN" }.

尽管书上说:

将返回输入文档中的四个部门属性.

will return the four dept attributes in the input document.

我做错了什么?

推荐答案

BaseX 只是对序列化很严格.如果您将属性节点强制转换为字符串,它不会抱怨:

BaseX is just being strict about serialization. It won't complain if you force the attribute nodes into strings:

xquery doc("catalog.xml")/*/product/@dept/string()

这篇关于BaseX 属性无法序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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