Based on past papers, the XQuery question seems to take the exact same format every year, hence, the answers can be memorised and specified to apply to the current question.
Write XQuery Statements for each of the following queries posed on the document
in Figure B. Show the results that you would expect to get when you run the query.
Return all of the values of the BankName elements in the document separated by a ”+” sign.
In a new element called BankClassifications, return the values of any Classification attributes that appear in the document.
Return only the first of the firstname elements for each BankManager in the document.
For the Bank with BankID2, return within an element called BankDetails the element BankName and all of the elements in the BankManager element.
Note
To avoid having to load the document repeatedly we will specify that we have a global let statement applying for all the questions.
This takes the form:
let $bankRegistry := doc("banks.xml")
Question
Return all of the values of the BankName elements in the document separated by a ”+” sign.
XQuery:
string-join(bankRegistry//BankName, "+")
Expected Result:
Allied Irish Bank+CitiBank Europe+Bank Of Ireland
Question
In a new element called BankClassifications, return the values of any Classification attributes that appear in the document.
XQuery:
<BankClassifications>{ for $classification in bankRegistry//@Classification return <Classification>{$classification}</Classification>}</BankClassifications>