指甲紫色是什么原因| 痰栓是什么| 为什么嘴巴老是干| 菊花脑是什么菜| 什么辉煌四字词语| 热伤风是什么意思| 自食其力是什么意思| 双子座女和什么星座最配| 什么是同源染色体| 维生素b4又叫什么| 脆鱼是什么鱼| 总胆红素偏高吃什么药| 排斥一个人什么意思| 囊肿是什么| 男生腿毛旺盛说明什么| 眉毛里面长痘痘是什么原因| N医学上是什么意思| 甲状腺适合吃什么食物| 护理学主要学什么| 上将相当于什么级别| 什么时候受孕率最高| 2月17日是什么星座| 兵解是什么意思| 什么叫扁平疣长什么样| 包二奶是什么意思| 人活着到底是为了什么| 什么东西泡脚减肥| 侧切是什么意思| 松鼠咬人后为什么会死| 什么老什么老| 荨麻疹可以吃什么水果| 眼睛感染用什么眼药水| 小儿磨牙是什么原因引起的| 眩晕挂号挂什么科| 蓝莓有什么作用| 没有美瞳护理液用什么代替| 什么什么为笑| 二氧化碳是什么意思| 什么原因导致月经量少| 成是什么生肖| 15度穿什么衣服| 木薯粉可以做什么美食| 如果怀孕了会有什么预兆| 夏天猪骨煲什么汤最好| 为什么乳头内陷| 时光静好是什么意思| ochirly是什么牌子| 排卵试纸两条杠是什么意思| 猪蛋是什么| 睾丸皮痒用什么药| 让心归零是什么意思| 丑时是什么时辰| 医保卡有什么用| 牙龈萎缩吃什么药| 上半身皮肤痒什么原因| 为什么医院不开金刚藤| 梨的功效与作用是什么| 锹形虫吃什么| 松香有毒吗对人体有什么危害| 姜黄粉是什么做的| 的确什么意思| ket是什么| 土耳其是什么人种| 痒痒粉在药店叫什么| 脑梗吃什么食物| 挪揄是什么意思| 512是什么节日| 女人眉毛稀少代表什么| 为什么会肚子痛| 宫颈萎缩意味着什么| 女生为什么会喷水| 股骨头坏死什么原因| 脖子里面有结节是什么病| 鼻烟是什么东西| 右肩膀疼痛预示什么病| 什么是转氨酶| 前门大街有什么好玩的| 晚上睡觉小腿抽筋是什么原因| 哽咽是什么意思| 米诺地尔搽剂和米诺地尔酊有什么区别| 虚岁27岁属什么生肖| 羊水破了什么感觉| 浸润性癌是什么意思| 中秋节送什么水果好| rl是什么单位| 澳门是什么时候回归的| 清热去湿热颗粒有什么功效| 青少年吃什么钙片有助于长高| 天秤座有什么特点| 什么是五险一金| 斯凯奇鞋是什么档次| 什么的树影| 橡皮泥能做什么| 七月七日是什么日子| 风湿性心脏病是什么原因引起的| 闻所未闻是什么意思| 坐怀不乱是什么生肖| 睡觉趴着睡是什么原因| mj是什么单位| 膈肌痉挛是什么症状| 菱角是什么| 腌羊肉串放什么调料| bid是什么意思啊| 养生是什么意思| 色泽是什么意思| 4月29是什么星座| 低压高是什么原因造成的| 什么的尘土| 脾胃虚寒吃什么药好| 四月28日是什么星座| 手麻木吃什么药| 神经质是什么意思| 法益是什么意思| 老头乐是什么| 苦口婆心是什么生肖| 农历三月三是什么日子| 吃什么容易怀女儿| 子宫内膜双层什么意思| 琏是什么意思| 行政管理是做什么的| 稀奶油是什么| 局部癌变是什么意思| 胃食管反流病吃什么药| 化验肝功挂什么科| 人类的祖先是什么生肖| 低蛋白血症吃什么最快| 什么食用油最好最健康| 敛肺是什么意思| 豆蔻年华是什么意思| 植株是什么意思| 大炮是什么| 引火下行是什么意思| 喉咙痒痒的吃什么药| remax是什么牌子| 戒断反应什么意思| 当兵对牙齿有什么要求| 2015年五行属什么| 百里挑一是什么生肖| 鱼泡是鱼的什么器官| 浙江属于什么方向| 青柑是什么| 梦见好多蚊子是什么意思| 为什么医院不建议药流| 中暑是什么感觉| 薄荷音是什么意思| 西红柿什么时候成熟| 肝在什么位置| 一般细菌培养及鉴定是检查什么| 南极为什么比北极冷| 什么血糖仪准确度高| 暹什么意思| 就此别过是什么意思| 逆生长是什么意思| 手机什么时候发明的| 儿童湿疹用什么药膏| 娃娃鱼吃什么| 滢字五行属什么| 语迟则人贵是什么意思| 高考什么时候恢复| 0206是什么星座| 生辰八字指的是什么| 后装治疗是什么意思| 肺气虚吃什么食物| 肺结核传染途径是什么| 倾字五行属什么| 1923年属什么生肖| 单鞋是什么鞋| 重色轻友是什么意思| aml是什么病| 月经量多是什么原因| 帽缨是什么意思| 泄露是什么意思| 摸底是什么意思| 皮肤瘙痒用什么药最好| 来例假不能吃什么| 五浊恶世是什么意思| 流产期间吃什么好| 卡马西平片治什么病| 独角仙生活在什么地方| 什么叫引产| 乔峰和洪七公什么关系| 耳朵发烫是什么征兆| 清明上河图描绘的是什么季节的景象| 红霉素软膏和红霉素眼膏有什么区别| 肝囊肿挂什么科| 李自成为什么会失败| 腋臭和狐臭有什么区别| 什么是变异性哮喘| 什么是绿茶| 博士生导师是什么级别| 求婚是什么意思| 什么是格言| 尿液检查能查出什么病| 什么的月亮| 男人吃荔枝有什么好处| 小孩急性肠胃炎吃什么药| 杭州有什么景点| 女人白虎是什么意思| 雌激素是什么| 7.8号是什么日子| 月经推迟半个月是什么原因| 什么是业障| 丰的部首是什么偏旁| 什么时间最容易怀孕| 吃亏是什么意思| 什么的琴声| 蕊五行属什么| 水淀粉是什么东西| 14是什么意思| 月经来的少是什么原因| 紫苏长什么样子图片| 感冒黄鼻涕吃什么药| 一级法官是什么级别| 怀璧其罪是什么意思| 胸闷气短是什么原因造成的| 舒克是什么职业| 月经来了不能吃什么东西| 武汉都有什么区| 耳鸣吃什么药效果最好| 怀孕有什么特征和反应| 手指麻木什么原因| 发烧41度是什么概念| 疮疡是什么病| viscose是什么面料| 啄木鸟为什么不会脑震荡| 胃部检查除了胃镜还有什么方法| 美的不可方物什么意思| 叉烧炒什么菜好吃| 2000年是属什么生肖| 打两个喷嚏代表什么| 为什么喜欢秋天| lge是什么意思| 什么避孕套好用| 胎儿头偏小是什么原因引起的| 冠状动脉钙化什么意思| ibd是什么意思| 翠字五行属什么| a21和以纯什么关系| 3.1415926是什么意思| 什么护肤品好用| 岭南是什么地方| 整体认读音节有什么| 喝生姜水有什么好处| 增加骨密度吃什么药| 什么东西补血| 立春是什么生肖| 肠道易激惹综合征的症状是什么| 攫住是什么意思| 脚发烫是什么原因| 胡萝卜什么颜色| 5月12号是什么星座| 网球ad是什么意思| 端午节吃什么菜呢| 处女座男和什么星座最配| 第一次同房是什么感觉| 男闺蜜是什么意思| 相处是什么意思| 里字五行属什么| 半夜饿是什么原因| 头皮屑是什么东西| 前列腺炎吃什么药| 变态反应科是看什么病的| 卵泡是什么| 玉镯子断了有什么预兆| 百度Jump to content

