XQuery Tools from Altova
What is XQuery?XQuery (XML Query) is a recently introduced recommendation from the World Wide Web Consortium (W3C) that defines a query language for extracting data from XML files and databases, and producing results in XML markup. XQuery shares a common data model with XPath 2.0, and uses XPath syntax to operate on sequences of nodes within XML documents. In fact, XPath is actually a subset of the XQuery language, meaning that any valid XPath expression is also valid XQuery. Where XQuery expands upon the XPath standard is in its ability to perform more complex operations such as on-the-fly result-set transformations, record selection based on FLWOR expressions, joins, and recursion based on built-in functions. XQuery FunctionsXQuery includes over 100 built-in functions for numeric values, string values, Boolean values, date and time comparisons, regular expressions, node and QName manipulation, and more. These are defined in the W3C’s XQuery 1.0 and XPath 2.0 Functions and Operators, which also gives direction for creating constructor functions based on XML Schema and user-defined datatypes. The standard XQuery functions can also be augmented using the define function clause. XQuery functions are used to return or create sequences. For example, the XQuery function fn:doc is used to return the document nodes found at a specified URI, while a slightly more complex aggregate function (count, avg, max, min, sum) will perform calculations using a specified sequence as an argument. XQuery ExpressionsXQuery arguments take the form of expressions, which specify the node value(s) for processors to return in the result tree. Path Expressions The XQuery specification uses path expressions (based on the same syntax as XPath 2.0), constructed from a combination of keywords, symbols, and operands, to navigate through nodes in an XML document. Predicates are used to limit the data that is returned based on interpreted element values. For example, the simple path expression below would return all of the books published by Addison-Wesley from our selected document.
Node Constructor Expressions Because it was designed for use with XML, a highly flexible markup language that can be used to represent just about anything, XQuery stands apart from other query languages with a unique ability to transform both the content and structure of result values. Element constructor expressions can be used to generate new nodes in XML or virtually any other output format based on the result of a query. Elements, attributes, comments, processing instructions, and text nodes can be computed based on any expression, generating new content on-the-fly. For example, the simple element constructor expression below takes build on our path expression example to output the result-set in an HTML list:
XQuery element constructors can be embedded inside complex queries (such as FLWOR expressions), or vice versa, making recursive functions, or loops, relatively easy to execute. FLWOR Expressions In the tradition of SQL select statements, FLWOR (For-Let-Where-Order By-Return) expressions, are extremely versatile queries that are used to bind variables to intermediate results for processing. For example, the very basic FLWOR expression below returns all books published by Addison-Wesley, including the associated copyright year and title.
FLWOR expressions are most often used to perform joins, iterating over and combining data from multiple sources into a single result. For example, the join below will integrate the bibliography data from our original document with a price list and output a single result tree.
XQuery vs. XSLTMuch has been made of the overlap that XQuery has with XSLT 2.0, and there are many intentional similarities between two languages, partly as a result of the close collaboration between the responsible Working Groups. They both incorporate the entirety of XPath 2.0 for data selection, pull datatypes from XML Schema, and share a universal function library. But these two standards were designed for different purposes, and though they can oftentimes be used interchangeably, they are ideally suited for different tasks. XSLT was primarily developed as a mechanism for transforming one XML document into another XML document, as well as for rendering XML content into human-readable output such as HTML, while XQuery, true to its name, is primarily a query language for manipulating structured data assets, similar to SQL, and is, therefore, best used for extracting data that matches certain criteria from a larger dataset. XQuery vs. SQLStructured Query Language (SQL) sits on the other side of the fence as a language that also has a good deal in common with XQuery. In contrast with XSLT, SQL and XQuery are targeting the same development community. XQuery differs from SQL in that it is primarily targeted at XML and can also handle relational data, whereas SQL is primarily focused on relational data, but can also handle XML. More specifically, SQL/XML is an extension to the SQL standard that provides specific functionality for querying XML data stored in relational databases via SQL statements. Altova Toos for XQuery DevelopmentXMLSpy XMLSpy includes native, schema-aware support for XQuery development with AltovaXML™, its built-in, standards-conformant XQuery engine, which is also available as a free download for use in your applications. To make learning and working with XQuery as easy as possible, XMLSpy includes intelligent editing features such as syntax coloring, context sensitive entry helpers, and code completion, as well as an XQuery debugger and XQuery profiler (see below). The XMLSpy XQuery Debugger allows you to test and perfect your XQuery code as you’re writing it. You can set breakpoints on any expression in the XQuery document and any node(s) in the associated XML file to halt the debugger whenever that particular instruction or node is accessed. This provides you with an immediate visual understanding of the way that your XQuery document is processing the XML data.
The XMLSpy XQuery profiler monitors your XQuery code as it runs and record how long each process takes. You can then use this information to determine which parts of the code are taking the longest time and optimize any problem areas or bottlenecks.
MapForce MapForce autogenerates standards-conformant XQuery code for mapping one XML Schema to another XML Schema. Using its intuitive visual interface, MapForce allows you to define data mappings graphically and then generate XQuery code to implement the data transformation. The ability to generate XQuery code allows you work with XQuery in a native implementation with MapForce acting as a visual XQuery builder. The XQuery code generated by MapForce can then be executed in an XML-enabled database. AltovaXML XQuery Processor AltovaXML is a free XML standards processor that includes the Altova schema-aware XQuery processor, XSLT 1.0 processor, schema-aware XSLT 2.0 processor, and XML validating parser. Now you can use the same engines found in Altova XMLSpy, MapForce, and StyleVision in your own applications, royalty-free. AltovaXML includes COM, Java, and .NET interfaces and supports command line operations. Learn more and download AltovaXML® 2012.
|
| |||||||||||||||||||||||||||||||||||||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
