{"id":1844,"date":"2023-05-04T06:56:03","date_gmt":"2023-05-04T06:56:03","guid":{"rendered":"https:\/\/blog.amt.in\/?p=1844"},"modified":"2023-05-04T06:56:03","modified_gmt":"2023-05-04T06:56:03","slug":"insights-on-xquery","status":"publish","type":"post","link":"https:\/\/blog.amt.in\/index.php\/2023\/05\/04\/insights-on-xquery\/","title":{"rendered":"Insights on XQuery"},"content":{"rendered":"<p>XQuery\u00c2\u00a0(XML Query) is a\u00c2\u00a0query\u00c2\u00a0and\u00c2\u00a0functional programming\u00c2\u00a0language that queries and transforms collections of structured and\u00c2\u00a0unstructured data, usually in the form of\u00c2\u00a0XML, text and with vendor-specific extensions for other data formats (JSON,\u00c2\u00a0binary, etc.). The language is developed by the XML Query\u00c2\u00a0working group\u00c2\u00a0of the\u00c2\u00a0W3C. The work is closely coordinated with the development of\u00c2\u00a0XSLT\u00c2\u00a0by the XSL Working Group; the two groups share responsibility for\u00c2\u00a0XPath, which is a subset of XQuery.<\/p>\n<p>XQuery 1.0\u00c2\u00a0became a\u00c2\u00a0W3C Recommendation\u00c2\u00a0on January 23, 2007.<\/p>\n<p>XQuery 3.0\u00c2\u00a0became a\u00c2\u00a0W3C Recommendation\u00c2\u00a0on April 8, 2014.<\/p>\n<p>XQuery 3.1\u00c2\u00a0became a\u00c2\u00a0W3C Recommendation\u00c2\u00a0on March 21, 2017.<\/p>\n<p>XQuery is a functional,\u00c2\u00a0side effect-free, expression-oriented programming language with a simple\u00c2\u00a0type system.<\/p>\n<p>XQuery provides the means to extract and manipulate data from XML documents or any data source that can be viewed as XML, such as\u00c2\u00a0relational databases\u00c2\u00a0or office documents.<\/p>\n<p>XQuery contains a superset of\u00c2\u00a0XPath\u00c2\u00a0expression syntax to address specific parts of an XML document. It supplements this with a\u00c2\u00a0SQL-like &#8220;FLWOR\u00c2\u00a0expression&#8221; for performing joins. A FLWOR expression is constructed from the five clauses after which it is named: FOR, LET, WHERE, ORDER BY, RETURN.<\/p>\n<p>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.<\/p>\n<p>The language is based on the\u00c2\u00a0XQuery and XPath Data Model\u00c2\u00a0(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.<\/p>\n<p>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\u00c2\u00a0XML Schema.<\/p>\n<p>Features for updating XML documents or databases, and\u00c2\u00a0full text search\u00c2\u00a0capability, 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.<\/p>\n<p>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).<\/p>\n<h4><span id=\"Scope\" class=\"mw-headline\">Scope:<\/span><\/h4>\n<p>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\u00c2\u00a0XSLT, which was designed expressly to allow input XML documents to be transformed into HTML or other formats.<\/p>\n<p>The XSLT 2.0 and XQuery standards were developed by separate working groups within\u00c2\u00a0W3C, working together to ensure a common approach where appropriate. They share the same data model (XDM), type system, and function library, and both include\u00c2\u00a0XPath\u00c2\u00a02.0 as a sublanguage.<\/p>\n<h4><span id=\"Origin\" class=\"mw-headline\">Origin:<\/span><\/h4>\n<p>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\u00c2\u00a0the web\u00c2\u00a0(as\u00c2\u00a0web template language), or on paper. XQuery was primarily conceived as a\u00c2\u00a0database query language\u00c2\u00a0in the tradition of\u00c2\u00a0SQL.<\/p>\n<p>Because the two languages originate in different communities, XSLT is stronger\u00c2\u00a0in its handling of narrative documents with more flexible structure, while XQuery is stronger in its data handling (for example, when performing relational joins).<\/p>\n<h4><span id=\"Versions\" class=\"mw-headline\">Versions:<\/span><\/h4>\n<p>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.\u00c2\u00a0Many of these features were planned for XQuery 3.0.<\/p>\n<p>Any comparison must take into account the fact that 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.<\/p>\n<p>The above is a brief about\u00c2\u00a0XQuery. Watch this space for more updates on the latest trends in Technology.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>XQuery\u00c2\u00a0(XML Query) is a\u00c2\u00a0query\u00c2\u00a0and\u00c2\u00a0functional programming\u00c2\u00a0language<\/p>\n","protected":false},"author":1,"featured_media":1846,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[154,655,7,654],"tags":[156,656,18,657],"class_list":["post-1844","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming-language","category-query","category-techtrends","category-xquery","tag-programming-language","tag-query","tag-technology","tag-xquery"],"_links":{"self":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/1844","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/comments?post=1844"}],"version-history":[{"count":1,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/1844\/revisions"}],"predecessor-version":[{"id":1845,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/1844\/revisions\/1845"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/media\/1846"}],"wp:attachment":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/media?parent=1844"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/categories?post=1844"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/tags?post=1844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}