advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Download the code for this article
Partners & Affiliates
advertisement
advertisement
advertisement
Average Rating: 3.5/5 | Rate this item | 2 users have rated this item.
 

Introduction to XQuery (Part 2 of 4)

The XQuery data model recognizes seven types of nodes. Learn how to take advantage of the data model in XQuery expressions  


 
 
 
 
advertisement
ou can find a quick introduction to the XQuery language with examples of several kinds of XQuery expressions in Part I of this series. In this part you'll explore some basic XQuery concepts.


Data Model
XQuery's data model describes the values that occur in the evaluation of a query; the inputs, outputs and intermediate values that occur during the processing of a query are all instances of the data model. The XQuery data model contains these important categories of values:

Simple Typed Values. A simple typed value conforms to a simple type as defined by the XML Schema specification, which includes strings, integers, dates etc. You can find the complete list of simple types in the XML Schema specification—Part 2.

Nodes. The XQuery data model recognizes seven types of nodes: document, element, attribute, text, comment, processing-instruction and namespace nodes. The model treats XML documents and document fragments as trees of nodes. A document is a tree with the document node as the root of the tree. Similarly a document fragment is a tree with an element at its root. Document nodes and namespace nodes have no parents. All other nodes can have zero or one parent. Only a document node or an element node can have children. Here's a simple xml document and the corresponding data model instance.

   <?xml version="1.0"?>
   <greetings>
      <!—Welcome message -->
      <welcome>Hello XQuery User</welcome>
   </greetings>

The data model instance representing this document looks like Figure 1:

Figure 1: The data model representing a simple XML document containing a <greeting> root element and a <welcome> element that holds a text message.


Sequences. A sequence is an ordered list of simple values or nodes. Sequences are flat, which means that a sequence cannot contain another sequence as its member. A sequence containing only one member is referred to as a singleton sequence. From a data model point of view, there is no distinction between a singleton sequence containing a simple value and the simple value itself.

Query Expressions. Expressions are the top-level abstraction of every element in XQuery, and are the basic building blocks of XQuery. There are several kinds of expression defined in the latest specification:

  • Constants and Variables
  • Operators
  • Path Expressions
  • FLWR (For-Let-Where-Return) expressions
  • Element/Attribute Constructors
  • Conditional expressions
  • Quantified Expressions
  • Built-in and User Defined Functions
  Next Page: Constants and Variables


Page 1: IntroductionPage 3: Operators
Page 2: Constants and VariablesPage 4: Path Expressions (XPath 2.0)
Please rate this item (5=best)
 1  2  3  4  5
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs