Which character starts a variable in XQuery?
A
@ B
$ C
# D
%
Analysis & Theory
XQuery variables begin with a dollar sign, like `$title`.
Which of the following is a valid XQuery variable declaration?
A
let title = 'Harry Potter'; B
let $title := 'Harry Potter' C
var $title = 'Harry Potter'; D
$title := 'Harry Potter'
Analysis & Theory
XQuery uses `let $var := value` for variable declarations.
What is the correct syntax to access an XML document named 'books.xml'?
A
get('books.xml') B
load('books.xml') C
doc('books.xml') D
xml('books.xml')
Analysis & Theory
`doc('books.xml')` is used to load and access XML documents in XQuery.
Which of the following is the correct way to return the title of each book?
A
for $b in doc('books.xml') return $b.book.title B
for $b in doc('books.xml')//book return $b/title C
loop $b from doc('books.xml') return $b/title D
foreach $b in doc('books.xml') return title
Analysis & Theory
This is the correct FLWOR syntax: `for $b in doc('books.xml')//book return $b/title`.
Which clause is optional in a FLWOR expression?
A
for B
let C
where D
All except return
Analysis & Theory
Only `return` is required in a FLWOR expression; all others are optional.
Which of the following would correctly return a new XML element `<price>` with the value '100'?
A
return <price>'100'</price> B
return <price>100</price> C
return price(100) D
return price = 100
Analysis & Theory
You return XML with embedded values like: `<price>100</price>`.
How do you write a comment in XQuery?
A
// This is a comment B
# This is a comment C
<!-- This is a comment --> D
/* This is a comment */
Analysis & Theory
XQuery uses XML-style comments: `<!-- comment -->`.