Application 5: Trade Audit Server
Several industries require that trade documents be saved in their original form. Examples range from EBT in the energy industry to XBRL for retail banks. These inescapable regulations typically require an IT department to set up a custom environment outside the trading application. Companies often want to hold on to these documents in case disputes ariseshowing an actual copy of a trade is proof that it happened. This is often referred to as non-repudiation
no one can repudiate the trade if you have a copy of the trade message or document.
The problem is that transactions add up. Trying to find a trade document days or weeks after the fact can be a challenge. A good solution would be a search application that can mine through hundreds or thousands of trades to find a specific trade. With XQuery, you can do much better than a simple search. You can look for a set of conditionssay, a certain trading partner, a time range, and a combination of words in the instructions (like "trade" and "at market").
|Anyone with only modest knowledge of XML and SQL can learn XQuery relatively quickly.|
In this scenario, a trading firm keeps all the trading documents in a collection of documents named "tradelogs". We need a query which, for any given trader, finds all the trades that trader executed after hours where the total trade price is less than $15,000, and where the trade instructions contain a specific keyword or phrase.
The following query uses the $trader
parameter and the $keyword
parameter to retrieve all the matching trades.
for $trade in collection("tradelogs")//trade
where $trade/traderName = $trader and
$trade/executionTime = "afterhours" and
$trade/tradePrice < 15000 and
(some $instruction in $trade//instruction satisfies
As you can see from these scenarios, XQuery can help solve practical problems faced by IT departments. However, these scenarios only scratch the surface of XQuery's capabilities. Anyone with only modest knowledge of XML and SQL can learn XQuery relatively quickly. Because XQuery works against many different data types and formats, it's tremendously useful whether you are searching a file system, a relational database, a document management system, a Web service, or all of these simultaneously. When you top that off with its ability to integrate and transform results, XQuery truly embodies the next generation of query languages.