XPath selection for multiple report parts in multiple requests
IBM Cognos Mashup Service provides a way to make the report output more adjusted to developers needs - we can use XPath expression to filter the report output. This method can be useful when a report is very big or we would like to avoid report parsing on the client.
Let us consider the following report (Return Quantity by Product Line from IBM Cognos 10 Samples):
The report looks simple in the Viewer but the Layout Data XML needed to generate it has more than 2500 lines and takes over 44 kB on disk. CMS provides a way to filter out unneeded information which could also improve performance.
Looking at the LDX output we see the following structure of our report:
Let us ask CMS to return only the first page of the report without all
tags. Using REST call we would use the following URL:
is the report ID on my IBM Cognos 10 installation or:
if we use the SearchPath.
The LDX response received from CMS will not contain
element as the document root, but
To retrieve the values of summary row only, we could use the following REST URL:
and our response would be:
To select the numeric value of summary we would have to call:
so our result would be:
Making SOAP call we would have to define filters object in the report output request. The value of the
filterType should be set to XPATH and the
filterValue to the XPath expression. The response object will contain
FormatOutput object holding our results.
Each call we used till now caused the report to re-run. We can avoid that using CMS caching mechanism and secondary requests.
Let us run the report and retrieve its title only, i.e:
The response contains the title, but the request URL has been changed by CMS to:
We have to use that
in our next request. That way we can access other details in the report much faster, without re-running it, e.g. to access the summary value we would just call:
It is possible to use wildcards in XPath filters but for performance reasons queries like:
are strongly discouraged.
- CMS does not support nested predicates, look-back predicates.
child:: axis is supported (explicit or implicit) e.g.
- CMS allows only for using only
pos() functions e.g.