123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: cpscrn
- (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:ui="http://developer.cognos.com/schemas/cps/logic/ui/1/"
- xmlns:xts="http://developer.cognos.com/schemas/xts/"
- xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
- xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/">
- <xsl:variable name="params" select="/root/interactions/param | /root/state/param | /root/transients/param | /root/customs/param"/>
- <!-- Preferences vars -->
- <xsl:variable name="preferences" select="/root/bus:biBusHeader/bus:userPreferenceVars"/>
- <xsl:variable name="productLocale" select="$preferences/item[name = 'productLocale']/value"/>
- <xsl:variable name="contentLocale" select="$preferences/item[name = 'contentLocale']/value"/>
-
- <!-- HTTP env vars -->
- <xsl:variable name="environmentVars" select="/root/bus:biBusHeader/*[local-name() = 'hdrSession']/bus:environmentVars"/>
- <xsl:variable name="userPrefsDefault" select="/root/system/param[@name='defaultPortalPreferences']"/>
-
- <xsl:variable name="user-agent" select="$environmentVars/item[name='HTTP_USER_AGENT']/value"/>
- <xsl:variable name="browser">
- <xsl:choose>
- <xsl:when test="contains($user-agent , 'MSIE')">ie</xsl:when> <!-- IE 4.xx and above -->
- <xsl:when test="contains($user-agent , 'Safari/5') and not(contains($user-agent , 'Chrome'))">safari</xsl:when> <!-- Safari user-agent does not contain Chrome -->
- <xsl:when test="contains($user-agent , 'Chrome')">chrome</xsl:when> <!-- Chrome user-agent contains Safari also -->
- <xsl:when test="contains($user-agent , 'Mozilla/5.0')">moz</xsl:when> <!-- NS 6.xx and 7.xx -->
- <xsl:when test="contains($user-agent , 'Mozilla/4.')">ns4</xsl:when> <!-- NS 4.xx -->
- <xsl:when test="string-length($user-agent) = 0">undefined</xsl:when>
- <xsl:otherwise>other</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:template name="build-navQuery-properties">
- <nav:property name="screenTip"/>
- <nav:property name="description"/>
- <nav:property name="parentId"/>
- <nav:property name="fullPath"/>
- <nav:property name="lastModifiedDate"/>
- <nav:property name="status"/>
- <nav:property name="newState"/>
- <nav:property name="readState"/>
- <nav:property name="action"/>
- <nav:property name="actionsURL"/>
- <nav:property name="icons"/>
- </xsl:template>
-
- <xsl:template name="build-pagination-params">
- <xsl:variable name="skip">
- <xsl:choose>
- <xsl:when test="string($params[@name='skip']) != ''">
- <xsl:value-of select="$params[@name='skip']"/>
- </xsl:when>
- <xsl:otherwise>0</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="maxObjects">
- <xsl:choose>
- <xsl:when test="$params[@name='maxobjs'] != ''">
- <xsl:value-of select="$params[@name='maxobjs']"/>
- </xsl:when>
- <xsl:when test="$preferences/item[name = 'linesPerPage']/value">
- <xsl:value-of select="$preferences/item[name = 'linesPerPage']/value"/>
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="$userPrefsDefault/pref[@name='lines']"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="sort">
- <xsl:if test="$params[@name='sort'] != ''">
- <xsl:value-of select="$params[@name='sort']"/>
- </xsl:if>
- </xsl:variable>
-
- <nav:skipObjects>
- <xsl:choose>
- <xsl:when test="$skip != '' ">
- <xsl:value-of select="$skip"/>
- </xsl:when>
- <xsl:otherwise>0</xsl:otherwise>
- </xsl:choose>
- </nav:skipObjects>
- <nav:maxObjects><xsl:value-of select="$maxObjects"/></nav:maxObjects>
- <xsl:choose>
- <xsl:when test="starts-with(string($sort),'n')">
- <xsl:variable name="order">
- <xsl:choose>
- <xsl:when test="$sort = 'n_d'">
- <xsl:text>descending</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>ascending</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <nav:sort order="{$order}">name</nav:sort>
- </xsl:when>
- <xsl:when test="starts-with(string($sort),'d')">
- <xsl:variable name="order">
- <xsl:choose>
- <xsl:when test="$sort = 'd_d'">
- <xsl:text>descending</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>ascending</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <nav:sort order="{$order}">lastModifiedDate</nav:sort>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template name="handleException">
- <xsl:variable name="xts-fault" select="/root/fault/xts:exception[last()]"/>
- <xsl:variable name="code" select="$xts-fault/xts:exceptionCode"/>
- <xsl:variable name="prefix" select="substring-before( string( $code ), ':' )"/>
- <xsl:variable name="local-code" select="substring-after( string( $code ), ':' )"/>
- <error>
- <xsl:choose>
- <xsl:when test="($prefix = 'nav') and ($local-code = 'InvalidCredentials')">
- <code>invalidCredentials</code>
- </xsl:when>
- <xsl:otherwise>
- <code xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/">
- <xsl:value-of select="$code"/>
- </code>
- </xsl:otherwise>
- </xsl:choose>
- <message>
- <xsl:value-of select="$xts-fault/xts:exceptionMsg"/>
- </message>
- <details>
- <xsl:value-of select="$xts-fault/xts:exceptionDetails"/>
- </details>
- </error>
- </xsl:template>
- </xsl:stylesheet>
|