Table of Contents. Preface... xvii

Size: px
Start display at page:

Download "Table of Contents. Preface... xvii"

Transcription

1 Table of Contents Preface xvii 1. Introduction to XQuery What Is XQuery? 1 Capabilities of XQuery 2 Uses for XQuery 2 Processing Scenarios 3 Easing into XQuery 4 Path Expressions 5 FLWORs 7 Adding XML Elements and Attributes 8 Adding Elements 9 Adding Attributes 11 Functions 11 Joins 12 Aggregating and Grouping Values XQuery Foundations The Design and History of the XQuery Language 15 XQuery in Context 16 XQuery and XPath 16 XQuery Versus XSLT 16 XQuery Versus SQL 17 XQuery and XML Schema 17 Processing Queries 18 Input Documents 18 The Query 19 The Context 20 iii

2 The Query Processor 20 The Results of the Query 21 The XQuery Data Model 21 Nodes 22 Atomic Values 26 Sequences 27 Types 28 Namespaces Expressions: XQuery Building Blocks Categories of Expressions 31 Keywords and Names 32 Whitespace in Queries 33 Literals 33 Variables 34 Function Calls 34 Comments 35 Precedence and Parentheses 35 Comparison Expressions 37 General Comparisons 37 Value Comparisons 38 Node Comparisons 40 Conditional (if-then-else) Expressions 41 Conditional Expressions and Effective Boolean Value 42 Nesting Conditional Expressions 43 Switch Expressions 43 Logical (and/or) Expressions 45 Precedence of Logical Expressions 45 Negating a Boolean Value Navigating XML by Using Paths Path Expressions 47 Path Expressions and Context 48 Steps 49 Axes 49 Node Tests 50 Abbreviated Syntax 53 Other Expressions as Steps 53 Predicates 54 Comparisons in Predicates 55 Using Positions in Predicates 56 Using Multiple Predicates 59 iv Table of Contents

3 More Complex Predicates 59 A Closer Look at Context 60 Working with the Context Node 61 Accessing the Root 61 Dynamic Paths 62 The Simple Map Operator Adding Elements and Attributes to Results Including Elements and Attributes from the Input Document 65 Direct Element Constructors 66 Containing Literal Characters 67 Containing Other Element Constructors 68 Containing Enclosed Expressions 68 Specifying Attributes Directly 71 Declaring Namespaces in Direct Constructors 72 Use Case: Modifying an Element from the Input Document 73 Direct Element Constructors and Whitespace 74 Computed Constructors 77 Computed Element Constructors 77 Computed Attribute Constructors 80 Use Case: Turning Content to Markup Selecting and Joining Using FLWORs Selecting with Path Expressions 83 FLWOR Expressions 83 The for Clause 85 The let Clause 88 The where Clause 89 The return Clause 90 The Scope of Variables 91 Quantified Expressions 91 Binding Multiple Variables 93 Selecting Distinct Values 93 Joins 95 Three-Way Joins 96 Outer Joins 96 Joins and Types Sorting and Grouping Sorting in XQuery 99 The order by Clause 99 The sort Function 103 Table of Contents v

4 Document Order 103 Document Order Comparisons 105 Reversing the Order 106 Indicating That Order Is Not Significant 106 Grouping 108 Grouping Using the group by Clause 109 Aggregating Values 112 Ignoring Missing Values 114 Counting Missing Values 115 Aggregating on Multiple Values 116 Constraining and Sorting on Aggregated Values Functions Built-in Versus User-Defined Functions 119 Calling Functions 119 Function Names 120 Function Signatures 121 Argument Lists 121 Sequence Types 123 Calling Functions with the Arrow Operator 124 User-Defined Functions 124 Why Define Your Own Functions? 124 Function Declarations 125 The Function Body 126 The Function Name 127 The Parameter List 127 Functions and Context 130 Recursive Functions Advanced Queries Working with Positions and Sequence Numbers 133 Adding Sequence Numbers to Results 133 Using the count Clause 135 Testing for the Last Item 137 Windowing 138 Using start and end Conditions 140 Windows Based on Position 141 Windows Based on Previous or Next Items 142 Sliding Windows 143 Copying Input Elements with Modifications 144 Adding Attributes to an Element 145 Removing Attributes from an Element 146 vi Table of Contents

5 Removing Attributes from All Descendants 147 Removing Child Elements 147 Changing Names 148 Combining Results 150 Sequence Constructors 150 The union Expression 151 The intersect Expression 151 The except Expression 151 Using Intermediate XML Documents 152 Creating Lookup Tables 152 Reducing Complexity Namespaces and XQuery XML Namespaces 157 Namespace URIs 157 Declaring Namespaces 158 Default Namespace Declarations 159 Namespaces and Attributes 159 Namespace Declarations and Scope 160 Namespaces and XQuery 161 Namespace Declarations in Queries 162 Predeclared Namespaces 162 Prolog Namespace Declarations 163 Namespace Declarations in Direct Element Constructors 166 Namespace Declarations in Computed Constructors 167 The Impact and Scope of Namespace Declarations 168 Controlling Namespace Declarations in Your Results 170 In-Scope Versus Statically Known Namespaces 171 Controlling the Copying of Namespace Declarations 174 URI-Qualified Names A Closer Look at Types The XQuery Type System 179 Advantages of a Strong Type System 179 Do You Need to Care About Types? 180 The Built-in Types 181 Atomic Types 181 List Types 183 Union Types 183 Types, Nodes, and Atomic Values 183 Nodes and Types 183 Atomic Values and Types 184 Table of Contents vii

6 Type Checking in XQuery 184 The Static Analysis Phase 184 The Dynamic Evaluation Phase 185 Automatic Type Conversions 185 Subtype Substitution 185 Type Promotion 186 Casting of Untyped Values 186 Atomization 186 Effective Boolean Value 187 Function Conversion Rules 189 Sequence Types 190 Occurrence Indicators 191 Generic Sequence Types 192 Simple Type Names as Sequence Types 193 Element and Attribute Tests 193 Sequence Type Matching 194 The instance of Expression 194 Constructors and Casting 195 Constructors 195 The Cast Expression 196 The Castable Expression 197 Casting Rules Prologs, Modules, and Variables Structure of a Query: Prolog and Body 201 Prolog Declarations 202 The Version Declaration 203 Assembling Queries from Multiple Modules 204 Library Modules 204 Importing a Library Module 205 Loading a Library Module Dynamically 207 Variable Declarations 208 Variable Declaration Syntax 208 The Scope of Variables 209 Variable Names 209 Initializing Expressions 210 External Variables 210 Private Functions and Variables 211 Declaring External Functions Inputs and Outputs Types of Input and Output Documents 213 viii Table of Contents

7 Accessing Input Documents 214 Accessing a Single Document with a Function 214 Accessing a Collection 215 Setting the Context Outside the Query 216 Using Variables 216 Setting the Context in the Prolog 217 Serializing Output 217 Serialization Methods 218 Serialization Parameters 220 Specifying Serialization Parameters by Using Option Declarations 224 Specifying Serialization Parameters by Using a Separate XML Document 225 Serialization Errors 226 Serializing to a String Using Schemas with XQuery What Is a Schema? 227 Why Use Schemas with Queries? 228 W3C XML Schema: A Brief Overview 230 Element and Attribute Declarations 230 Types 231 Namespaces and XML Schema 232 In-Scope Schema Definitions 233 Where Do In-Scope Schema Definitions Come From? 233 Schema Imports 234 Schema Validation and Type Assignment 236 The Validate Expression 236 Validation Mode 238 Assigning Type Annotations to Nodes 238 Nodes and Typed Values 239 Types and Newly Constructed Elements and Attributes 240 Sequence Types and Schemas Static Typing What Is Static Typing? 245 Obvious Static Type Errors 246 Static Typing and Schemas 246 Raising False Errors 247 Static Typing Expressions and Constructs 247 The Typeswitch Expression 248 The Treat Expression 250 Type Declarations 251 Type Declarations in FLWORs 251 Table of Contents ix

8 Type Declarations in Quantified Expressions 252 Type Declarations in Global Variable Declarations 253 The zero-or-one, one-or-more, and exactly-one Functions Writing Better Queries Query Design Goals 255 Clarity 256 Improving the Layout 256 Choosing Names 257 Using Comments for Documentation 257 Modularity 259 Robustness 259 Handling Data Variations 259 Handling Missing Values 260 Error Handling 262 Avoiding Dynamic Errors 262 The error and trace Functions 263 Try/Catch Expressions 263 Performance 265 Avoid Reevaluating the Same or Similar Expressions 266 Avoid Unnecessary Sorting 266 Avoid Expensive Path Expressions 267 Use Predicates Instead of where Clauses Working with Numbers The Numeric Types 269 The xs:decimal Type 269 The xs:integer Type 269 The xs:float and xs:double Types 270 The xs:numeric Type 270 Constructing Numeric Values 270 The number Function 271 Numeric Type Promotion 271 Comparing Numeric Values 272 Arithmetic Operations 273 Arithmetic Operations on Multiple Values 274 Arithmetic Operations and Types 274 Precedence of Arithmetic Operators 274 Addition, Subtraction, and Multiplication 275 Division 275 Modulus (Remainder) 276 Functions on Numbers 277 x Table of Contents

9 Formatting Numbers 279 Formatting Integers 279 Formatting Decimal Numbers 280 The Decimal Format Declaration Working with Strings The xs:string Type 283 Constructing Strings 283 String Literals 284 The xs:string Constructor and the string Function 284 Comparing Strings 284 Comparing Entire Strings 285 Determining Whether a String Contains Another String 285 Matching a String to a Pattern 286 Substrings 287 Finding the Length of a String 288 Concatenating and Splitting Strings 289 Concatenating Strings 289 Splitting Strings Apart 290 Converting Between Codepoints and Strings 291 Manipulating Strings 291 Converting Between Uppercase and Lowercase 291 Replacing Individual Characters in Strings 292 Replacing Substrings That Match a Pattern 292 Whitespace and Strings 294 Normalizing Whitespace 294 Internationalization Considerations 295 Collations 295 Unicode Normalization 297 Determining the Language of an Element Regular Expressions The Structure of a Regular Expression 299 Atoms 299 Quantifiers 299 Parenthesized Sub-Expressions and Branches 300 Representing Individual Characters 301 Representing Any Character 303 Representing Groups of Characters 303 Multi-Character Escapes 304 Category Escapes 304 Block Escapes 305 Table of Contents xi

10 Character Class Expressions 306 Single Characters and Ranges 306 Subtraction from a Range 307 Negative Character Class Expressions 307 Escaping Rules for Character Class Expressions 308 Reluctant Quantifiers 308 Anchors 309 Back-References 310 Using Flags 311 Using Sub-Expressions with Replacement Variables Working with Dates, Times, and Durations The Date and Time Types 315 Constructing and Casting Dates and Times 316 Time Zones 317 Comparing Dates and Times 318 The Duration Types 319 The xs:yearmonthduration and xs:daytimeduration Types 320 Comparing Durations 320 Extracting Components of Dates, Times, and Durations 321 Formatting Dates and Times 322 Using Arithmetic Operators on Dates, Times, and Durations 323 Subtracting Dates and Times 323 Adding and Subtracting Durations from Dates and Times 324 Adding and Subtracting Two Durations 325 Multiplying and Dividing Durations by Numbers 326 Dividing Durations by Durations 326 The Date Component Types Working with Qualified Names, URIs, and IDs Working with Qualified Names 329 Retrieving Node Names 330 Constructing Qualified Names 332 Other Name-Related Functions 333 Working with URIs 334 Base and Relative URIs 334 Documents and URIs 336 Escaping URIs 338 Working with IDs 339 Joining IDs and IDREFs 340 Constructing ID Attributes 341 Generating Unique ID Values 341 xii Table of Contents

11 22. Working with Other XML Constructs XML Comments 343 XML Comments and the Data Model 343 Querying Comments 344 Comments and Sequence Types 344 Constructing Comments 345 Processing Instructions 346 Processing Instructions and the Data Model 346 Querying Processing Instructions 347 Processing Instructions and Sequence Types 347 Constructing Processing Instructions 348 Documents 349 Document Nodes and the Data Model 349 Document Nodes and Sequence Types 350 Constructing Document Nodes 350 Text Nodes 351 Text Nodes and the Data Model 351 Querying Text Nodes 352 Text Nodes and Sequence Types 353 Why Work with Text Nodes? 353 Constructing Text Nodes 355 XML Entity and Character References 355 CDATA Sections Function Items and Higher-Order Functions Why Higher-Order Functions? 359 Constructing Functions and Calling Them Dynamically 360 Named Function References 360 Using function-lookup to Obtain a Function 361 Inline Function Expressions 361 Partial Function Application 362 The Arrow Operator and Dynamic Function Calls 363 Syntax Recap 363 Functions and Sequence Types 364 Higher-Order Functions 364 Built-In Higher-Order Functions 365 Writing Your Own Higher-Order Functions Maps, Arrays, and JSON Maps 369 Constructing Maps 369 Looking Up Map Values 371 Table of Contents xiii

12 Querying Maps 375 Changing Maps 375 Iterating over Entries in a Map 376 Maps and Sequence Types 376 Arrays 378 Constructing Arrays 378 Arrays Versus Sequences 379 Arrays and Atomization 380 Looking Up Array Values 380 Querying Arrays 382 Changing Arrays 383 Arrays and Sequence Types 384 JSON 385 Parsing JSON 385 Serializing JSON 386 Converting Between JSON and XML Implementation-Specific Features Conformance 391 Version Support 392 New Features in XQuery New Features in XQuery Setting the Query Context 394 The Option Declaration 395 Extension Expressions 396 Annotations XQuery for SQL Users Relational Versus XML Data Models 399 Comparing SQL Syntax with XQuery Syntax 401 A Simple Query 401 Conditions and Operators 402 Functions 404 Selecting Distinct Values 405 Working with Multiple Tables and Subqueries 406 Grouping 408 Combining SQL and XQuery 408 Combining Structured and Semi-Structured Data 409 Flexible Data Structures 409 SQL/XML 411 xiv Table of Contents

13 27. XQuery for XSLT Users XQuery and XPath 413 XQuery Versus XSLT 413 Shared Components 414 Equivalent Components 414 Differences 415 Using XQuery and XSLT Together 420 XQuery Backward Compatibility with XPath Data Model 421 New Expressions 422 Path Expressions 422 Function Conversion Rules 423 Arithmetic and Comparison Expressions 423 Built-in Functions Additional XQuery-Related Standards XQuery Update Facility 425 Full-Text Search 426 XQueryX 428 RESTXQ 430 XQuery API for Java (XQJ) 432 A. Built-in Function Reference B. Built-in Types C. Error Summary Index Table of Contents xv

14 CHAPTER 1 Introduction to XQuery This chapter provides background on the purpose and capabilities of XQuery. It also gives a quick introduction to the features of XQuery that are covered in more detail later in the book. It is designed to provide a basic familiarity with the most commonly used kinds of expressions, without getting too bogged down in the details. What Is XQuery? The use of XML has exploded in recent years. An enormous amount of information is now stored in XML, both in XML databases and in documents on a filesystem. This includes highly structured data such as sales figures, semi-structured data such as product catalogs and yellow pages, and relatively unstructured data such as letters and books. Even more information is passed between systems as transitory XML documents. All of this data is used for a variety of purposes. For example, sales figures may be useful for compiling financial statements that may be published on the Web, reporting results to the tax authorities, calculating bonuses for salespeople, or creating internal reports for planning. For each of these uses, we are interested in different elements of the data and expect it to be formatted and transformed according to our needs. XQuery is a query language designed by the W3C to address these needs. It allows you to select the XML data elements of interest, reorganize and possibly transform them, and return the results in a structure of your choosing. 1

15 Capabilities of XQuery XQuery has a rich set of features that allow many different types of operations on XML data and documents, including: Selecting information based on specific criteria Filtering out unwanted information Searching for information within a document or set of documents Joining data from multiple documents or collections of documents Sorting, grouping, and aggregating data Transforming and restructuring XML data into another XML vocabulary or structure Performing arithmetic calculations on numbers and dates Manipulating strings to reformat text As you can see, XQuery can be used not just to extract sections of XML documents, but also to manipulate and transform the results for output. In fact, XQuery is a Turing-complete functional programming language, which means you can also use it for general-purpose programming and application development, not just for querying data. Uses for XQuery There are as many reasons to query XML as there are reasons to use XML. Some examples of common uses for the XQuery language are: Finding textual documents in a native XML database and presenting styled results Generating reports on data stored in a database for presentation on the Web as HTML Extracting information from a relational database for use in a web service Pulling data from databases or packaged software and transforming it for application integration Combining content from traditionally non-xml sources to implement content management and delivery Ad hoc querying of standalone XML documents for the purposes of testing or research Building entire complex web applications 2 Chapter 1: Introduction to XQuery

16 Processing Scenarios XQuery s sweet spot is querying bodies of XML content that encompass many XML documents, often stored in databases. For this reason, it is sometimes called the SQL of XML. Some of the earliest XQuery implementations were in native XML database products. The term native XML database generally refers to a database that is designed for XML content from the ground up, as opposed to a traditionally relational database. Rather than being oriented around tables and columns, its data model is based on hierarchical documents and collections of documents. Native XML databases are most often used for narrative content and other data that is less predictable than what you would typically store in a relational database. Many of these products are now known by the broader term NoSQL database and provide support for not just XML but also JSON and other data formats. Examples of these database products that support XQuery are exist, MarkLogic Server, BaseX, Zorba, and EMC Documentum xdb. Of these, all but MarkLogic Server and EMC Documentum xdb are open source. These products provide the traditional capabilities of databases, such as data storage, indexing, querying, loading, extracting, backup, and recovery. Most of them also provide some added value in addition to their database capabilities. For example, they might provide advanced full-text searching functionality, document conversion services, or end-user interfaces. Major relational database products, including Oracle (via its XML DB), IBM DB2 (via purexml), and Microsoft SQL Server, also have support for XML and various versions of XQuery. Early implementations of XML in relational databases involved storing XML in table columns as blobs or character strings and providing query access to those columns. However, these vendors are increasingly blurring the line between native XML databases and relational databases with new features that allow you to store XML natively. Other XQuery processors are not embedded in a database product, but work independently. They might be used on physical XML documents stored as files on a file system or on the Web. They might also operate on XML data that is passed in memory from some other process. The most notable product in this category is Saxon, which has both open source and commercial versions. Altova s RaptorXML also provides support for standalone XQuery queries. XML editors provide support for editing and running XQuery queries and displaying the results. Some, like Altova s XMLSpy, have their own embedded XQuery implementations. Others, like oxygen XML Editor, allow you to run queries using one or more separate XQuery processors. If you are new to XQuery, a free trial license to a product like oxygen or XMLSpy is a good way to get started running queries. What Is XQuery? 3

17 Easing into XQuery The rest of this chapter takes you through a set of example queries, each of which builds on the previous one. Three XML documents are used repeatedly as input documents to the query examples throughout the book. They will be used so frequently that it may be worth printing them from the companion web site at so that you can view them alongside the examples. These three examples are quite simplistic, but they are useful for educational purposes because they are easy to learn and remember while looking at query examples. In reality, most XQuery queries will be executed against much more complex documents, and often against multiple documents as a collection. However, in order to keep the examples reasonably concise and clear, this book will work with smaller documents that have a representative mix of XML characteristics. The catalog.xml document is a product catalog containing general information about products (Example 1-1). 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> The prices.xml document contains prices for most of the products, based on an effective date (Example 1-2). 4 Chapter 1: Introduction to XQuery

18 Example 1-2. Price information input document (prices.xml) <prices> <pricelist effdate=" "> <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> The order.xml document is a simple order containing a list of products ordered (referenced by a number that matches the number used in catalog.xml), along with quantities and colors (Example 1-3). Example 1-3. Order input document (order.xml) <order num=" " date=" " cust="0221a"> <item dept="wmn" num="557" quantity="1" color="navy"/> <item dept="acc" num="563" quantity="1"/> <item dept="acc" num="443" quantity="2"/> <item dept="men" num="784" quantity="1" color="white"/> <item dept="men" num="784" quantity="1" color="gray"/> <item dept="wmn" num="557" quantity="1" color="black"/> </order> Path Expressions The most straightforward kind of query simply selects elements or attributes from an input document. This type of query is known as a path expression. For example, the path expression: doc("catalog.xml")/catalog/product will select all the product elements from the catalog.xml document. Path expressions are used to traverse an XML tree to select elements and attributes of interest. They are similar to paths used for filenames in many operating systems. They consist of a series of steps, separated by slashes, that traverse the elements and attributes in the XML documents. In this example, there are three steps: Path Expressions 5

