CentraSite 10.7 | CentraSite Developer's Guide | Custom Reporting Searches | Sample XQueries for Reporting Searches | XQueries for Retrieving Classifications
 
XQueries for Retrieving Classifications
The purpose of classifying objects is to allow a means of semantic retrieval. Let us assume that we have the following taxonomy classifications to describe the different types of music:
*e: Classical Music
*ec: Classical Chamber Music
*ecb: Brass Chamber Music
*eo: Classical Music for Orchestras
*u: Non-Classical Music
*us: Music for Small Bands
*ub: BigBand Music
This enables the customer to retrieve specific music sheets as classified in the online store. An XQuery function to retrieve the concept object representing the taxonomy classification ecb (Brass Chamber Music):
declare namespace jaxr = "http://namespaces.CentraSite.com/Schema/jaxr";
for $concept in collection("CentraSite")/jaxr:concept
where $concept/jaxr:name/jaxr:localString = "ecb"
return $concept
Make sure that you do not use the user-defined function local:getName in the above XQuery function, because this function assumes that every such concept only has one name which cannot be expected in an internationalized environment.
The following XQuery function retrieves the services that are classified by this concept to search for music sheets applicable to Brass Chamber Music.
declare namespace jaxr = "http://namespaces.CentraSite.com/Schema/jaxr";
declare function local:getName($node as node()) as xs:string {
string($node/jaxr:name/jaxr:localString)
};
let $concept := collection("CentraSite")/jaxr:concept[jaxr:name/
jaxr:localString="ecb"]
for $service in collection("CentraSite")/jaxr:service
where $service//jaxr:classification/jaxr:concept = $concept/jaxr:key
return local:getName($service)