XQuery Training

XQuery- Overview

Have the Capsule of XQuery in a single shot.

The technical lingual mechanism for the restoration of the data stored in the format of XML is how we define XQuery.

Specializations of XQuery

  1. Functional and Practically Implementable
  2. Similar to SQL
  3. Gridded on XPath
  4. Universally Invited
  5. W3C parameterized

Benefits of XQuery

  1. Hierarchy
  2. Query tree and graphical structures
  3. Query web pages
  4. Transformation of XML documents
  5. XML based Databases
  6. Object based Databases
Environment Set UP of XQuery

This chapter gives you a detail account about how to adapt XQuery library in the local development environment.

  1. Execution of XQuery counter XML
Your first XQuery App- Deploy your first app
  1. Example
  2. XQuery Expressions-
    1. Doc()
  3. How the Path Expressions are used?In order to trace the location of the portion of XML on which search is to be implemented Path Expressions are used.
  4. Iteration of the Objects-XML data is considered as XQuery objects.
  5. Application of the condition-
  6. Producing the output


The XQuery Layout and algorithm protocol

F- For- For the selection of a group of nodes

L-Let-position the output in the XQuery Variable form

W-Where- Selects the nodes satisfying specific constraints

O-Order BY- Sequences the nodes as per the given condition

R-Return- Gives the final output

XQuery –HTML Structure

The conversion of XML document into an HTML page becomes a cinch with XQuery.

Unlock the key whole with the suitable examples.

XQuery Path- XPath Flexible

XQuery follows the regulations of XPath. XPath Expressions are employed to constrict the search output on XML collections.

XQuery Sequences-

An array or ordered assimilation of data item of similar or different types.

  1. Creation of a SequenceSequences are built up using parenthesis and string in place of quotes and double quotes or XML elements can also comprise a sequence.
  2. Observing the items of the sequenceUsing the value or index the objects can be iterated sequentially. The Sequence Functions
    1. count($seq as item()*)It counts the number of items in the sequence.
    2. Sum($seq as item()*)It outputs the sum of the number of the items in the sequence.
    3. Avg($seq as item()*)It outputs the average value of the number of items in the sequence.
    4. Min($seq as item()*)It outputs the lowest valued item in the sequence.
    5. Distinct-values($seq as item()*)It returns selected distinct items from any sequence.
    6. Max($ seq as item()*)It outputs the highest value of the sequence.
    7. Subsequence($seq as item()*, $startingLoc as xs:double, $length as XS:DOUBLE)It returns the subset of the sequence.
    8. Insert-before($seq as item()*, $position as: integer, $inserts as item()*)Inserts any data item in the given sequence
    9. Remove($seq as item()*)It removes the data item from the given sequence.
    10. Reverse($ser as item()*)IT outputs the reverse of the sequence.
    11. Index-of($seq asbanyAtomicType()*, $target as anyAtomicTYpe())It outputs the index as integer to show the availability of any item within the given sequence.
    12. Last()It outputs the last element of the sequence when employed in predicate expression.
    13. Position()It is used in the FLOWR expressions to get the positions of the items in any sequence.

XML String Functions- The Manipulators

    1. string-length($string as xs:string) as xs:integerIt outputs the length of the given string.
    2. Concat($input as xs: anyAtomicType?) as xs:stringFor the concatenation of the string returned as output.
    3. String-join($sequence as xs:string*, $delimiter as xs:string) as xs:string

It outputs the combination of the data items which are separated by the delimiter in a sequence.

XQuery Date Functions

  1. Current-date()It generates the current date
  2. Current-time()It returns the present or the current time.
  3. Current-dateTime()
  4. It generates both current date and time.XQuery Regular Expressions
    1. Matches($input, $regex)It generates true if the input coordinates with the offered regular expression.
    2. Replace($input, $regex, $string)It replaces the given string with the matched input string.
    3. Tokenize($Input, $regex)It outputs a sequenceof data items which matches the regular expression.

XQuery –If-Then Else

XQuery offers a robust framework of if-then else which are the constraint which the input has to satisfy.

XQuery Customized Functions

You can write user end customized functions apart from inbuilt function in XQuery.