123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- <?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: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: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>
|