background preloader

Xquery

Facebook Twitter

XQuery Tutorial. Converting XML to CSV Using XQuery. XQuery Examples: Introduction to XQuery. Example 1-1. Product catalog input document (catalog.xml) <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> Example 1-2. Price information input document (prices.xml) <prices><priceList effDate="2006-11-15"><prod num="557"><price currency="USD">29.99</price><discount type="CLR">10.00</discount></prod><prod num="563"><price currency="USD">69.99</price></prod><prod num="443"><price currency="USD">39.99</price><discount type="CLR">3.99</discount></prod></priceList></prices> Example 1-3.

Example 1-4. Example 1-5. Example 1-6. Example 1-7. XQuery. Welcome to the XQuery Examples Collection Wikibook! XQuery is a World Wide Web Consortium recommendation for selecting data from documents and databases. Current Status[edit] We are in the process of testing many of these examples using the eXist 2.0 release. Please let us know if you find any problems. We are looking for volunteers to help us create XQuery 3.0 examples. Recent Changes New and Revised Articles[edit] About this Project[edit] This is a collaborative project and we encourage everyone who is using XQuery to contribute their XQuery examples. Execution of examples use an eXist demo server. Instructors: please sign our Guest Registry if you are using this book for learning or teaching XQueryContributors: please see our Naming Conventions to ensure your examples are consistent with the textbookLearners: If you are looking for an example of a specific XQuery language construct, technique or problem but can't find an example, please add a suggestion to the Examples Wanted section.

XQuery Tutorials. Home > Learn XML > XML Tutorials > XQuery Tutorials These XQuery tutorials will give you the ability to query in ways you have never dreamed possible. With XQuery at your side, heterogeneous data sources don't stand a chance at hiding what your looking for! Learn XQuery in Ten Minutes "Learn XQuery in 10 Minutes" is for all those people who really want to know what XQuery is, but don't have the time to find out. Blooming FLWOR: An Introduction to the XQuery FLWOR Expression FLWOR expressions are a powerful and important part of XQuery in the same way as path expressions are at the heart of XPath.

An Introduction to XML Schema-Aware XSLT and XQuery Processing You wouldn't use XML without a Schema, so why are engineers so reckless when it comes to their XSLT and XQuery? Understanding XQuery Functions But you can also write serious applications in XQuery, and to do that you need to split the application into reusable components. Prev: "Data Integration Tutorials" Next: "XML Schema Tutorial"

XQuery Examples: Introduction to XQuery. XQuery/XQuery and XML Schema. Motivation[edit] In learning any modelling language, it is helpful to see sample instances of any formal model. This is equally true when developing an XML Schema. XML Development tools like Oxygen and XML-Spy have tools to generate a random instance of a supplied XML schema, but it is useful to have a web service to do this. The service can also be used for test data generation. The following is a test XML Schema file: Sample XML Schema[edit] <? XQuery to convert Simple XML Schema into an Instance Document[edit] We can use a recursive function to convert this XML Schema into an instance document.

This function uses the element construct to create a new XML instance tree based on the information in the XML Schema file and the typeswitch construct to select the appropriate processing of a given element type. Type Instance Generation[edit] Some helper functions are required to generate random instances of (some of ) the standard types. Script[edit] Execute Sample Output[edit] To do[edit]