“拥抱新时代·心中的歌唱给党”网络歌手大赛圆满落幕

From Wikipedia, the free encyclopedia
XQuery
Paradigmdeclarative, functional, modular
Designed byW3C
First appeared2007
Stable release
3.1 / March 21, 2017; 8 years ago (2025-08-05)[1]
Typing disciplinedynamic or static,[2][3] strong
OSCross-platform
Filename extensions.xq, .xql, .xqm, .xqy, .xquery
Websitewww.w3.org/XML/Query/
Major implementations
Many
Influenced by
XPath, SQL, XSLT
百度 但网咖绝不是行业发展的终点,无论是休闲娱乐路线还是电子竞技模式,未来网咖还有很长的路要走。

XQuery (XML Query) is a query language and functional programming language designed to query and transform collections of structured and unstructured data, primarily in the form of XML. It also supports text data and, through implementation-specific extensions, other formats like binary and relational data.

The language was developed by the XML Query working group of the W3C, with version 1.0 becoming a W3C Recommendation in January 2007. XQuery development is closely coordinated with the development of XSLT by the XSL Working Group. Both groups jointly maintain XPath, a shared component of XQuery and XSLT. XQuery extends XPath with features like FLWOR (For, Let, Where, Order by, Return) expressions, making it semantically similar to SQL but optimized for hierarchical rather than relational data.

