123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 |
- <?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:encodingUtils="com.cognos.portal.utils.EncodingUtils">
- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
- <xsl:variable name="controllerParams" select="/root/controllerParams/param"/>
- <xsl:variable name="customs" select="/root/customs/param"/>
- <xsl:variable name="meta" select="/root/fragment/meta"/>
- <xsl:variable name="backURL" select="/root/interactions/param[@name='backURL']"/>
- <xsl:template match="/">
- <response>
- <xsl:if test="not($controllerParams[@name='frag-directive'] = 'meta-only')">
- <xsl:variable name="pages">
- <xsl:choose>
- <!-- pages is statically defined as XML -->
- <xsl:when test="$customs[@name='pages']/pages">
- <xsl:copy-of select="$customs[@name='pages']/pages"/>
- </xsl:when>
- <!-- pages is statically defined as text, so convert it to XML -->
- <xsl:when test="normalize-space($customs[@name='pages']) != ''">
- <xsl:value-of select="$customs[@name='pages']" disable-output-escaping="yes"/>
- </xsl:when>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="folder">
- <xsl:call-template name="get-custom">
- <xsl:with-param name="name">folder</xsl:with-param>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="maxlevels">
- <xsl:call-template name="get-custom">
- <xsl:with-param name="name">maxlevels</xsl:with-param>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="header">
- <xsl:call-template name="get-custom">
- <xsl:with-param name="name">header</xsl:with-param>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="footer">
- <xsl:call-template name="get-custom">
- <xsl:with-param name="name">footer</xsl:with-param>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="fixed">
- <xsl:call-template name="get-custom">
- <xsl:with-param name="name">fixed</xsl:with-param>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="view">
- <xsl:call-template name="get-custom">
- <xsl:with-param name="name">view</xsl:with-param>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="excludeEmptyFolders">
- <xsl:call-template name="get-custom">
- <xsl:with-param name="name">excludeEmptyFolders</xsl:with-param>
- </xsl:call-template>
- </xsl:variable>
- <fragment>
- <xsl:if test="$fixed = 'true'">
- <info>
- <xsl:copy-of select="/root/fragment/info/*"/>
- <display>fixed</display>
- </info>
- </xsl:if>
-
- <xsl:if test="$header != ''">
- <xsl:variable name="myHref">
- <xsl:call-template name="gen-href">
- <xsl:with-param name="value" select="$header"/>
- </xsl:call-template>
- </xsl:variable>
- <subfragment id="header" href="{$myHref}">
- <params><!-- backURL needs to be kept in a cdata block for now. This is due to a bug in the server, where text is being truncated at the first entity -->
- <param name="backURL">
- <xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text><xsl:value-of select="$backURL" disable-output-escaping="yes"/><xsl:text disable-output-escaping="yes">]]></xsl:text>
- </param>
- </params>
- </subfragment>
- </xsl:if>
- <xsl:if test="$footer != ''">
- <subfragment id="footer">
- <xsl:attribute name="href">
- <xsl:call-template name="gen-href">
- <xsl:with-param name="value" select="$footer"/>
- </xsl:call-template>
- </xsl:attribute>
- </subfragment>
- </xsl:if>
- <xsl:if test="not($controllerParams[@name='frag-view'])">
- <newView>
- <xsl:value-of select="$view"/>
- </newView>
- </xsl:if>
- </fragment>
- <xsl:choose>
- <xsl:when test="$pages/pages">
- <!-- copy as XML elements -->
- <xsl:copy-of select="$pages/pages"/>
- </xsl:when>
- <xsl:when test="$pages != ''">
- <!-- copy as disabled-escaping text -->
- <xsl:copy-of select="$pages"/>
- </xsl:when>
- <xsl:when test="$folder != ''">
- <!-- copy NAV request -->
- <xsl:variable name="classes">
- <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="filter">
- <xsl:text>[@objectClass='folder'</xsl:text>
- <xsl:for-each select="$classes/class">
- <xsl:text> or @objectClass='</xsl:text>
- <xsl:value-of select="."/>
- <xsl:text>'</xsl:text>
- </xsl:for-each>
- <xsl:text>][@shown='true']</xsl:text>
- </xsl:variable>
- <xsl:variable name="fragPortalAgent">
- <xsl:choose>
- <xsl:when test="$controllerParams[@name='frag-portalAgent'] != ''">
- <xsl:value-of select="$controllerParams[@name='frag-portalAgent']"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>cognosFragmentServer</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:variable name="frag-agent" select="/root/controllerParams/param[@name='frag-agent']"/>
- <xsl:variable name="browser">
- <xsl:choose>
- <xsl:when test="contains($frag-agent , 'MSIE')">ie</xsl:when> <!-- IE 4.xx and above -->
- <xsl:when test="contains($frag-agent , 'Safari')">safari</xsl:when> <!-- Safari -->
- <xsl:when test="contains($frag-agent , 'Mozilla/5.0')">moz</xsl:when> <!-- NS 6.xx and 7.xx -->
- <xsl:when test="contains($frag-agent , 'Mozilla/4.')">ns4</xsl:when> <!-- NS 4.xx -->
- <xsl:when test="string-length($frag-agent) = 0">undefined</xsl:when>
- <xsl:otherwise>other</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <nav>
- <SOAP-ENV:Envelope xmlns:bus="http://developer.cognos.com/schemas/bibus/3/" xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <SOAP-ENV:Header>
- <xsl:copy-of select="/root/bus:biBusHeader"/>
- </SOAP-ENV:Header>
- <SOAP-ENV:Body>
- <nav:request>
- <nav:param name="browserAgent"><xsl:value-of select="$browser"/></nav:param>
- <nav:param name="webContentURL">.</nav:param>
- <nav:param name="portalAgent"><xsl:value-of select="$fragPortalAgent"/></nav:param>
- <nav:queries>
- <nav:query>
- <nav:getContainer>
- <nav:id>
- <xsl:call-template name="gen-cmpath">
- <xsl:with-param name="value" select="$folder"/>
- </xsl:call-template>
- </nav:id>
- <nav:childObjectFilter>
- <xsl:text/><nav:itemType>folder</nav:itemType><xsl:text/>
- <xsl:for-each select="$classes/class">
- <xsl:text/><nav:itemType><xsl:value-of select="."/></nav:itemType><xsl:text/>
- </xsl:for-each>
- </nav:childObjectFilter>
- <nav:property name="baseType"/>
- <nav:property name="internalId"/>
- <nav:property name="permissions"/>
- <nav:property name="action"/>
- <nav:property name="hidden"/>
- <nav:property name="defaultPortalAction"/>
- <xsl:if test="$customs[@name='useProductLocaleForTabNames']='true'">
- <nav:property name="productLocaleName"/>
- </xsl:if>
- </nav:getContainer>
- </nav:query>
- <xsl:if test="number($maxlevels) > 1 or $excludeEmptyFolders='true'">
- <nav:query>
- <nav:search>
- <nav:searchType>normal</nav:searchType>
- <nav:scope>
- <xsl:call-template name="gen-cmpath">
- <xsl:with-param name="value" select="$folder"/>
- </xsl:call-template>
- <xsl:text>/*/*</xsl:text>
- <xsl:value-of select="$filter"/>
- </nav:scope>
- <nav:childObjects>none</nav:childObjects>
- <nav:sort order="descending">displaySequence</nav:sort>
- <nav:property name="baseType"/>
- <nav:property name="internalId"/>
- <nav:property name="parentId"/>
- <nav:property name="permissions"/>
- <nav:property name="action"/>
- <nav:property name="hidden"/>
- <nav:property name="defaultPortalAction"/>
- <xsl:if test="$customs[@name='useProductLocaleForTabNames']='true'">
- <nav:property name="productLocaleName"/>
- </xsl:if>
- </nav:search>
- </nav:query>
- </xsl:if>
- </nav:queries>
- </nav:request>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>
- </nav>
- </xsl:when>
- <xsl:otherwise>
- <!-- no pages xml or selected folder -->
- <pages no-source="true"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
- <xsl:if test="string(/root/interactions/param[@name='selectedTabs'])!=''">
- <state>
- <xsl:copy-of select="/root/interactions/param[@name='selectedTabs']"/>
- </state>
- </xsl:if>
- </response>
- </xsl:template>
- <!--
- gen-cmpath: generate a CM path syntax for NAV
- -->
- <xsl:template name="gen-cmpath">
- <xsl:param name="value"/>
- <xsl:choose>
- <xsl:when test="starts-with($value, 'path:')">
- <xsl:value-of select="$value"/>
- </xsl:when>
- <xsl:when test="starts-with($value, 'storeID(')">
- <xsl:text>path:</xsl:text>
- <xsl:value-of select="$value"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>path:storeID('</xsl:text>
- <xsl:value-of select="$value"/>
- <xsl:text>')</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <!--
- gen-href: generate href based on $value
- -->
- <xsl:template name="gen-href">
- <xsl:param name="value"/>
- <xsl:choose>
- <xsl:when test="starts-with($value, '/')">
- <xsl:value-of select="$value"/>
- </xsl:when>
- <xsl:when test="contains($value, '://')">
- <xsl:value-of select="$value"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>/cm?path=</xsl:text>
- <xsl:value-of select="$value"/>
- </xsl:otherwise>
- </xsl:choose>
- </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>
|