123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: HTS
- (C) Copyright IBM Corp. 2005, 2010
- US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- -->
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/"
- xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt">
- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
- <xsl:variable name="customs" select="/root/customs/param"/>
- <xsl:variable name="meta" select="/root/fragment/meta"/>
- <xsl:variable name="excludeEmptyFolders">
- <xsl:call-template name="get-custom">
- <xsl:with-param name="name">excludeEmptyFolders</xsl:with-param>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="selected-tabs" select="/root/state/param[@name='selectedTabs']"/>
- <xsl:variable name="is-using-product-locale" select="$customs[@name='useProductLocaleForTabNames']='true'"/>
- <xsl:variable name="report-saved-output-height" select="$customs[@name='reportSavedOutputHeight']"/>
- <!--
- defines an attribute set to be applied on each page element
- -->
- <xsl:attribute-set name="page">
- <xsl:attribute name="title">
- <xsl:choose>
- <xsl:when test="$is-using-product-locale">
- <xsl:value-of select="nav:productLocaleName"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="nav:name"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- <xsl:attribute name="href">
- <xsl:choose>
- <xsl:when test="nav:type = 'package' and nav:subType = 'adaptiveAnalytics' and local-name() = 'item'">
- <xsl:text>/AApackage/</xsl:text>
- <xsl:value-of select="nav:internalId"/>
- </xsl:when>
-
- <!-- admin pages -->
- <xsl:when test="nav:type = 'pageletFolder'">
- <xsl:text>/booklet/</xsl:text>
- <xsl:value-of select="nav:internalId"/>
- <xsl:text>?frag-view=vtabs&showicons=true</xsl:text>
- <xsl:if test="$is-using-product-locale">
- <xsl:text>&useProductLocaleForTabNames=true</xsl:text>
- </xsl:if>
- </xsl:when>
- <xsl:when test="nav:type = 'shortcut'">
- <xsl:text>/cm/</xsl:text>
- <xsl:value-of select="nav:internalId"/>
- <xsl:if test="nav:item/nav:type = 'report' or nav:item/nav:type = 'reportView' or nav:item/nav:type = 'query' or nav:item/nav:type = 'analysis'">
- <xsl:text>?viewer-height=</xsl:text>
- <xsl:value-of select="$report-saved-output-height"/>
- </xsl:if>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>/</xsl:text>
- <xsl:value-of select="nav:type"/>
- <xsl:text>/</xsl:text>
- <xsl:value-of select="nav:internalId"/>
- <xsl:if test="nav:type = 'report' or nav:type = 'query' or nav:type = 'analysis' or nav:type = 'reportView'">
- <xsl:text>?viewer-height=</xsl:text>
- <xsl:value-of select="$report-saved-output-height"/>
- </xsl:if>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- <xsl:attribute name="icon">
- <xsl:value-of select="nav:imgURL"/>
- </xsl:attribute>
- <xsl:attribute name="hidden">
- <xsl:choose>
- <xsl:when test="nav:hidden = 'true'">
- <xsl:text>true</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>false</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- <xsl:attribute name="id">
- <xsl:value-of select="nav:internalId"/>
- </xsl:attribute>
- <xsl:attribute name="type">
- <xsl:value-of select="nav:type"/>
- </xsl:attribute>
- <xsl:attribute name="permissions">
- <xsl:value-of select="nav:permissions"/>
- </xsl:attribute>
- </xsl:attribute-set>
- <!--
- MAIN - transforms the NAV's response into pages XML elements.
- -->
- <xsl:template match="/">
- <xsl:variable name="results" select="/root/input[@name='nav']/nav:requestResponse/nav:queryReplies/nav:queryReply"/>
- <xsl:variable name="container" select="$results[1]/nav:getContainerResponse/nav:container"/>
- <xsl:variable name="children" select="$results[2][not($excludeEmptyFolders='true')]/nav:searchResponse/nav:content/*"/>
- <xsl:variable name="firstlevel-has-children" select="$results[2]/nav:searchResponse/nav:content/*"/>
- <xsl:variable name="classes">
- <class>folder</class>
- <class>analysis</class>
- <class>document</class>
- <class>package</class>
- <class>pagelet</class>
- <class>pageletFolder</class>
- <class>powerPlayCube</class>
- <class>powerPlayReport</class>
- <class>powerPlay8Report</class>
- <class>query</class>
- <class>report</class>
- <class>reportView</class>
- <class>shortcut</class>
- <class>URL</class>
- </xsl:variable>
- <xsl:variable name="class-list">
- <xsl:for-each select="$classes/class"><xsl:value-of select="concat(., '|')"/></xsl:for-each>
- </xsl:variable>
- <xsl:variable name="originalPages">
- <xsl:copy-of select="/root/input[@name='pages']/pages"/>
- </xsl:variable>
- <xsl:variable name="pages">
- <xsl:choose>
- <!-- use the pages XML (from customization) -->
- <xsl:when test="/root/input[@name='pages']/pages">
- <!-- Use a copy of the pages element to create ids, to insulate those ids from changes elsewhere in the input document. -->
- <xsl:apply-templates select="$originalPages/*"/>
- </xsl:when>
- <!-- use the NAV response -->
- <xsl:when test="$container[1][nav:defaultAction]">
- <xsl:for-each select="$container[1]">
- <pages xsl:use-attribute-sets="page">
- <xsl:for-each select="$container/nav:content/*[nav:defaultAction][not(self::nav:shortcut) or contains($class-list, concat(./*/nav:type, '|'))]">
- <xsl:variable name="parentId" select="nav:id"/>
- <!-- When 'excludeEmptyFolders' flag is turned on, hide any container object that has no children -->
- <xsl:if test="not(self::nav:container) or not($excludeEmptyFolders='true') or count($firstlevel-has-children[nav:parentId = $parentId][nav:defaultAction]) > 0">
- <page xsl:use-attribute-sets="page">
- <xsl:if test="contains($selected-tabs, nav:internalId)">
- <xsl:attribute name="selected">true</xsl:attribute>
- </xsl:if>
- <xsl:for-each select="$children[nav:parentId = $parentId][nav:defaultAction][not(self::nav:shortcut) or contains($class-list, concat(./*/nav:type, '|'))]">
- <page xsl:use-attribute-sets="page">
- <xsl:if test="contains($selected-tabs, nav:internalId)">
- <xsl:attribute name="selected">true</xsl:attribute>
- </xsl:if>
- </page>
- </xsl:for-each>
- </page>
- </xsl:if>
- </xsl:for-each>
- </pages>
- </xsl:for-each>
- </xsl:when>
- <xsl:otherwise>
- <pages unavailable="true"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <response>
-
- <xsl:variable name="refresh" select="string(/root/interactions/param[@name='refresh'])"/>
- <xsl:variable name="updateState" select="string(/root/interactions/param[@name='updateState'])"/>
-
- <xsl:variable name="level1-selected-page" select="($pages/pages/page[@selected='true'] | $pages/pages/page[position() = 1 and not($pages/pages/page[@selected='true'])])"/>
- <xsl:variable name="selected-page" select="($level1-selected-page/page[@selected='true'] | $level1-selected-page/page[position() = 1 and not($level1-selected-page/page[@selected='true'])] | $level1-selected-page[not(page)] )"/>
- <xsl:variable name="first-page" select="$selected-page[not($refresh = 'true' or $updateState = 'true')]"/>
- <fragment>
- <xsl:if test="$customs[@name='titleOptions']='selected'">
- <preferredTitle>
- <xsl:value-of select="$container/nav:name"/>
- </preferredTitle>
- </xsl:if>
- <xsl:if test="$first-page/@href != '' ">
- <!-- and add the first page subfragment -->
- <subfragment id="firstpage" href="{$first-page/@href}"/>
- </xsl:if>
- </fragment>
- <!-- copy the new pages XML -->
- <xsl:copy-of select="$pages"/>
- </response>
- </xsl:template>
- <xsl:template match="pages|page">
- <xsl:copy>
- <xsl:copy-of select="@*"/>
- <xsl:variable name="id">
- <xsl:choose>
- <xsl:when test="@id">
- <xsl:value-of select="@id"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="generate-id()"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:if test="not(@id)">
- <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
- </xsl:if>
- <xsl:if test="contains($selected-tabs,$id)">
- <xsl:attribute name="selected">true</xsl:attribute>
- </xsl:if>
- <xsl:apply-templates/>
- </xsl:copy>
- </xsl:template>
- <!--
- get-custom: get a value from either the customs or the META's default value
- -->
- <xsl:template name="get-custom">
- <xsl:param name="name"/>
- <xsl:choose>
- <xsl:when test="$customs[@name=$name]">
- <xsl:value-of select="$customs[@name=$name]"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$meta/customProperties[@name=$name]/default/value"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- </xsl:stylesheet>
|