XQuery 3.1, published in March 2017, added support for JSON and introduced maps, arrays, and additional higher-order functions, significantly expanding the language's capabilities for modern data processing.

XQuery is implemented by many database systems, XML databases, and XML processors, including BaseX, eXist, MarkLogic, Saxon, and Berkeley DB XML, making it a cornerstone technology for processing XML data in enterprise software applications.

Features

[edit]

XQuery's mission is to:

"provide flexible query facilities to extract data from real and virtual documents on the World Wide Web, therefore finally providing the needed interaction between the Web world and the database world. Ultimately, collections of XML files will be accessed like databases."[4]

It is a functional, side effect-free, expression-oriented programming language with a simple type system, summed up by Kilpel?inen:[5]

All XQuery expressions operate on sequences, and evaluate to sequences. Sequences are ordered lists of items. Items can be either nodes, which represent components of XML documents, or atomic values, which are instances of XML Schema base types like xs:integer or xs:string. Sequences can also be empty, or consist of a single item only. No distinction is made between a single item and a singleton sequence. (...) XQuery/XPath sequences differ from lists in languages like Lisp and Prolog by excluding nested sequences. Designers of XQuery may have considered nested sequences unnecessary for the manipulation of document contents. Nesting, or hierarchy of document structures is instead represented by nodes and their child-parent relationships

XQuery provides the means to extract and manipulate data from XML documents or any data source that can be viewed as XML, such as relational databases[6] or office documents.

XQuery contains a superset of XPath expression syntax to address specific parts of an XML document. It supplements this with a SQL-like "FLWOR expression" for performing joins. A FLWOR expression is constructed from the five clauses after which it is named: FOR, LET, WHERE, ORDER BY, RETURN.

The language also provides syntax allowing new XML documents to be constructed. Where the element and attribute names are known in advance, an XML-like syntax can be used; in other cases, expressions referred to as dynamic node constructors are available. All these constructs are defined as expressions within the language, and can be arbitrarily nested.

The language is based on the XQuery and XPath Data Model (XDM) which uses a tree-structured model of the information content of an XML document, containing seven kinds of nodes: document nodes, elements, attributes, text nodes, comments, processing instructions, and namespaces.

XDM also models all values as sequences (a singleton value is considered to be a sequence of length one). The items in a sequence can either be XML nodes or atomic values. Atomic values may be integers, strings, Booleans, and so on: the full list of types is based on the primitive types defined in XML Schema.

Features for updating XML documents or databases, and full text search capability, are not part of the core language, but are defined in add-on extension standards: XQuery Update Facility 1.0 supports update feature and XQuery and XPath Full Text 1.0 supports full text search in XML documents.

XQuery 3.0 adds support for full functional programming, in that functions are values that can be manipulated (stored in variables, passed to higher-order functions, and dynamically called).

Examples