19 1. doc("catalog.xml") calls an XQuery function named doc, passing it the name of the file to open 2. catalog selects the catalog element, the outermost element of the document 3. product selects all the product children of catalog The result of the query will be the four product elements, exactly as they appear (with the same attributes and contents) in the input document. Example 1-4 shows the complete result. Example 1-4. Four product elements selected from the 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> The asterisk (*) can be used as a wildcard to indicate any element name. For example, the path expression: doc("catalog.xml")/*/product will return any product children of the outermost element, regardless of the outermost element s name. Alternatively, you can use a double slash (//) to return product elements that appear anywhere in the catalog document, as in: doc("catalog.xml")//product In addition to traversing the XML document, a path expression can contain predicates that filter out elements or attributes that do not meet a particular criterion. Predicates are indicated by square brackets. For example, the path expression: doc("catalog.xml")/catalog/product[@dept = "ACC"] 6 Chapter 1: Introduction to XQuery

20 contains a predicate. It selects only those product elements whose dept attribute value is ACC. sign is used to indicate that dept is an attribute as opposed to a child element. When a predicate contains a number, it serves as an index. For example: doc("catalog.xml")/catalog/product[2] will return the second product element in the catalog. Path expressions are convenient because of their compact, easy-to-remember syntax. However, they have a limitation: they can only return elements and attributes as they appear in input documents. Any elements selected in a path expression appear in the results with the same names, the same attributes and contents, and in the same order as in the input document. When you select the product elements, you get them with all of their children and with their dept attributes. Path expressions are covered in detail in Chapter 4. FLWORs The basic structure of many (but not all) queries is the FLWOR expression. FLWOR (pronounced flower ) stands for for, let, where, order by, return, the most common keywords used in the expression. FLWORs, unlike path expressions, allow you to manipulate, transform, and sort your results. Example 1-5 shows a simple FLWOR that returns the names of all products in the ACC department. Example 1-5. Simple FLWOR Query for $prod in doc("catalog.xml")/catalog/product where $prod/@dept = "ACC" order by $prod/name return $prod/name Results <name language="en">deluxe Travel Bag</name> <name language="en">floppy Sun Hat</name> As you can see, the FLWOR is made up of several parts: for This clause sets up an iteration through the product elements, and the rest of the FLWOR is evaluated once for each of the four products. Each time, a variable FLWORs 7

21 named $prod is bound to a different product element. Dollar signs are used to indicate variable names in XQuery. where This clause selects only products in the ACC department. This has the same effect as a predicate ([@dept = "ACC"]) in a path expression. order by This clause sorts the results by product name, something that is not possible with path expressions. return This clause indicates that the product element s name children should be returned in the query result. The let clause (the L in FLWOR) is used to bind the value of a variable. Unlike a for clause, it does not set up an iteration. Example 1-6 shows a FLWOR that returns the same result as Example 1-5. The second line is a let clause that binds the product element s name child to a variable called $name. The $name variable is then referenced later in the FLWOR, in both the order by clause and the return clause. Example 1-6. Adding a let clause for $prod in doc("catalog.xml")/catalog/product let $name := $prod/name where $prod/@dept = "ACC" order by $name return $name The let clause serves as a programmatic convenience that avoids repeating the same expression multiple times. With some implementations, it may improve performance because the expression is evaluated only once instead of each time it is needed. This chapter has provided only very basic examples of FLWORs. In fact, FLWORs can become quite complex. Multiple for clauses are permitted, which set up iterations within iterations. Additional clauses such as group by, count, and window are available. In addition, complex expressions can be used in any of the clauses. FLWORs are discussed in detail in Chapter 6. Even more advanced examples of FLWORs are provided in Chapter 9. Adding XML Elements and Attributes Sometimes you want to reorganize or transform the elements in the input documents into differently named or structured elements. XML constructors can be used to create elements and attributes that appear in the query results. 8 Chapter 1: Introduction to XQuery

22 Adding Elements Suppose you want to wrap the results of your query in a different XML vocabulary, for example, XHTML. You can do this using a familiar XML-like syntax. To wrap the name elements in a ul element, for instance, you can use the query shown in Example 1-7. The ul element represents an unordered list in HTML. Example 1-7. Wrapping results in a new element Query <ul>{ for $prod in doc("catalog.xml")/catalog/product where $prod/@dept='acc' order by $prod/name return $prod/name }</ul> Results <ul> <name language="en">deluxe Travel Bag</name> <name language="en">floppy Sun Hat</name> </ul> This example is the same as Example 1-5, with the addition of the first and last lines. In the query, the ul start tag and end tag, and everything in between, is known as an element constructor. The curly braces around the content of the ul element signify that it is an expression (known as an enclosed expression) that is to be evaluated. In this case, the enclosed expression returns two elements, which become children of ul. Any content in an element constructor that is not inside curly braces appears in the results as is. For example: <h1>there are {count(doc("catalog.xml")//product)} products.</h1> will return the result: <h1>there are 4 products.</h1> The content outside the curly braces, namely the strings "There are " and " products.", appear literally in the results, as textual content of the h1 element. The element constructor does not need to be the outermost expression in the query. You can include element constructors at various places in your query. For example, if you want to wrap each resulting name element in its own li element, you could use the query shown in Example 1-8. An li element represents a list item in HTML. Adding XML Elements and Attributes 9

23 Example 1-8. Element constructor in FLWOR return clause Query <ul>{ for $prod in doc("catalog.xml")/catalog/product where order by $prod/name return <li>{$prod/name}</li> }</ul> Results <ul> <li><name language="en">deluxe Travel Bag</name></li> <li><name language="en">floppy Sun Hat</name></li> </ul> Here, the li element constructor appears in the return clause of a FLWOR. Since the return clause is evaluated once for each iteration of the for clause, two li elements appear in the results, each with a name element as its child. However, suppose you don t want to include the name elements at all, just their contents. You can do this by calling a built-in function called data, which extracts the contents of an element. This is shown in Example 1-9. Example 1-9. Using the data function Query <ul>{ for $prod in doc("catalog.xml")/catalog/product where $prod/@dept='acc' order by $prod/name return <li>{data($prod/name)}</li> }</ul> Results <ul> <li>deluxe Travel Bag</li> <li>floppy Sun Hat</li> </ul> Now no name elements appear in the results. In fact, no elements at all from the input document appear. 10 Chapter 1: Introduction to XQuery

24 Adding Attributes You can also add your own attributes to results using an XML-like syntax. Example 1-10 adds attributes to the ul and li elements. Example Adding attributes to results Query <ul type="square">{ for $prod in doc("catalog.xml")/catalog/product where order by $prod/name return <li }</ul> Results <ul type="square"> <li class="acc">deluxe Travel Bag</li> <li class="acc">floppy Sun Hat</li> </ul> As you can see, attribute values, like element content, can either be literal text or enclosed expressions. The ul element constructor has an attribute type that is included as is in the results, while the li element constructor has an attribute class whose value is an enclosed expression delimited by curly braces. In attribute values, unlike element content, you don t need to use the data function to extract the value: it happens automatically. The constructors shown in these examples are known as direct constructors, because they use an XML-like syntax. You can also construct elements and attributes with dynamically determined names, using computed constructors. Chapter 5 provides detailed coverage of XML constructors. Functions Almost 200 functions are built into XQuery, covering a broad range of functionality. Functions can be used to manipulate strings and dates, perform mathematical calculations, combine sequences of elements, and perform many other useful jobs. You can also define your own functions, either in the query itself, or in an external library. Both built-in and user-defined functions can be called from almost any place in a query. For instance, Example 1-9 calls the doc function in a for clause, and the data function in an enclosed expression. Chapter 8 explains how to call functions and also Functions 11

25 describes how to write your own user-defined functions. Appendix A lists all the built-in functions and explains each of them in detail. Joins One of the major benefits of FLWORs is that they can easily join data from multiple sources. For example, suppose you want to join information from your product catalog (catalog.xml) and your order (order.xml). You want a list of all the items in the order, along with their number, name, and quantity. The name comes from the product catalog, and the quantity comes from the order. The product number appears in both input documents, so it is used to join the two sources. Example 1-11 shows a FLWOR that performs this join. Example Joining multiple input documents Query for $item in doc("order.xml")//item let $name := doc("catalog.xml")//product[number = $item/@num]/name return <item num="{$item/@num}" name="{$name}" quan="{$item/@quantity}"/> Results <item num="557" name="fleece Pullover" quan="1"/> <item num="563" name="floppy Sun Hat" quan="1"/> <item num="443" name="deluxe Travel Bag" quan="2"/> <item num="784" name="cotton Dress Shirt" quan="1"/> <item num="784" name="cotton Dress Shirt" quan="1"/> <item num="557" name="fleece Pullover" quan="1"/> The for clause sets up an iteration through each item from the order. For each item, the let clause goes to the product catalog and gets the name of the product. It does this by finding the product element whose number child equals the item s num attribute, and selecting its name child. Because the FLWOR iterated six times, the results contain one new item element for each of the six item elements in the order document. Joins are covered in Chapter 6. Aggregating and Grouping Values One common use for XQuery is to summarize and group XML data. It is sometimes useful to find the sum, average, or maximum of a sequence of values, grouped by a particular value. For example, suppose you want to know the number of items contained in an order, grouped by department. The query shown in Example 1-12 accomplishes this. It uses a group by clause to group the items by department, and 12 Chapter 1: Introduction to XQuery

26 the sum function to calculate the totals of the quantity attribute values for the items in each department. Example Aggregating values Query xquery version "3.0"; for $i in doc("order.xml")//item let $d := group by $d order by $d return <department name="{$d}" Results <department name="acc" totquantity="3"/> <department name="men" totquantity="2"/> <department name="wmn" totquantity="2"/> Chapter 7 covers sorting, grouping, and aggregating values in detail. The version declaration on the first line of this example is used to show that use of the group by clause requires at least version 3.0 of XQuery. Aggregating and Grouping Values 13

2nd Edition. XQuery SEARCH ACROSS A VARIETY OF XML DATA. Priscilla Walmsley

2nd Edition. XQuery SEARCH ACROSS A VARIETY OF XML DATA. Priscilla Walmsley 2nd Edition XQuery SEARCH ACROSS A VARIETY OF XML DATA Priscilla Walmsley O Reilly ebooks. Your bookshelf on your devices. PDF Mobi epub DAISY When you buy an ebook through oreilly.com you get lifetime

More information

Navigating Input Documents Using Paths4

Navigating Input Documents Using Paths4 Chapter 4 CHAPTER 4 Navigating Input Documents Using Paths4 Path expressions are used to navigate input documents to select elements and attributes of interest. This chapter explains how to use path expressions

More information

Next Generation Query and Transformation Standards. Priscilla Walmsley Managing Director, Datypic

Next Generation Query and Transformation Standards. Priscilla Walmsley Managing Director, Datypic Next Generation Query and Transformation Standards Priscilla Walmsley Managing Director, Datypic http://www.datypic.com pwalmsley@datypic.com 1 Agenda The query and transformation landscape Querying XML

More information

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 27-1

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 27-1 Slide 27-1 Chapter 27 XML: Extensible Markup Language Chapter Outline Introduction Structured, Semi structured, and Unstructured Data. XML Hierarchical (Tree) Data Model. XML Documents, DTD, and XML Schema.

More information

Pre-Discussion. XQuery: An XML Query Language. Outline. 1. The story, in brief is. Other query languages. XML vs. Relational Data

Pre-Discussion. XQuery: An XML Query Language. Outline. 1. The story, in brief is. Other query languages. XML vs. Relational Data Pre-Discussion XQuery: An XML Query Language D. Chamberlin After the presentation, we will evaluate XQuery. During the presentation, think about consequences of the design decisions on the usability of

More information

XML databases. Jan Chomicki. University at Buffalo. Jan Chomicki (University at Buffalo) XML databases 1 / 9

XML databases. Jan Chomicki. University at Buffalo. Jan Chomicki (University at Buffalo) XML databases 1 / 9 XML databases Jan Chomicki University at Buffalo Jan Chomicki (University at Buffalo) XML databases 1 / 9 Outline 1 XML data model 2 XPath 3 XQuery Jan Chomicki (University at Buffalo) XML databases 2

More information

info-h-509 xml technologies Lecture 6: XQuery Stijn Vansummeren February 14, 2017

info-h-509 xml technologies Lecture 6: XQuery Stijn Vansummeren February 14, 2017 info-h-509 xml technologies Lecture 6: XQuery Stijn Vansummeren February 14, 2017 Introduction our story so far XML is a standard notation for documents and data We can select parts of XML with XPath We

More information

Advanced Database Technologies XQuery

Advanced Database Technologies XQuery Advanced Database Technologies XQuery Christian Grün Database & Information Systems Group Introduction What is XQuery? query language (more than a) counterpart to SQL functional language general purpose

More information

XPath Expression Syntax

XPath Expression Syntax XPath Expression Syntax SAXON home page Contents Introduction Constants Variable References Parentheses and operator precedence String Expressions Boolean Expressions Numeric Expressions NodeSet expressions

More information

Table of Contents Chapter 1 - Introduction Chapter 2 - Designing XML Data and Applications Chapter 3 - Designing and Managing XML Storage Objects

Table of Contents Chapter 1 - Introduction Chapter 2 - Designing XML Data and Applications Chapter 3 - Designing and Managing XML Storage Objects Table of Contents Chapter 1 - Introduction 1.1 Anatomy of an XML Document 1.2 Differences Between XML and Relational Data 1.3 Overview of DB2 purexml 1.4 Benefits of DB2 purexml over Alternative Storage

More information

XML: Extensible Markup Language

XML: Extensible Markup Language XML: Extensible Markup Language CSC 375, Fall 2015 XML is a classic political compromise: it balances the needs of man and machine by being equally unreadable to both. Matthew Might Slides slightly modified

More information

SQL Queries. for. Mere Mortals. Third Edition. A Hands-On Guide to Data Manipulation in SQL. John L. Viescas Michael J. Hernandez

SQL Queries. for. Mere Mortals. Third Edition. A Hands-On Guide to Data Manipulation in SQL. John L. Viescas Michael J. Hernandez SQL Queries for Mere Mortals Third Edition A Hands-On Guide to Data Manipulation in SQL John L. Viescas Michael J. Hernandez r A TT TAddison-Wesley Upper Saddle River, NJ Boston Indianapolis San Francisco

More information

Burrows & Langford Appendix D page 1 Learning Programming Using VISUAL BASIC.NET

Burrows & Langford Appendix D page 1 Learning Programming Using VISUAL BASIC.NET Burrows & Langford Appendix D page 1 APPENDIX D XSLT XSLT is a programming language defined by the World Wide Web Consortium, W3C (http://www.w3.org/tr/xslt), that provides the mechanism to transform a

More information

Chapter 13 XML: Extensible Markup Language

Chapter 13 XML: Extensible Markup Language Chapter 13 XML: Extensible Markup Language - Internet applications provide Web interfaces to databases (data sources) - Three-tier architecture Client V Application Programs Webserver V Database Server

More information

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix PGJC4_JSE8_OCA.book Page ix Monday, June 20, 2016 2:31 PM Contents Figures Tables Examples Foreword Preface xix xxi xxiii xxvii xxix 1 Basics of Java Programming 1 1.1 Introduction 2 1.2 Classes 2 Declaring

More information

The PCAT Programming Language Reference Manual

The PCAT Programming Language Reference Manual The PCAT Programming Language Reference Manual Andrew Tolmach and Jingke Li Dept. of Computer Science Portland State University September 27, 1995 (revised October 15, 2002) 1 Introduction The PCAT language

More information

COPYRIGHTED MATERIAL. Contents. Part I: Introduction 1. Chapter 1: What Is XML? 3. Chapter 2: Well-Formed XML 23. Acknowledgments

COPYRIGHTED MATERIAL. Contents. Part I: Introduction 1. Chapter 1: What Is XML? 3. Chapter 2: Well-Formed XML 23. Acknowledgments Acknowledgments Introduction ix xxvii Part I: Introduction 1 Chapter 1: What Is XML? 3 Of Data, Files, and Text 3 Binary Files 4 Text Files 5 A Brief History of Markup 6 So What Is XML? 7 What Does XML

More information

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this

More information

Chapter 17. Fundamental Concepts Expressed in JavaScript

Chapter 17. Fundamental Concepts Expressed in JavaScript Chapter 17 Fundamental Concepts Expressed in JavaScript Learning Objectives Tell the difference between name, value, and variable List three basic data types and the rules for specifying them in a program

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

XPath. Asst. Prof. Dr. Kanda Runapongsa Saikaew Dept. of Computer Engineering Khon Kaen University

XPath. Asst. Prof. Dr. Kanda Runapongsa Saikaew Dept. of Computer Engineering Khon Kaen University XPath Asst. Prof. Dr. Kanda Runapongsa Saikaew (krunapon@kku.ac.th) Dept. of Computer Engineering Khon Kaen University 1 Overview What is XPath? Queries The XPath Data Model Location Paths Expressions

More information

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments. Java How to Program, 9/e Education, Inc. All Rights Reserved. } Java application programming } Use tools from the JDK to compile and run programs. } Videos at www.deitel.com/books/jhtp9/ Help you get started

More information

One of the main selling points of a database engine is the ability to make declarative queries---like SQL---that specify what should be done while

One of the main selling points of a database engine is the ability to make declarative queries---like SQL---that specify what should be done while 1 One of the main selling points of a database engine is the ability to make declarative queries---like SQL---that specify what should be done while leaving the engine to choose the best way of fulfilling

More information

CHAPTER 1: INTRODUCING C# 3

CHAPTER 1: INTRODUCING C# 3 INTRODUCTION xix PART I: THE OOP LANGUAGE CHAPTER 1: INTRODUCING C# 3 What Is the.net Framework? 4 What s in the.net Framework? 4 Writing Applications Using the.net Framework 5 What Is C#? 8 Applications

More information

Introduction to XQuery and XML Databases

Introduction to XQuery and XML Databases Introduction to XQuery and XML Databases TEI@Oxford July 2009 XQuery While XSLT is good for transforming XML to other formats (XML, HTML, PDF, Text, etc.) sometimes you may wish to query a large database

More information

Introduction to XQuery. Overview. Basic Principles. .. Fall 2007 CSC 560: Management of XML Data Alexander Dekhtyar..

Introduction to XQuery. Overview. Basic Principles. .. Fall 2007 CSC 560: Management of XML Data Alexander Dekhtyar.. .. Fall 2007 CSC 560: Management of XML Data Alexander Dekhtyar.. Overview Introduction to XQuery XQuery is an XML query language. It became a World Wide Web Consortium Recommendation in January 2007,

More information

Big Data 12. Querying

Big Data 12. Querying Ghislain Fourny Big Data 12. Querying pinkyone / 123RF Stock Photo Declarative Languages What vs. How 2 Functional Languages for let order by if + any else = then every while where return exit with Expression

More information

Big Data 10. Querying

Big Data 10. Querying Ghislain Fourny Big Data 10. Querying pinkyone / 123RF Stock Photo 1 Declarative Languages What vs. How 2 Functional Languages for let order by if + any else = then every while where return exit with Expression

More information

M359 Block5 - Lecture12 Eng/ Waleed Omar

M359 Block5 - Lecture12 Eng/ Waleed Omar Documents and markup languages The term XML stands for extensible Markup Language. Used to label the different parts of documents. Labeling helps in: Displaying the documents in a formatted way Querying

More information

FRAC: Language Reference Manual

FRAC: Language Reference Manual FRAC: Language Reference Manual Justin Chiang jc4127 Kunal Kamath kak2211 Calvin Li ctl2124 Anne Zhang az2350 1. Introduction FRAC is a domain-specific programming language that enables the programmer

More information

Progress Report on XQuery

Progress Report on XQuery Progress Report on XQuery Don Chamberlin Almaden Research Center May 24, 2002 History Dec. '98: W3C sponsors workshop on XML Query Oct. '99: W3C charters XML Query working group Chair: Paul Cotton About

More information

A Web-Based Introduction

A Web-Based Introduction A Web-Based Introduction to Programming Essential Algorithms, Syntax, and Control Structures Using PHP, HTML, and MySQL Third Edition Mike O'Kane Carolina Academic Press Durham, North Carolina Contents

More information

BEAWebLogic. Integration. Transforming Data Using XQuery Mapper

BEAWebLogic. Integration. Transforming Data Using XQuery Mapper BEAWebLogic Integration Transforming Data Using XQuery Mapper Version: 10.2 Document Revised: March 2008 Contents Introduction Overview of XQuery Mapper.............................................. 1-1

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Working with XML and DB2

Working with XML and DB2 Working with XML and DB2 What is XML? XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to carry data, not to display data XML tags are not predefined.

More information

XQuery 1.0: An XML Query Language

XQuery 1.0: An XML Query Language XQuery 1.0: An XML Query Language W3C Recommendation 23 January 2007 This version: Latest version: http://www.w3.org/tr/2007/rec-xquery-20070123/ http://www.w3.org/tr/xquery/ Previous version: http://www.w3.org/tr/2006/pr-xquery-20061121/

More information

Delivery Options: Attend face-to-face in the classroom or remote-live attendance.

Delivery Options: Attend face-to-face in the classroom or remote-live attendance. XML Programming Duration: 5 Days Price: $2795 *California residents and government employees call for pricing. Discounts: We offer multiple discount options. Click here for more info. Delivery Options:

More information

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved. Assoc. Prof. Dr. Marenglen Biba (C) 2010 Pearson Education, Inc. All rights reserved. Java application A computer program that executes when you use the java command to launch the Java Virtual Machine

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss Chapter 1 terminology (parenthesized numbers are page numbers) Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement

More information

Language. f SQL. Larry Rockoff COURSE TECHNOLOGY. Kingdom United States. Course Technology PTR. A part ofcenqaqe Learninq

Language. f SQL. Larry Rockoff COURSE TECHNOLOGY. Kingdom United States. Course Technology PTR. A part ofcenqaqe Learninq Language f SQL Larry Rockoff Course Technology PTR A part ofcenqaqe Learninq *, COURSE TECHNOLOGY!» CENGAGE Learning- Australia Brazil Japan Korea Mexico Singapore Spain United Kingdom United States '

More information

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */ Overview Language Basics This chapter describes the basic elements of Rexx. It discusses the simple components that make up the language. These include script structure, elements of the language, operators,

More information

Java EE 7: Back-end Server Application Development 4-2

Java EE 7: Back-end Server Application Development 4-2 Java EE 7: Back-end Server Application Development 4-2 XML describes data objects called XML documents that: Are composed of markup language for structuring the document data Support custom tags for data

More information

"Charting the Course to Your Success!" MOC D Querying Microsoft SQL Server Course Summary

Charting the Course to Your Success! MOC D Querying Microsoft SQL Server Course Summary Course Summary Description This 5-day instructor led course provides students with the technical skills required to write basic Transact-SQL queries for Microsoft SQL Server 2014. This course is the foundation

More information

Navigation. 3.1 Introduction. 3.2 Paths

Navigation. 3.1 Introduction. 3.2 Paths 03Brundage_ch03.qxd 1/8/04 1:09 PM Page 63 C H A P T E R 3 Navigation 3.1 Introduction Once you ve constructed or loaded XML in a query, you need a way to navigate over that hierarchical data. In many

More information

Pace University. Fundamental Concepts of CS121 1

Pace University. Fundamental Concepts of CS121 1 Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction

More information

Scenario Manager User Guide. Release September 2013

Scenario Manager User Guide. Release September 2013 Scenario Manager User Guide Release 6.2.1 September 2013 Scenario Manager User Guide Release 6.2.1 September 2013 Document Control Number: 9MN12-62110017 Document Number: SMUG-13-FCCM-0017-6.2.1-01 Oracle

More information

Part VII. Querying XML The XQuery Data Model. Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2005/06 153

Part VII. Querying XML The XQuery Data Model. Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2005/06 153 Part VII Querying XML The XQuery Data Model Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2005/06 153 Outline of this part 1 Querying XML Documents Overview 2 The XQuery Data Model The XQuery

More information

Optional SQL Feature Summary

Optional SQL Feature Summary Optional SQL Feature Summary The following table lists all optional features included in the SQL standard, from SQL- 2003 to SQL-2016. It also indicates which features that are currently supported by Mimer

More information

IT 374 C# and Applications/ IT695 C# Data Structures

IT 374 C# and Applications/ IT695 C# Data Structures IT 374 C# and Applications/ IT695 C# Data Structures Module 2.1: Introduction to C# App Programming Xianrong (Shawn) Zheng Spring 2017 1 Outline Introduction Creating a Simple App String Interpolation

More information

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics Java Programming, Sixth Edition 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics Additional Projects Additional

More information

The SPL Programming Language Reference Manual

The SPL Programming Language Reference Manual The SPL Programming Language Reference Manual Leonidas Fegaras University of Texas at Arlington Arlington, TX 76019 fegaras@cse.uta.edu February 27, 2018 1 Introduction The SPL language is a Small Programming

More information

1 Lexical Considerations

1 Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

More information

Who This Book Is For What This Book Covers How This Book Is Structured What You Need to Use This Book. Source Code

Who This Book Is For What This Book Covers How This Book Is Structured What You Need to Use This Book. Source Code Contents Introduction Who This Book Is For What This Book Covers How This Book Is Structured What You Need to Use This Book Conventions Source Code Errata p2p.wrox.com xxi xxi xxii xxii xxiii xxiii xxiv

More information

Chapter 2 XML, XML Schema, XSLT, and XPath

Chapter 2 XML, XML Schema, XSLT, and XPath Summary Chapter 2 XML, XML Schema, XSLT, and XPath Ryan McAlister XML stands for Extensible Markup Language, meaning it uses tags to denote data much like HTML. Unlike HTML though it was designed to carry

More information

Typescript on LLVM Language Reference Manual

Typescript on LLVM Language Reference Manual Typescript on LLVM Language Reference Manual Ratheet Pandya UNI: rp2707 COMS 4115 H01 (CVN) 1. Introduction 2. Lexical Conventions 2.1 Tokens 2.2 Comments 2.3 Identifiers 2.4 Reserved Keywords 2.5 String

More information

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery. HTML5/CSS3/JavaScript Programming Course Summary Description This class is designed for students that have experience with basic HTML concepts that wish to learn about HTML Version 5, Cascading Style Sheets

More information

Variable Scope The Main() Function Struct Functions Overloading Functions Using Delegates Chapter 7: Debugging and Error Handling Debugging in Visual

Variable Scope The Main() Function Struct Functions Overloading Functions Using Delegates Chapter 7: Debugging and Error Handling Debugging in Visual Table of Contents Title Page Introduction Who This Book Is For What This Book Covers How This Book Is Structured What You Need to Use This Book Conventions Source Code Errata p2p.wrox.com Part I: The OOP

More information

Teradata SQL Features Overview Version

Teradata SQL Features Overview Version Table of Contents Teradata SQL Features Overview Version 14.10.0 Module 0 - Introduction Course Objectives... 0-4 Course Description... 0-6 Course Content... 0-8 Module 1 - Teradata Studio Features Optimize

More information

Our Strategy for Learning Fortran 90

Our Strategy for Learning Fortran 90 Our Strategy for Learning Fortran 90 We want to consider some computational problems which build in complexity. evaluating an integral solving nonlinear equations vector/matrix operations fitting data

More information

Basics of Java Programming

Basics of Java Programming Basics of Java Programming Lecture 2 COP 3252 Summer 2017 May 16, 2017 Components of a Java Program statements - A statement is some action or sequence of actions, given as a command in code. A statement

More information

UNIT 3 XML DATABASES

UNIT 3 XML DATABASES UNIT 3 XML DATABASES XML Databases: XML Data Model DTD - XML Schema - XML Querying Web Databases JDBC Information Retrieval Data Warehousing Data Mining. 3.1. XML Databases: XML Data Model The common method

More information

Semi-structured Data. 8 - XPath

Semi-structured Data. 8 - XPath Semi-structured Data 8 - XPath Andreas Pieris and Wolfgang Fischl, Summer Term 2016 Outline XPath Terminology XPath at First Glance Location Paths (Axis, Node Test, Predicate) Abbreviated Syntax What is

More information

CSC Web Technologies, Spring Web Data Exchange Formats

CSC Web Technologies, Spring Web Data Exchange Formats CSC 342 - Web Technologies, Spring 2017 Web Data Exchange Formats Web Data Exchange Data exchange is the process of transforming structured data from one format to another to facilitate data sharing between

More information

Oracle Database 11g: SQL and PL/SQL Fundamentals

Oracle Database 11g: SQL and PL/SQL Fundamentals Oracle University Contact Us: +33 (0) 1 57 60 20 81 Oracle Database 11g: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn In this course, students learn the fundamentals of SQL and PL/SQL

More information

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual Contents 1 Introduction...2 2 Lexical Conventions...2 3 Types...3 4 Syntax...3 5 Expressions...4 6 Declarations...8 7 Statements...9

More information

CGS 3066: Spring 2015 JavaScript Reference

CGS 3066: Spring 2015 JavaScript Reference CGS 3066: Spring 2015 JavaScript Reference Can also be used as a study guide. Only covers topics discussed in class. 1 Introduction JavaScript is a scripting language produced by Netscape for use within

More information

ARG! Language Reference Manual

ARG! Language Reference Manual ARG! Language Reference Manual Ryan Eagan, Mike Goldin, River Keefer, Shivangi Saxena 1. Introduction ARG is a language to be used to make programming a less frustrating experience. It is similar to C

More information

XQuery. Leonidas Fegaras University of Texas at Arlington. Web Databases and XML L7: XQuery 1

XQuery. Leonidas Fegaras University of Texas at Arlington. Web Databases and XML L7: XQuery 1 XQuery Leonidas Fegaras University of Texas at Arlington Web Databases and XML L7: XQuery 1 XQuery Influenced by SQL Based on XPath Purely functional language may access elements from documents, may construct

More information

CS112 Lecture: Primitive Types, Operators, Strings

CS112 Lecture: Primitive Types, Operators, Strings CS112 Lecture: Primitive Types, Operators, Strings Last revised 1/24/06 Objectives: 1. To explain the fundamental distinction between primitive types and reference types, and to introduce the Java primitive

More information

"Charting the Course... MOC C: Querying Data with Transact-SQL. Course Summary

Charting the Course... MOC C: Querying Data with Transact-SQL. Course Summary Course Summary Description This course is designed to introduce students to Transact-SQL. It is designed in such a way that the first three days can be taught as a course to students requiring the knowledge

More information

CSE 142 Su 04 Computer Programming 1 - Java. Objects

CSE 142 Su 04 Computer Programming 1 - Java. Objects Objects Objects have state and behavior. State is maintained in instance variables which live as long as the object does. Behavior is implemented in methods, which can be called by other objects to request

More information

Oracle 11g: XML Fundamentals

Oracle 11g: XML Fundamentals Oracle 11g: XML Fundamentals Student Guide D52500GC10 Edition 1.0 December 2007 D53762 Authors Chaitanya Koratamaddi Salome Clement Technical Contributors and Reviewers Bijoy Choudhury Isabelle Cornu Ken

More information

In addition to the primary macro syntax, the system also supports several special macro types:

In addition to the primary macro syntax, the system also supports several special macro types: The system identifies macros using special parentheses. You need to enclose macro expressions into curly brackets and the percentage symbol: {% expression %} Kentico provides an object-oriented language

More information

DBS2: Exkursus XQuery and XML-Databases. Jan Sievers Jens Hündling Lars Trieloff

DBS2: Exkursus XQuery and XML-Databases. Jan Sievers Jens Hündling Lars Trieloff DBS2: Exkursus XQuery and XML-Databases Jan Sievers Jens Hündling Lars Trieloff Motivation XML ubiquitous data exchange format Can be used to present Object data, relational data, semi-structured data

More information

XML and information exchange. XML extensible Markup Language XML

XML and information exchange. XML extensible Markup Language XML COS 425: Database and Information Management Systems XML and information exchange 1 XML extensible Markup Language History 1988 SGML: Standard Generalized Markup Language Annotate text with structure 1992

