123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: ps
- (C) Copyright IBM Corp. 2005, 2011
- US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- -->
- <!--
- Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
- Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
- -->
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
- xmlns:c8="http://developer.cognos.com/schemas/xmldata/1/"
- xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/"
- xmlns:xts="http://developer.cognos.com/schemas/xts/"
- xmlns:xos="http://developer.cognos.com/schemas/xts/output/"
- xmlns:cs="http://developer.cognos.com/schemas/cs">
-
- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
-
- <xsl:param name="gw" select="''"/>
-
- <xsl:variable name="search-url">
- <xsl:value-of select="$gw"/>
- <xsl:text/>/gosearch?csn.terms=<xsl:text/>
- <xsl:value-of select="/root/env/param[@name='query']"/>
- </xsl:variable>
- <!-- Did we get any results? -->
- <xsl:variable name="results">
- <xsl:choose>
- <xsl:when test="/root/burgundy/cs:document/cs:result/cs:extensions/cs:resultCount != '0'">burgundy</xsl:when>
- <xsl:when test="/root/nav:searchResponse/nav:content/*">cmsearch</xsl:when>
- <xsl:when test="/root/report | /root/chart">cm</xsl:when>
- <xsl:when test="string(/root/metrics/MetricShortStats/image/row/uri) != ''">metric</xsl:when>
- <xsl:when test="string(/root/metrics/ob_server/ob_response/image/row/uri) != ''">metric</xsl:when>
- <xsl:otherwise>none</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <!-- Defines the URL that goes under the Title in the response -->
- <xsl:variable name="the-url">
- <xsl:choose>
- <xsl:when test="$results = 'metric' or $results = 'cm'">
- <xsl:value-of select="$gw"/>?b_action=xts.run&m=onebox/launch.xts<xsl:text/>
- <xsl:choose>
- <xsl:when test="$results = 'metric'">
- <xsl:variable name="path">/content//package[@name='<xsl:value-of select="/root/metrics/packagePath"/>']</xsl:variable>
- <xsl:text/>&path=<xsl:value-of select="xtsext:protect(xtsext:urlencode(string($path)),'url','searchPath','getdata')"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text/>&id=<xsl:value-of select="/root/item/storeID/value"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$search-url"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:variable name="the-name">
- <xsl:choose>
- <xsl:when test="string(/root/item[1]/defaultName/value) != ''">
- <xsl:value-of select="/root/item[1]/defaultName/value"/>
- </xsl:when>
- <xsl:when test="string(/root/metrics/MetricShortStats/imageTitle/row/title)!=''">
- <xsl:value-of select="/root/metrics/MetricShortStats/imageTitle/row/title"/>
- </xsl:when>
- <xsl:when test="string(/root/metrics/ob_server/ob_response/imageTitle/row/title)!=''">
- <xsl:value-of select="/root/metrics/ob_server/ob_response/imageTitle/row/title"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text/><xts:string id="IDS_OBX_COGNOS_GO"/><xsl:text/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:variable name="img-source">
- <xsl:choose>
- <xsl:when test="/root/chart">
- <xsl:variable name="chart-store-id">storeID('<xsl:value-of select="/root/chart"/>')</xsl:variable>
- <xsl:value-of select="$gw"/>
- <xsl:text/>?SM=query&search=<xsl:value-of select="xtsext:protect($chart-store-id,'none','cmid','getdata')"/>
- <xsl:text/>&SA=propEnum,properties&ITEM=data&EA=&SS=queryOptions,options&dataEncoding=MIME&ES=&EM=<xsl:text/>
- </xsl:when>
- <xsl:when test="string(/root/metrics/MetricShortStats/image/row/uri) != ''">
- <xsl:value-of select="/root/metrics/MetricShortStats/image/row/uri"/>
- </xsl:when>
- <xsl:when test="string(/root/metrics/ob_server/ob_response/image/row/uri) != ''">
- <xsl:value-of select="/root/metrics/ob_server/ob_response/image/row/uri"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="substring-before($gw, '/cgi-bin')"/>
- <xsl:text/>/onebox/cognos8_40.gif<xsl:text/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:key name="class-names" match="/root/objectClass/class" use="@name"/>
-
- <xsl:template match="/root">
- <xos:part>
- <xos:entityHeader>
- <xos:param name="Content-Type">text/xml; charset=utf-8</xos:param>
- </xos:entityHeader>
- <xos:entityBody>
- <xsl:variable name="canDebug" select="string(/root/env/param[@name='d'])='1' and string(/root/debug/debugSwitch) != 'disable'"/>
- <xsl:if test="$canDebug">
- <xsl:text disable-output-escaping="yes"><debug></xsl:text>
- </xsl:if>
- <OneBoxResults>
- <provider><xts:string id="IDS_OBX_PROVIDER_RESULTS"/></provider>
- <title>
- <urlText><xsl:value-of select="$the-name"/></urlText>
- <urlLink><xsl:value-of select="$the-url"/></urlLink>
- </title>
- <IMAGE_SOURCE>
- <xsl:value-of select="$img-source"/>
- </IMAGE_SOURCE>
- <xsl:if test="$results != 'none'">
- <MODULE_RESULT resultCode="success" cogType="title">
- <xsl:if test="string(/root/env/param[@name='lang'])!=''">
- <xsl:attribute name="xml:lang"><xsl:value-of select="/root/env/param[@name='lang']"/></xsl:attribute>
- </xsl:if>
- <xsl:if test="$results != 'burgundy'">
- <Field name="brand"><xts:string id="IDS_COGNOS_REPORTS"/></Field>
- </xsl:if>
- <xsl:if test="$results = 'burgundy' or $results = 'cmsearch'">
- <Field name="results"> <xts:string id="IDS_OBX_RESULTS_FOR"/> <xsl:text/></Field>
- <Field name="query"><xsl:value-of select="/root/env/param[@name='query']"/></Field>
- <xsl:if test="$results = 'burgundy'">
- <Field name="count"><xsl:text/> <xts:string id="IDS_OBX_ABOUT"><xts:param name="obx_count"><xsl:value-of select="burgundy/cs:document/cs:result/cs:extensions/cs:resultCount"/></xts:param></xts:string></Field>
- </xsl:if>
- </xsl:if>
- <Field name="moreResults"><xts:string id="IDS_OBX_MORE_RESULTS"/></Field>
- <Field name="searchURL"><xsl:value-of select="$search-url"/></Field>
- </MODULE_RESULT>
- </xsl:if>
- <xsl:apply-templates select="report | burgundy | nav:searchResponse | metrics/MetricShortStats | metrics/ob_server/ob_response | error"/>
- </OneBoxResults>
- <xsl:if test="$canDebug">
- <xsl:copy-of select="."/>
- <results><xsl:value-of select="$results"/></results>
- <xsl:text disable-output-escaping="yes"></debug></xsl:text>
- </xsl:if>
- </xos:entityBody>
- </xos:part>
- </xsl:template>
-
- <!-- Handle XHTML reports -->
- <xsl:template match="report">
- <!-- grab just the first page-body -->
- <xsl:apply-templates select="descendant::td[@class='pb'][1]"/>
- </xsl:template>
-
- <xsl:template match="td[@class='pb']">
- <xsl:for-each select="table/tr[position()<5]">
- <MODULE_RESULT resultCode="success">
- <U><xsl:value-of select="$the-url"/></U>
- <xsl:apply-templates select="td[position()<9]"/>
- </MODULE_RESULT>
- </xsl:for-each>
- </xsl:template>
- <xsl:template match="td[@class='xm'] | td[@class='ml'] | td[@class='ol'] | td[@class='lt']">
- <Field name="head">
- <xsl:value-of select="span"/>
- </Field>
- </xsl:template>
-
- <xsl:template match="td[@class='mv'] | td[@class='ov'] | td[@class='lc'] | td[@class='lm']">
- <Field name="val">
- <xsl:value-of select="span"/>
- </Field>
- </xsl:template>
-
- <!-- Handle CMM responses -->
- <xsl:variable name="cmm-types" select="/root/metrics/MetricShortStats/table/row[2] | /root/metrics/ob_server/ob_response/table/types"/>
-
- <xsl:template match="MetricShortStats | ob_server/ob_response">
- <xsl:if test="string(image/row/uri) != ''">
- <xsl:for-each select="table/*">
- <xsl:choose>
- <xsl:when test="position()=1 or local-name()='columns'">
- <MODULE_RESULT resultCode="success">
- <xsl:for-each select="*">
- <Field name="head">
- <xsl:value-of select="."/>
- </Field>
- </xsl:for-each>
- </MODULE_RESULT>
- </xsl:when>
- <xsl:when test="position()=2 or local-name()='types'"/>
- <xsl:otherwise>
- <MODULE_RESULT resultCode="success">
- <xsl:for-each select="*">
- <xsl:variable name="pos" select="position()"/>
- <Field>
- <xsl:attribute name="name">
- <xsl:choose>
- <xsl:when test="$cmm-types/*[$pos] = 'image'">img</xsl:when>
- <xsl:otherwise>val</xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- <xsl:value-of select="."/>
- </Field>
- </xsl:for-each>
- </MODULE_RESULT>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- <xsl:apply-templates select="table/*"/>
- </xsl:if>
- </xsl:template>
-
- <!-- Handle burgundy search results -->
- <xsl:template match="burgundy">
- <xsl:apply-templates select="cs:document/cs:result/cs:searchResults/cs:items/cs:item"/>
- </xsl:template>
-
- <xsl:template match="cs:item">
- <MODULE_RESULT resultCode="success" cogType="{key('class-names', cs:type)}">
- <U>
- <xsl:choose>
- <xsl:when test="cs:itemType = 'CMM'">
- <xsl:value-of select="cs:url"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$gw"/>
- <xsl:text/>?b_action=xts.run&m=onebox/launch.xts&id=<xsl:value-of select="cs:id"/>
- </xsl:otherwise>
- </xsl:choose>
- </U>
- <Title><xsl:value-of select="cs:name"/></Title>
- <!-- TODO: fix this when burgundy doesn't return markup in the cs:detail anymore?
- <Field name="description">
- <xsl:value-of select="cs:matchDescription/cs:detail" disable-output-escaping="yes"/>
- </Field>
- -->
- </MODULE_RESULT>
- </xsl:template>
-
- <!-- Handle CM search results -->
- <xsl:template match="nav:searchResponse">
- <xsl:apply-templates select="nav:content/nav:item | nav:content/nav:container"/>
- </xsl:template>
-
- <xsl:template match="nav:item | nav:container">
- <MODULE_RESULT resultCode="success" cogType="{key('class-names', nav:type)}">
- <U><xsl:value-of select="nav:defaultAction/nav:url"/></U>
- <Title><xsl:value-of select="nav:name"/></Title>
- <Field name="description">
- <xsl:value-of select="nav:description"/>
- </Field>
- </MODULE_RESULT>
- </xsl:template>
-
- <xsl:template match="error">
- <MODULE_RESULT resultCode="lookupFailure">
- <Diagnostics>
- <xsl:value-of select="fault//messageString[1]"/>
- </Diagnostics>
- </MODULE_RESULT>
- </xsl:template>
-
- <xsl:template match="text()"/>
- </xsl:stylesheet>
|