[edit]

The sample XQuery code below lists the unique speakers in each act of Shakespeare's play Hamlet, encoded in hamlet.xml

<html>
<body>
{
  for $act in doc("hamlet.xml")//ACT
  let $speakers := distinct-values($act//SPEAKER)
  return
    <div>
      <h1>{ string($act/TITLE) }</h1>
      <ul>
      {
        for $speaker in $speakers
        return <li>{ $speaker }</li>
      }
      </ul>
    </div>
}
</body>
</html>

All XQuery constructs for performing computations are expressions. There are no statements, even though some of the keywords appear to suggest statement-like behaviors. To execute a function, the expression within the body is evaluated and its value is returned. Thus to write a function to double an input value, one simply writes:

declare function local:doubler($x) { $x * 2 }

To write a full query saying 'Hello World', one writes the expression:

"Hello World"

This style is common in functional programming languages.

Applications

[edit]

Below are a few examples of how XQuery can be used:

  1. Extracting information from a database for use in a web service.
  2. Generating summary reports on data stored in an XML database.
  3. Searching textual documents on the Web for relevant information and compiling the results.
  4. Selecting and transforming XML data to XHTML to be published on the Web.
  5. Pulling data from databases to be used for the application integration.
  6. Splitting up an XML document that represents multiple transactions into multiple XML documents.

XQuery and XSLT compared

[edit]

Scope

[edit]

Although XQuery was initially conceived as a query language for large collections of XML documents, it is also capable of transforming individual documents. As such, its capabilities overlap with XSLT, which was designed expressly to allow input XML documents to be transformed into HTML or other formats.

The XSLT 2.0 and XQuery standards were developed by separate working groups within W3C, working together to ensure a common approach where appropriate. They share the same data model (XDM), type system, and function library, and both include XPath 2.0 as a sublanguage.

Origin

[edit]

The two languages, however, are rooted in different traditions and serve the needs of different communities. XSLT was primarily conceived as a stylesheet language whose primary goal was to render XML for the human reader on screen, on the web (as web template language), or on paper. XQuery was primarily conceived as a database query language in the tradition of SQL.

Because the two languages originate in different communities, XSLT is stronger[according to whom?] in its handling of narrative documents with more flexible structure, while XQuery is stronger in its data handling (for example, when performing relational joins).

Versions

[edit]

XSLT 1.0 appeared as a Recommendation in 1999, whereas XQuery 1.0 only became a Recommendation in early 2007; as a result, XSLT is still much more widely used. Both languages have similar expressive power, though XSLT 2.0 has many features that are missing from XQuery 1.0, such as grouping, number and date formatting, and greater control over XML namespaces.[7][8][9] Many of these features were planned for XQuery 3.0.[10]

Any comparison must take into account the version of XSLT. XSLT 1.0 and XSLT 2.0 are very different languages. XSLT 2.0, in particular, has been heavily influenced by XQuery in its move to strong typing and schema-awareness.

Strengths and weaknesses

[edit]

Usability studies have shown that XQuery is easier to learn than XSLT, especially for users with previous experience of database languages such as SQL.[11] This can be attributed to the fact that XQuery is a smaller language with fewer concepts to learn, and to the fact that programs are more concise. It is also true that XQuery is more orthogonal, in that any expression can be used in any syntactic context. By contrast, XSLT is a two-language system in which XPath expressions can be nested in XSLT instructions but not vice versa.

XSLT is currently stronger than XQuery for applications that involve making small changes to a document (for example, deleting all the NOTE elements). Such applications are generally handled in XSLT by use of a coding pattern that involves an identity template that copies all nodes unchanged, modified by specific templates that modify selected nodes. XQuery has no equivalent to this coding pattern, though in future versions it will be possible to tackle such problems using the update facilities in the language that are under development.[12]

XQuery 1.0 lacked any kind of mechanism for dynamic binding or polymorphism; this has been remedied with the introduction of functions as first-class values in XQuery 3.0. The absence of this capability starts to become noticeable when writing large applications, or when writing code that is designed to be reusable in different environments.[citation needed] XSLT offers two complementary mechanisms in this area: the dynamic matching of template rules, and the ability to override rules using xsl:import, that make it possible to write applications with multiple customization layers.

The absence of these facilities from XQuery 1.0 was a deliberate design decision: it has the consequence that XQuery is very amenable to static analysis, which is essential to achieve the level of optimization needed in database query languages. This also makes it easier to detect errors in XQuery code at compile time.

The fact that XSLT 2.0 uses XML syntax makes it rather verbose in comparison to XQuery 1.0. However, many large applications take advantage of this capability by using XSLT to read, write, or modify stylesheets dynamically as part of a processing pipeline. The use of XML syntax also enables the use of XML-based tools for managing XSLT code. By contrast, XQuery syntax is more suitable for embedding in traditional programming languages such as Java (see XQuery API for Java) or C#. If necessary, XQuery code can also be expressed in an XML syntax called XQueryX. The XQueryX representation of XQuery code is rather verbose and not convenient for humans, but can easily be processed with XML tools, for example transformed with XSLT stylesheets.[13][14]

Versions and extensions

[edit]

Versions

[edit]

W3C extensions

[edit]

The World Wide Web Consortium (W3C) developed two major extensions to XQuery:

  • XQuery 1.0 and XPath 2.0 Full-Text,[18] which extends XQuery with full-text search capabilities
  • XQuery Update Facility, which enables data modification in XQuery

Both became W3C Recommendations as extensions to XQuery 1.0. Efforts to adapt them for XQuery 3.0 were abandoned due to resource constraints.

A scripting (procedural) extension for XQuery was proposed but never completed.[19][20]

The EXPath Community Group[21] develops extensions for XQuery and related standards (XPath, XSLT, XProc, and XForms). The following extensions are available:

  • Packaging System,[22] for managing XQuery libraries and modules.
  • File Module,[23] for file system operations.
  • Binary Module,[24] for handling binary data.
  • Web Applications,[25] for building web-based applications

Third-party extensions

[edit]

JSONiq is an extension of XQuery that adds support to extract and transform data from JSON documents. JSONiq is a superset of XQuery 3.0. It is published under the Creative Commons Attribution-ShareAlike 3.0 license.

XQuery 3.1 de facto deprecates JSONiq as it has added full support for JSON.

The EXQuery[26] project develops standards around creating portable XQuery applications. The following standards are currently available:

Further reading

[edit]
  • Querying XML: XQuery, XPath, and SQL/XML in context. Jim Melton and Stephen Buxton. Morgan Kaufmann, 2006. ISBN 1-55860-711-0.
  • Walmsley, Priscilla (2007). XQuery, 1st Edition. O'Reilly Media. ISBN 978-0-596-00634-1.
  • Walmsley, Priscilla (2015). XQuery, 2nd Edition. O'Reilly Media. ISBN 978-1-4919-1510-3.
  • XQuery: The XML Query Language. Michael Brundage. Addison-Wesley Professional, 2004. ISBN 0-321-16581-0.
  • XQuery from the Experts: A Guide to the W3C XML Query Language. Howard Katz (ed). Addison-Wesley, 2004. ISBN 0-321-18060-7.
  • An Introduction to the XQuery FLWOR Expression. Dr. Michael Kay (W3C XQuery Committee), 2005.

Implementations

[edit]
Overview of popular XQuery implementations
Name License Language XQuery 3.1 XQuery 3.0 XQuery 1.0 XQuery Update 1.0 XQuery Full Text 1.0
BaseX BSD license Java Yes Yes Yes Yes Yes
eXist LGPL Java Partial Partial Yes No No
MarkLogic Proprietary C++ No Partial Yes No No
Saxon HE Mozilla Public License Java Partial Partial Yes Yes No
Saxon EE Proprietary Java Yes Yes Yes Yes No
Xidel GPLv3+ FreePascal Yes Yes Yes No No
Zorba Apache License C++ No Yes Yes Yes Yes

See also

[edit]

References

[edit]
  1. ^ "XQuery 3.1 Recommendation". 2025-08-05.
  2. ^ "XQuery 3.1: An XML Query Language". 2025-08-05.
  3. ^ "XQuery and Static Typing". 3 April 2023.
  4. ^ W3C (2025-08-05). "cited by J.Robie".{{cite web}}: CS1 maint: numeric names: authors list (link)
  5. ^ Kilpel?inen, Pekka (2012). "Using XQuery for problem solving" (PDF). Software: Practice and Experience. 42 (12): 1433–1465. doi:10.1002/spe.1140. S2CID 15561027. Archived from the original (PDF) on 2025-08-05. Retrieved 2025-08-05.
  6. ^ "Data retrieval with XQuery". Retrieved on 18 January 2016.
  7. ^ Kay, Michael (May 2005). "Comparing XSLT and XQuery". Archived from the original on 2025-08-05. Retrieved 2025-08-05.
  8. ^ Eisenberg, J. David (2025-08-05). "Comparing XSLT and XQuery".
  9. ^ Smith, Michael (2025-08-05). "XQuery, XSLT "overlap" debated". Archived from the original on 2025-08-05. Retrieved 2025-08-05.
  10. ^ "XQuery 3.0 requirements".
  11. ^ Usability of XML Query Languages. Joris Graaumans. SIKS Dissertation Series No 2005-16, ISBN 90-393-4065-X
  12. ^ "XQuery Update Facility".
  13. ^ "XML Syntax for XQuery (XQueryX)".
  14. ^ Michael Kay. "Saxon diaries: How not to fold constants".
  15. ^ "XML and Semantic Web W3C Standards Timeline" (PDF). 2025-08-05. Archived from the original (PDF) on 2025-08-05. Retrieved 2025-08-05.
  16. ^ "XQuery 3.0 Recommendation". 2025-08-05.
  17. ^ "XQuery 3.1 Recommendation". 2025-08-05.
  18. ^ XQuery and XPath Full Text 1.0
  19. ^ XQuery Scripting Extension 1.0 Requirements
  20. ^ XQuery 1.0 Scripting Extension
  21. ^ EXPath Community Group
  22. ^ Packaging System
  23. ^ File Module
  24. ^ Binary Module
  25. ^ Web Applications
  26. ^ "Standard for portable XQuery applications". Retrieved 12 December 2013.
  27. ^ "RESTXQ 1.0: RESTful Annotations for XQuery".
[edit]
狗皮膏药是什么意思 菀字五行属什么 ria是什么意思 蜕膜是什么 蚯蚓吃什么食物
什么食物含牛磺酸 酒鬼酒是什么香型 番石榴什么时候成熟 龙涎香是什么 身上痣多是什么原因
打太极拳有什么好处 破气是什么意思 阳盛阴衰是什么意思 老年斑是什么原因引起的 宝宝发烧手脚冰凉是什么原因
征求是什么意思 宫缩什么感觉 萎缩性胃炎是什么原因引起的 鸢是什么意思 下焦湿热吃什么药
男人蛋皮痒用什么药creativexi.com sakose是什么牌子hcv8jop0ns5r.cn 两个月没有来月经了是什么原因hcv7jop6ns1r.cn 疯狂动物城闪电是什么动物hcv9jop7ns4r.cn 丙二醇是什么东西hcv8jop7ns2r.cn
梦见奶奶死了是什么意思hcv9jop5ns9r.cn 咖啡有什么好处jinxinzhichuang.com 枸杞和什么一起泡水喝最好jingluanji.com karen是什么意思hcv9jop3ns7r.cn 2022年属虎的是什么命hcv8jop3ns5r.cn
肾阳虚吃什么药最好hcv8jop0ns9r.cn 抽烟头晕是什么原因hcv9jop5ns8r.cn 50公斤发什么物流便宜hcv9jop3ns5r.cn 脉弱是什么意思hcv9jop0ns7r.cn 孩子流鼻血是什么原因inbungee.com
豆芽菜是什么意思hcv8jop9ns6r.cn 什么事每人每天都必须认真的做hcv8jop4ns5r.cn 藏青和藏蓝有什么区别hcv8jop8ns7r.cn 女人脸肿是什么原因引起的helloaicloud.com 大口什么字hcv9jop5ns5r.cn
百度