Home arrow XML arrow Page 5 - XQuery, concluded
XML

XQuery, concluded


XQuery speeds up the process of finding information contained in an XML document -- which is very handy when dealing with long XML documents. This article, the second of two parts, will teach you how to write XQuery expressions. It is excerpted from chapter nine of the book XML DeMYSTiFieD, written by Jim Keogh and Ken Davidson (McGraw-Hill/Osborne, 2005; ISBN: 0072262109).

Author Info:
By: McGraw-Hill/Osborne
Rating: 5 stars5 stars5 stars5 stars5 stars / 9
February 16, 2006
TABLE OF CONTENTS:
  1. · XQuery, concluded
  2. · Retrieving the Value of an Attribute
  3. · Retrieving the Value of an Attribute and the Attribute Name
  4. · Functions
  5. · Looking Ahead

print this article
SEARCH DEVARTICLES

XQuery, concluded - Looking Ahead
(Page 5 of 5 )

XQuery is used to query information contained in an XML document. The XQuery is processed by the XQuery processor. Some of these processors are freeware or open source and others are commercial software products.

An XQuery is typed into an editor and saved to a file that contains the .xq file extension. The XQuery file is then passed to the XQuery processor as a command line argument. The result of the XQuery is contained in the output.html file, which you can open in your browser.

An XQuery contains conditional expressions that define search criteria. A conditional expression can be either true or false. Portions of the XML document that meet the search criteria are copied to the output.html file.

XML Demystified

The for and let clauses are used to assign values to variables within the XQuery. The order by clause is used to sort the results in ascending or descending order. The where clause specifies a filter criteria using the conditional expression and the return clause identifies information that the XQuery processor returns to the output .html file.

In the next chapter you’ll learn about MSXML, which lets you combine the power of XML and programming languages such as JavaScript, Visual Basic, and C++ when using Microsoft’s XML Core Services.

Quiz

  1. Saxon-B is the only software that can process an XQuery.

    a. True

    b. False
  2. What kind of clause is used to specify the filter criteria?

    a. SQL clause

    b. Declarative clause

    c. where clause

    d. None of the above 
  3. $x is an

    a. Element

    b. Attribute

    c. XQuery

    d. Variable 
  4. Order by

    a. Places all elements in the XML document in ascending order

    b. Places all elements in the XML document in descending order

    c. Places all return values in ascending order by default

    d. Places all return values in descending order by default 
  5. The where clause

    a. Locates the XML document

    b. Locates the output file

    c. Specifies the filter criteria

    d. All of the above 
  6. All functions used by an XQuery are built-in functions.

    a. True

    b. False 
  7. The data() function returns the text value of a variable.

    a. True

    b. False 
  8. A constructor

    a. Converts information contained in an XML document to another data type

    b. Is the first instance of a function

    c. Is the first instance of a variable

    d. None of the above 
  9. The doc() function retrieves an XML document.

    a. True

    b. False
  10. The round-half-to-even() function rounds half the value returned by a function.

    a. True

    b. False

DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus
XML ARTICLES

- Open XML Finally Supported by MS Office
- XML Features Added to Two Systems
- Using Regions with XSL Formatting Objects
- Using XSL Formatting Objects
- More Schematron Features
- Schematron Patterns and Validation
- Using Schematron
- Datatypes and More in RELAX NG
- Providing Options in RELAX NG
- An Introduction to RELAX NG
- Path, Predicates, and XQuery
- Using Predicates with XQuery
- Navigating Input Documents Using Paths
- XML Basics
- Introduction to XPath

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials