
XQuery
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
The W3C XQuery 3.1 standard provides a tool to search, extract, and manipulate content, whether it''s in XML, JSON or plain text. With this fully updated, in-depth tutorial, you'll learn to program with this highly practical query language.
Designed for query writers who have some knowledge of XML basics, but not necessarily advanced knowledge of XML-related technologies, this book is ideal as both a tutorial and a reference. You'll find background information for namespaces, schemas, built-in types, and regular expressions that are relevant to writing XML queries.
This second edition provides:
- A high-level overview and quick tour of XQuery
- New chapters on higher-order functions, maps, arrays, and JSON
- A carefully paced tutorial that teaches XQuery without being bogged down by the details
- Advanced concepts for taking advantage of modularity, namespaces, typing, and schemas
- Guidelines for working with specific types of data, such as numbers, strings, dates, URIs, maps and arrays
- XQuery's implementation-specific features and its relationship to other standards including SQL and XSLT
- A complete alphabetical reference to the built-in functions, types, and error messages
More details
Other editions
Additional editions

Content
- Cover
- Copyright
- Table of Contents
- Preface
- Contents of This Book
- Reading the Syntax Diagrams
- Conventions Used in This Book
- Using Code Examples
- Useful Functions
- O'Reilly Safari
- We'd Like to Hear from You
- Acknowledgments
- Chapter 1. Introduction to XQuery
- What Is XQuery?
- Capabilities of XQuery
- Uses for XQuery
- Processing Scenarios
- Easing into XQuery
- Path Expressions
- FLWORs
- Adding XML Elements and Attributes
- Adding Elements
- Adding Attributes
- Functions
- Joins
- Aggregating and Grouping Values
- Chapter 2. XQuery Foundations
- The Design and History of the XQuery Language
- XQuery in Context
- XQuery and XPath
- XQuery Versus XSLT
- XQuery Versus SQL
- XQuery and XML Schema
- Processing Queries
- Input Documents
- The Query
- The Context
- The Query Processor
- The Results of the Query
- The XQuery Data Model
- Nodes
- Atomic Values
- Sequences
- Types
- Namespaces
- Chapter 3. Expressions: XQuery Building Blocks
- Categories of Expressions
- Keywords and Names
- Whitespace in Queries
- Literals
- Variables
- Function Calls
- Comments
- Precedence and Parentheses
- Comparison Expressions
- General Comparisons
- Value Comparisons
- Node Comparisons
- Conditional (if-then-else) Expressions
- Conditional Expressions and Effective Boolean Value
- Nesting Conditional Expressions
- Switch Expressions
- Logical (and/or) Expressions
- Precedence of Logical Expressions
- Negating a Boolean Value
- Chapter 4. Navigating XML by Using Paths
- Path Expressions
- Path Expressions and Context
- Steps
- Axes
- Node Tests
- Abbreviated Syntax
- Other Expressions as Steps
- Predicates
- Comparisons in Predicates
- Using Positions in Predicates
- Using Multiple Predicates
- More Complex Predicates
- A Closer Look at Context
- Working with the Context Node
- Accessing the Root
- Dynamic Paths
- The Simple Map Operator
- Chapter 5. Adding Elements and Attributes to Results
- Including Elements and Attributes from the Input Document
- Direct Element Constructors
- Containing Literal Characters
- Containing Other Element Constructors
- Containing Enclosed Expressions
- Specifying Attributes Directly
- Declaring Namespaces in Direct Constructors
- Use Case: Modifying an Element from the Input Document
- Direct Element Constructors and Whitespace
- Computed Constructors
- Computed Element Constructors
- Computed Attribute Constructors
- Use Case: Turning Content to Markup
- Chapter 6. Selecting and Joining Using FLWORs
- Selecting with Path Expressions
- FLWOR Expressions
- The for Clause
- The let Clause
- The where Clause
- The return Clause
- The Scope of Variables
- Quantified Expressions
- Binding Multiple Variables
- Selecting Distinct Values
- Joins
- Three-Way Joins
- Outer Joins
- Joins and Types
- Chapter 7. Sorting and Grouping
- Sorting in XQuery
- The order by Clause
- The sort Function
- Document Order
- Document Order Comparisons
- Reversing the Order
- Indicating That Order Is Not Significant
- Grouping
- Grouping Using the group by Clause
- Aggregating Values
- Ignoring "Missing" Values
- Counting "Missing" Values
- Aggregating on Multiple Values
- Constraining and Sorting on Aggregated Values
- Chapter 8. Functions
- Built-in Versus User-Defined Functions
- Calling Functions
- Function Names
- Function Signatures
- Argument Lists
- Sequence Types
- Calling Functions with the Arrow Operator
- User-Defined Functions
- Why Define Your Own Functions?
- Function Declarations
- The Function Body
- The Function Name
- The Parameter List
- Functions and Context
- Recursive Functions
- Chapter 9. Advanced Queries
- Working with Positions and Sequence Numbers
- Adding Sequence Numbers to Results
- Using the count Clause
- Testing for the Last Item
- Windowing
- Using start and end Conditions
- Windows Based on Position
- Windows Based on Previous or Next Items
- Sliding Windows
- Copying Input Elements with Modifications
- Adding Attributes to an Element
- Removing Attributes from an Element
- Removing Attributes from All Descendants
- Removing Child Elements
- Changing Names
- Combining Results
- Sequence Constructors
- The union Expression
- The intersect Expression
- The except Expression
- Using Intermediate XML Documents
- Creating Lookup Tables
- Reducing Complexity
- Chapter 10. Namespaces and XQuery
- XML Namespaces
- Namespace URIs
- Declaring Namespaces
- Default Namespace Declarations
- Namespaces and Attributes
- Namespace Declarations and Scope
- Namespaces and XQuery
- Namespace Declarations in Queries
- Predeclared Namespaces
- Prolog Namespace Declarations
- Namespace Declarations in Direct Element Constructors
- Namespace Declarations in Computed Constructors
- The Impact and Scope of Namespace Declarations
- Controlling Namespace Declarations in Your Results
- In-Scope Versus Statically Known Namespaces
- Controlling the Copying of Namespace Declarations
- URI-Qualified Names
- Chapter 11. A Closer Look at Types
- The XQuery Type System
- Advantages of a Strong Type System
- Do You Need to Care About Types?
- The Built-in Types
- Atomic Types
- List Types
- Union Types
- Types, Nodes, and Atomic Values
- Nodes and Types
- Atomic Values and Types
- Type Checking in XQuery
- The Static Analysis Phase
- The Dynamic Evaluation Phase
- Automatic Type Conversions
- Subtype Substitution
- Type Promotion
- Casting of Untyped Values
- Atomization
- Effective Boolean Value
- Function Conversion Rules
- Sequence Types
- Occurrence Indicators
- Generic Sequence Types
- Simple Type Names as Sequence Types
- Element and Attribute Tests
- Sequence Type Matching
- The instance of Expression
- Constructors and Casting
- Constructors
- The Cast Expression
- The Castable Expression
- Casting Rules
- Chapter 12. Prologs, Modules, and Variables
- Structure of a Query: Prolog and Body
- Prolog Declarations
- The Version Declaration
- Assembling Queries from Multiple Modules
- Library Modules
- Importing a Library Module
- Loading a Library Module Dynamically
- Variable Declarations
- Variable Declaration Syntax
- The Scope of Variables
- Variable Names
- Initializing Expressions
- External Variables
- Private Functions and Variables
- Declaring External Functions
- Chapter 13. Inputs and Outputs
- Types of Input and Output Documents
- Accessing Input Documents
- Accessing a Single Document with a Function
- Accessing a Collection
- Setting the Context Outside the Query
- Using Variables
- Setting the Context in the Prolog
- Serializing Output
- Serialization Methods
- Serialization Parameters
- Specifying Serialization Parameters by Using Option Declarations
- Specifying Serialization Parameters by Using a Separate XML Document
- Specifying Serialization Parameters by Using a Map
- Serialization Errors
- Serializing to a String
- Chapter 14. Using Schemas with XQuery
- What Is a Schema?
- Why Use Schemas with Queries?
- W3C XML Schema: A Brief Overview
- Element and Attribute Declarations
- Types
- Namespaces and XML Schema
- In-Scope Schema Definitions
- Where Do In-Scope Schema Definitions Come From?
- Schema Imports
- Schema Validation and Type Assignment
- The Validate Expression
- Validation Mode
- Assigning Type Annotations to Nodes
- Nodes and Typed Values
- Types and Newly Constructed Elements and Attributes
- Sequence Types and Schemas
- Chapter 15. Static Typing
- What Is Static Typing?
- Obvious Static Type Errors
- Static Typing and Schemas
- Raising "False" Errors
- Static Typing Expressions and Constructs
- The Typeswitch Expression
- The Treat Expression
- Type Declarations
- Type Declarations in FLWORs
- Type Declarations in Quantified Expressions
- Type Declarations in Global Variable Declarations
- The zero-or-one, one-or-more, and exactly-one Functions
- Chapter 16. Writing Better Queries
- Query Design Goals
- Clarity
- Improving the Layout
- Choosing Names
- Using Comments for Documentation
- Modularity
- Robustness
- Handling Data Variations
- Handling Missing Values
- Error Handling
- Avoiding Dynamic Errors
- The error and trace Functions
- Try/Catch Expressions
- Performance
- Avoid Reevaluating the Same or Similar Expressions
- Avoid Unnecessary Sorting
- Avoid Expensive Path Expressions
- Use Predicates Instead of where Clauses
- Chapter 17. Working with Numbers
- The Numeric Types
- The xs:decimal Type
- The xs:integer Type
- The xs:float and xs:double Types
- The xs:numeric Type
- Constructing Numeric Values
- The number Function
- Numeric Type Promotion
- Comparing Numeric Values
- Arithmetic Operations
- Arithmetic Operations on Multiple Values
- Arithmetic Operations and Types
- Precedence of Arithmetic Operators
- Addition, Subtraction, and Multiplication
- Division
- Modulus (Remainder)
- Functions on Numbers
- Formatting Numbers
- Formatting Integers
- Formatting Decimal Numbers
- The Decimal Format Declaration
- Chapter 18. Working with Strings
- The xs:string Type
- Constructing Strings
- String Literals
- The xs:string Constructor and the string Function
- String Constructors
- Comparing Strings
- Comparing Entire Strings
- Determining Whether a String Contains Another String
- Matching a String to a Pattern
- Substrings
- Finding the Length of a String
- Concatenating and Splitting Strings
- Concatenating Strings
- Splitting Strings Apart
- Converting Between Codepoints and Strings
- Manipulating Strings
- Converting Between Uppercase and Lowercase
- Replacing Individual Characters in Strings
- Replacing Substrings That Match a Pattern
- Whitespace and Strings
- Normalizing Whitespace
- Internationalization Considerations
- Collations
- Unicode Normalization
- Determining the Language of an Element
- Chapter 19. Regular Expressions
- The Structure of a Regular Expression
- Atoms
- Quantifiers
- Parenthesized Sub-Expressions and Branches
- Representing Individual Characters
- Representing Any Character
- Representing Groups of Characters
- Multi-Character Escapes
- Category Escapes
- Block Escapes
- Character Class Expressions
- Single Characters and Ranges
- Subtraction from a Range
- Negative Character Class Expressions
- Escaping Rules for Character Class Expressions
- Reluctant Quantifiers
- Anchors
- Back-References
- Using Flags
- Using Sub-Expressions with Replacement Variables
- Chapter 20. Working with Dates, Times, and Durations
- The Date and Time Types
- Constructing and Casting Dates and Times
- Time Zones
- Comparing Dates and Times
- The Duration Types
- The xs:yearMonthDuration and xs:dayTimeDuration Types
- Comparing Durations
- Extracting Components of Dates, Times, and Durations
- Formatting Dates and Times
- Using Arithmetic Operators on Dates, Times, and Durations
- Subtracting Dates and Times
- Adding and Subtracting Durations from Dates and Times
- Adding and Subtracting Two Durations
- Multiplying and Dividing Durations by Numbers
- Dividing Durations by Durations
- The Date Component Types
- Chapter 21. Working with Qualified Names, URIs, and IDs
- Working with Qualified Names
- Retrieving Node Names
- Constructing Qualified Names
- Other Name-Related Functions
- Working with URIs
- Base and Relative URIs
- Documents and URIs
- Escaping URIs
- Working with IDs
- Joining IDs and IDREFs
- Constructing ID Attributes
- Generating Unique ID Values
- Chapter 22. Working with Other XML Constructs
- XML Comments
- XML Comments and the Data Model
- Querying Comments
- Comments and Sequence Types
- Constructing Comments
- Processing Instructions
- Processing Instructions and the Data Model
- Querying Processing Instructions
- Processing Instructions and Sequence Types
- Constructing Processing Instructions
- Documents
- Document Nodes and the Data Model
- Document Nodes and Sequence Types
- Constructing Document Nodes
- Text Nodes
- Text Nodes and the Data Model
- Querying Text Nodes
- Text Nodes and Sequence Types
- Why Work with Text Nodes?
- Constructing Text Nodes
- XML Entity and Character References
- CDATA Sections
- Chapter 23. Function Items and Higher-Order Functions
- Why Higher-Order Functions?
- Constructing Functions and Calling Them Dynamically
- Named Function References
- Using function-lookup to Obtain a Function
- Inline Function Expressions
- Partial Function Application
- The Arrow Operator and Dynamic Function Calls
- Syntax Recap
- Functions and Sequence Types
- Higher-Order Functions
- Built-In Higher-Order Functions
- Writing Your Own Higher-Order Functions
- Chapter 24. Maps, Arrays, and JSON
- Maps
- Constructing Maps
- Looking Up Map Values
- Querying Maps
- Changing Maps
- Iterating over Entries in a Map
- Maps and Sequence Types
- Arrays
- Constructing Arrays
- Arrays Versus Sequences
- Arrays and Atomization
- Looking Up Array Values
- Querying Arrays
- Changing Arrays
- Arrays and Sequence Types
- JSON
- Parsing JSON
- Serializing JSON
- Converting Between JSON and XML
- Chapter 25. Implementation-Specific Features
- Conformance
- Version Support
- New Features in XQuery 3.0
- New Features in XQuery 3.1
- Setting the Query Context
- The Option Declaration
- Extension Expressions
- Annotations
- Chapter 26. XQuery for SQL Users
- Relational Versus XML Data Models
- Comparing SQL Syntax with XQuery Syntax
- A Simple Query
- Conditions and Operators
- Functions
- Selecting Distinct Values
- Working with Multiple Tables and Subqueries
- Grouping
- Combining SQL and XQuery
- Combining Structured and Semi-Structured Data
- Flexible Data Structures
- SQL/XML
- Chapter 27. XQuery for XSLT Users
- XQuery and XPath
- XQuery Versus XSLT
- Shared Components
- Equivalent Components
- Differences
- Using XQuery and XSLT Together
- XQuery Backward Compatibility with XPath 1.0
- Data Model
- New Expressions
- Path Expressions
- Function Conversion Rules
- Arithmetic and Comparison Expressions
- Built-in Functions
- Chapter 28. Additional XQuery-Related Standards
- XQuery Update Facility
- Full-Text Search
- XQueryX
- RESTXQ
- XQuery API for Java (XQJ)
- Appendix A. Built-in Function Reference
- Appendix B. Built-in Types
- xs:anyAtomicType
- xs:anySimpleType
- xs:anyType
- xs:anyURI
- Casting and Comparing xs:anyURI Values
- xs:base64Binary
- xs:boolean
- Constructing xs:boolean Values
- Casting xs:boolean Values
- xs:byte
- xs:date
- xs:dateTime
- xs:dateTimeStamp
- xs:dayTimeDuration
- xs:decimal
- Casting xs:decimal Values
- xs:double
- Casting xs:double Values
- xs:duration
- xs:ENTITIES
- xs:ENTITY
- xs:error
- xs:float
- Casting xs:float Values
- xs:gDay
- xs:gMonth
- xs:gMonthDay
- xs:gYear
- xs:gYearMonth
- xs:hexBinary
- xs:ID
- xs:IDREF
- xs:IDREFS
- xs:int
- xs:integer
- Casting xs:integer Values
- xs:language
- xs:long
- xs:Name
- xs:NCName
- xs:negativeInteger
- xs:NMTOKEN
- xs:NMTOKENS
- xs:nonNegativeInteger
- xs:nonPositiveInteger
- xs:normalizedString
- xs:NOTATION
- xs:numeric
- xs:positiveInteger
- xs:QName
- xs:short
- xs:string
- xs:time
- xs:token
- xs:unsignedByte
- xs:unsignedInt
- xs:unsignedLong
- xs:unsignedShort
- xs:untyped
- xs:untypedAtomic
- xs:yearMonthDuration
- Appendix C. Error Summary
- FOAP0001
- FOAR0001
- FOAR0002
- FOAY0001
- FOAY0002
- FOCA0001
- FOCA0002
- FOCA0003
- FOCA0005
- FOCA0006
- FOCH0001
- FOCH0002
- FOCH0003
- FOCH0004
- FODC0001
- FODC0002
- FODC0003
- FODC0004
- FODC0005
- FODC0006
- FODC0010
- FODF1280
- FODF1310
- FODT0001
- FODT0002
- FODT0003
- FOER0000
- FOFD1340
- FOFD1350
- FOJS0001
- FOJS0003
- FOJS0004
- FOJS0005
- FOJS0006
- FOJS0007
- FONS0004
- FONS0005
- FOQM0001
- FOQM0002
- FOQM0003
- FOQM0005
- FOQM0006
- FORG0001
- FORG0002
- FORG0003
- FORG0004
- FORG0005
- FORG0006
- FORG0008
- FORG0009
- FORG0010
- FORX0001
- FORX0002
- FORX0003
- FORX0004
- FOTY0012
- FOTY0013
- FOTY0014
- FOTY0015
- FOUT1170
- FOUT1190
- FOUT1200
- FOXT0001
- FOXT0002
- FOXT0003
- FOXT0004
- FOXT0006
- SENR0001
- SEPM0004
- SEPM0009
- SEPM0010
- SEPM0016
- SEPM0017
- SEPM0018
- SEPM0019
- SERE0003
- SERE0005
- SERE0006
- SERE0008
- SERE0012
- SERE0014
- SERE0015
- SERE0020
- SERE0021
- SERE0022
- SERE0023
- SESU0007
- SESU0011
- SESU0013
- XPDY0002
- XPDY0050
- XPDY0130
- XPST0001
- XPST0003
- XPST0005
- XPST0008
- XPST0017
- XPST0051
- XPST0080
- XPST0081
- XPTY0004
- XPTY0018
- XPTY0019
- XPTY0020
- XPTY0117
- XQDY0025
- XQDY0026
- XQDY0027
- XQDY0041
- XQDY0044
- XQDY0054
- XQDY0061
- XQDY0064
- XQDY0072
- XQDY0074
- XQDY0084
- XQDY0091
- XQDY0092
- XQDY0096
- XQDY0101
- XQDY0102
- XQDY0137
- XQST0009
- XQST0012
- XQST0013
- XQST0016
- XQST0022
- XQST0031
- XQST0032
- XQST0033
- XQST0034
- XQST0035
- XQST0038
- XQST0039
- XQST0040
- XQST0045
- XQST0046
- XQST0047
- XQST0048
- XQST0049
- XQST0052
- XQST0055
- XQST0057
- XQST0058
- XQST0059
- XQST0060
- XQST0065
- XQST0066
- XQST0067
- XQST0068
- XQST0069
- XQST0070
- XQST0071
- XQST0075
- XQST0076
- XQST0079
- XQST0085
- XQST0087
- XQST0088
- XQST0089
- XQST0090
- XQST0094
- XQST0097
- XQST0098
- XQST0099
- XQST0103
- XQST0104
- XQST0106
- XQST0108
- XQST0109
- XQST0110
- XQST0111
- XQST0113
- XQST0114
- XQST0115
- XQST0116
- XQST0118
- XQST0119
- XQST0125
- XQST0129
- XQST0134
- XQTY0024
- XQTY0030
- XQTY0086
- XQTY0105
- Index
- About the Author
System requirements
File format: PDF
Copy-Protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (only limited: Kindle).
The file format PDF always displays a book page identically on any hardware. This makes PDF suitable for complex layouts such as those used in textbooks and reference books (images, tables, columns, footnotes). Unfortunately, on the small screens of e-readers or smartphones, PDFs are rather annoying, requiring too much scrolling.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our eBook Help page.