JSONiq和XQuery 3.1有什么区别? [英] What are the differences between JSONiq and XQuery 3.1?

查看:60
本文介绍了JSONiq和XQuery 3.1有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JSONiq XQuery 3.1 都扩展了 XQuery 3.0 ,并支持JSON.

Both JSONiq and XQuery 3.1 extend XQuery 3.0 with support for JSON.

它们有何不同?

推荐答案

总体动机

XQuery 3.1的设计目标是支持内存中的其他数据结构(映射,数组).这些结构被映射到JSON以进行输入和输出.自2017年3月以来,XQuery 3.1一直是W3C的推荐.

Overall motivation

XQuery 3.1 was designed with the goal to support additional data structures (maps, arrays) in memory. These structures are mapped to JSON for input and output. XQuery 3.1 has been a W3C recommendation since March 2017.

JSONiq的设计目标是在文档存储等设置中查询和更新JSON.它也是由XML Query工作组的成员(免责声明:我是其中之一)设计的,同时研究了支持JSON的各种可能性.尽管不是官方建议,但它是稳定且公开的.

JSONiq was designed with the goal of querying and updating JSON in settings such as document stores. It was also designed by members of the XML Query working group (disclaimer: I am one of them) while investigating various possibilities to support JSON. While it is not an official recommendation, it is stable and public.

XQuery 3.1和JSONiq都使用对象和数组扩展了数据模型,但是这样做的方式有所不同,这要归功于它们的重点.总体而言,XQuery 3.1具有更通用的数据模型,而JSONiq则将其限制为镜像JSON.

Both XQuery 3.1 and JSONiq extend the data model with objects and arrays, but do so in different ways, motivated by their distinct focuses. Overall, XQuery 3.1 has a more generic data model, while JSONiq restricts it to mirror JSON.

在JSONiq中,对象键必须是字符串.在XQuery 3.1中,它们可以是任何原子值.

In JSONiq, object keys must be strings. In XQuery 3.1, they can be any atomic value.

在JSONiq中,对象和数组中的值必须是单个项目,尤其是,数组与序列是同态的,即使它们是不同的.在XQuery 3.1中,对象和数组中的值可以是项目序列.

In JSONiq, values in objects and arrays must be single items, in particular, arrays are homomorphic to sequences even though they are distinct. In XQuery 3.1, values in object and arrays can be sequences of items.

在JSONiq中,空值用专用的原子类型表示.在XQuery 3.1中,它们用空序列表示(在数据模型中为空值).

In JSONiq, nulls are represented with a dedicated atomic type. In XQuery 3.1, they are represented with empty sequences (which are accepted values in the data model).

在XQuery 3.1中,不会通过填充数组或映射来复制值,数组或映射支持在XML节点上构建索引等.在JSONiq中,复制与XML构造函数类似,以确保严格的树语义.

In XQuery 3.1, values are not copied with populating an array or map, which supports among others building indices on XML nodes. In JSONiq, copies are made similarly to XML constructors, to ensure a strict tree semantics.

在JSONiq中构造对象和数组的语法是JSON的超集.

The syntax for constructing objects and arrays in JSONiq is a superset of JSON.

{ "foo" : [ 1 to 10 ] }

在XQuery 3.1中,它类似于计算的XML节点构造函数:

In XQuery 3.1, it is similar to computed XML node constructors:

map { "foo" : array { 1 to 10 } }

XQuery 3.1具有数组的另一种语法,其中用逗号分隔值的插槽,以嵌套序列:

XQuery 3.1 has an alternate syntax for arrays in which commas delimite the slots for the values, to nest sequences:

[ 1, (1 to 10), 11 ]

导航

XQuery 3.1使用函数调用在对象和数组中执行查找:

Navigation

XQuery 3.1 uses function calls to perform lookups in objects and arrays:

let $map := map { "foo" : "bar" }
return $map("foo")

let $array := array { 1, 2, 3 }
return $array(2)

它还使用?作为未加引号的名称和整数的快捷方式:

It also uses ? as a shortcut for unquoted names and integers:

let $map := map { "foo" : "bar" }
return $map?foo

let $array := array { 1, 2, 3 }
return $array?2

let $array := array { 1, 2, 3 }
return $array?*

JSONiq(核心语言)使用点和方括号

JSONiq (the core language) uses dots and square brackets

let $map := { "foo" : "bar" }
return $map.foo

let $array := [ 1, 2, 3 ]
return $array[[2]]

let $array := [ 1, 2, 3 ]
return $array[]

(JSONiq也作为XQuery的扩展存在,它也使函数调用语法过载).

(JSONiq also exists as an extension to XQuery that also overloads the function call syntax).

这篇关于JSONiq和XQuery 3.1有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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