More information

Lecture 3 Tao Wang 1

Lecture 3 Tao Wang 1 Lecture 3 Tao Wang 1 Objectives In this chapter, you will learn about: Arithmetic operations Variables and declaration statements Program input using the cin object Common programming errors C++ for Engineers

More information

H2 Spring B. We can abstract out the interactions and policy points from DoDAF operational views

H2 Spring B. We can abstract out the interactions and policy points from DoDAF operational views 1. (4 points) Of the following statements, identify all that hold about architecture. A. DoDAF specifies a number of views to capture different aspects of a system being modeled Solution: A is true: B.

More information

Chapter 7. Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel

Chapter 7. Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel 1 In this chapter, you will learn: The basic commands

More information

Delivery Options: Attend face-to-face in the classroom or via remote-live attendance.

Delivery Options: Attend face-to-face in the classroom or via remote-live attendance. XML Programming Duration: 5 Days US Price: $2795 UK Price: 1,995 *Prices are subject to VAT CA Price: CDN$3,275 *Prices are subject to GST/HST Delivery Options: Attend face-to-face in the classroom or

More information

Chapter 1: Getting Started. You will learn:

Chapter 1: Getting Started. You will learn: Chapter 1: Getting Started SGML and SGML document components. What XML is. XML as compared to SGML and HTML. XML format. XML specifications. XML architecture. Data structure namespaces. Data delivery,

More information

Programming Languages Third Edition. Chapter 9 Control I Expressions and Statements

Programming Languages Third Edition. Chapter 9 Control I Expressions and Statements Programming Languages Third Edition Chapter 9 Control I Expressions and Statements Objectives Understand expressions Understand conditional statements and guards Understand loops and variation on WHILE

More information

Absolute C++ Walter Savitch

Absolute C++ Walter Savitch Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents

More information

Ryan Stephens. Ron Plew Arie D. Jones. Sams Teach Yourself FIFTH EDITION. 800 East 96th Street, Indianapolis, Indiana, 46240

Ryan Stephens. Ron Plew Arie D. Jones. Sams Teach Yourself FIFTH EDITION. 800 East 96th Street, Indianapolis, Indiana, 46240 Ryan Stephens Ron Plew Arie D. Jones Sams Teach Yourself FIFTH EDITION 800 East 96th Street, Indianapolis, Indiana, 46240 Table of Contents Part I: An SQL Concepts Overview HOUR 1: Welcome to the World

More information

XML 2 APPLICATION. Chapter SYS-ED/ COMPUTER EDUCATION TECHNIQUES, INC.

XML 2 APPLICATION. Chapter SYS-ED/ COMPUTER EDUCATION TECHNIQUES, INC. XML 2 APPLIATION hapter SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. Objectives You will learn: How to create an XML document. The role of the document map, prolog, and XML declarations. Standalone declarations.

More information

Chapter 1 Readme.doc definitions you need to know 1

Chapter 1 Readme.doc definitions you need to know 1 Contents Foreword xi Preface to the second edition xv Introduction xvii Chapter 1 Readme.doc definitions you need to know 1 Sample data 1 Italics 1 Introduction 1 Dimensions, measures, members and cells

More information

Bonus Content. Glossary

Bonus Content. Glossary Bonus Content Glossary ActiveX control: A reusable software component that can be added to an application, reducing development time in the process. ActiveX is a Microsoft technology; ActiveX components

More information

Semistructured Data and XML

Semistructured Data and XML Semistructured Data and XML Computer Science E-66 Harvard University David G. Sullivan, Ph.D. Structured Data The logical models we've covered thus far all use some type of schema to define the structure

More information

XML. Semi-structured data (SSD) SSD Graphs. SSD Examples. Schemas for SSD. More flexible data model than the relational model.

XML. Semi-structured data (SSD) SSD Graphs. SSD Examples. Schemas for SSD. More flexible data model than the relational model. Semi-structured data (SSD) XML Semistructured data XML, DTD, (XMLSchema) XPath, XQuery More flexible data model than the relational model. Think of an object structure, but with the type of each object

More information

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL)

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management Tenth Edition Chapter 7 Introduction to Structured Query Language (SQL) Objectives In this chapter, students will learn: The basic commands and

More information

JME Language Reference Manual

JME Language Reference Manual JME Language Reference Manual 1 Introduction JME (pronounced jay+me) is a lightweight language that allows programmers to easily perform statistic computations on tabular data as part of data analysis.

More information

Seleniet XPATH Locator QuickRef

Seleniet XPATH Locator QuickRef Seleniet XPATH Locator QuickRef Author(s) Thomas Eitzenberger Version 0.2 Status Ready for review Page 1 of 11 Content Selecting Nodes...3 Predicates...3 Selecting Unknown Nodes...4 Selecting Several Paths...5

More information

"Charting the Course... MOC C: Developing SQL Databases. Course Summary

Charting the Course... MOC C: Developing SQL Databases. Course Summary Course Summary Description This five-day instructor-led course provides students with the knowledge and skills to develop a Microsoft SQL database. The course focuses on teaching individuals how to use

More information

XML Query Languages. Yanlei Diao UMass Amherst April 22, Slide content courtesy of Ramakrishnan & Gehrke, Donald Kossmann, and Gerome Miklau

XML Query Languages. Yanlei Diao UMass Amherst April 22, Slide content courtesy of Ramakrishnan & Gehrke, Donald Kossmann, and Gerome Miklau XML Query Languages Yanlei Diao UMass Amherst April 22, 2008 Slide content courtesy of Ramakrishnan & Gehrke, Donald Kossmann, and Gerome Miklau 1 Querying XML How do you query a directed graph? a tree?

More information

XML Path Language (XPath)

XML Path Language (XPath) 2.0 W3C Recommendation 23 January 2007 This version: Latest version: http://www.w3.org/tr/2007/rec-xpath20-20070123/ http://www.w3.org/tr/xpath20/ Previous version: http://www.w3.org/tr/2006/pr-xpath20-20061121/

More information

The Warhol Language Reference Manual

The Warhol Language Reference Manual The Warhol Language Reference Manual Martina Atabong maa2247 Charvinia Neblett cdn2118 Samuel Nnodim son2105 Catherine Wes ciw2109 Sarina Xie sx2166 Introduction Warhol is a functional and imperative programming

More information

The XQuery Data Model

The XQuery Data Model The XQuery Data Model 9. XQuery Data Model XQuery Type System Like for any other database query language, before we talk about the operators of the language, we have to specify exactly what it is that

More information

Big Data Exercises. Fall 2016 Week 9 ETH Zurich

Big Data Exercises. Fall 2016 Week 9 ETH Zurich Big Data Exercises Fall 2016 Week 9 ETH Zurich Introduction This exercise will cover XQuery. You will be using oxygen (https://www.oxygenxml.com/xml_editor/software_archive_editor.html), AN XML/JSON development

More information

Introduction to Computer Science and Business

Introduction to Computer Science and Business Introduction to Computer Science and Business The Database Programming with PL/SQL course introduces students to the procedural language used to extend SQL in a programatic manner. This course outline

More information

XML Systems & Benchmarks

XML Systems & Benchmarks XML Systems & Benchmarks Christoph Staudt Peter Chiv Saarland University, Germany July 1st, 2003 Main Goals of our talk Part I Show up how databases and XML come together Make clear the problems that arise

More information

Querying purexml Part 1 The Basics

Querying purexml Part 1 The Basics Information Management Emerging Partnerships and Technologies IBM Toronto Lab Summer/Fall 2010 Querying purexml Part 1 The Basics Li Chen, Shumin Wu Questions to malaika@us.ibm.com http://www.ibm.com/developerworks/wikis/display/db2xml/devotee

More information