CentraSite 10.11 | CentraSite Developer's Guide | Custom Reporting Searches | Sample XQueries for Reporting Searches | XQueries for Retrieving Embedded Objects
 
XQueries for Retrieving Embedded Objects
Embedded objects (for example, slots, classifications, and associations) occur embedded within the primary objects.
As an example, let us look at the slots provided with the service MusicQuoteService. The MusicQuoteService provides information on the music sheets by a composer. This service uses the composer's name as an input and returns the list of music sheets by that specific composer. A sheet, in this case, is a paired value consisting of a sheet's title and an ID that identifies the sheet in the online store database.
Let us assume that we bundle this service into different colour schemes and attach the property colour as a slot (key-value pair) to the service.
You may use an XQuery function to find the colour property:
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)

};
for $service in collection("CentraSite")/jaxr:service
where local:getName($service) = "MusicQuoteService"
return $service/jaxr:instanceSlots/colour
This XQuery function returns :
<colour xmlns="">blue</colour>
When dealing with function calls, the optimizer sometimes decides to inline the XQuery function. That is, before an XQuery gets executed, a function call is replaced with the body of the respective function. In this XQuery, the function call to local:getName might not get inline during optimization. Optionally, you can precede the function declaration with an inline XQuery pragma.
declare namespace jaxr = "http://namespaces.CentraSite.com/Schema/jaxr";
{?inline?}
declare function local:getName($node as node()) as xs:string {
string($node/jaxr:name/jaxr:localString)
};
for $service in collection("CentraSite")/jaxr:service
where local:getName($service) = "MusicQuoteService"
return $service/jaxr:instanceSlots/colour
The optimization pragma {?optimization inline="full"?} at the beginning of the XQuery would make all user-defined functions to be inline except those that directly or indirectly reference themselves.
Some of the embedded object types are related to specific primary object types as serviceBindings that occur as sub elements of the services. An XQuery using the local-name function would retrieve the sub elements that exist under the current element in an XML document:
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)
};
for $service in collection("CentraSite")/jaxr:service
where local:getName($service) = "MusicQuoteService"
return for $subelement in $service/*
return local-name($subelement)
This XQuery function yields:
<xq:result xmlns:xq="http://namespaces.softwareag.com/tamino/XQuery/result">
<xq:value>key</xq:value>
<xq:value>owner</xq:value>
<xq:value>name</xq:value>
<xq:value>description</xq:value>
<xq:value>submittingOrganization</xq:value>
<xq:value>externalLinks</xq:value>
<xq:value>classifications</xq:value>
<xq:value>majorVersion</xq:value>
<xq:value>minorVersion</xq:value>
<xq:value>stability</xq:value>
<xq:value>status</xq:value>
<xq:value>providingOrganization</xq:value>
<xq:value>serviceBindings</xq:value>
<xq:value>instanceSlots</xq:value>
</xq:result>