123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- <?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:xts="http://developer.cognos.com/schemas/xts/">
- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
- <xsl:template match="/">
- <xsl:variable name="current-stack-level" select="count( /root/env/param[ starts-with( @name, 'stack_' ) ] ) - 1"/>
- <xsl:variable name="current-stack-name" select="concat( 'stack_', $current-stack-level )"/>
- <xsl:variable name="op" select="/root/env/param[@name = 'ps_nav_op']"/>
- <!-- This is a comma-delimited list of template names representing the navigation path up a "push" or a "stack-up" navigation operations. -->
- <xsl:variable name="current-nav-stack" select=" /root/env/param[@name = 'ps_nav_stack'] "/>
- <xsl:variable name="passport" select="/root/credential/param[@name='CAM']/*[local-name() ='CAM']/*[local-name() = 'CAMPassport']/*[local-name() = 'id']"/>
- <!--
- Use this to delimit template names in the navigation stack. Use * since it is the least likely char to be used in a folder or file name.
- This is also defined in formlogic.xslt
- -->
- <xsl:variable name="nav-stack-delimiter" select="'*'"/>
- <!-- This represents the template where we came from -->
- <xsl:variable name="nav-source" select=" /root/env/param[@name = 'ps_nav_source']"/>
-
- <xts:sequence>
- <xsl:choose>
- <!-- Stack Up =================================================== -->
- <xsl:when test="$op = 'push' or $op = 'stack-up'">
- <!-- Save current data... -->
- <xts:append select="/root/env">
- <param name="{concat( 'stack_', string( $current-stack-level + 1 ) )}">
- <xsl:variable name="markup">
- <!-- we don't want to package up variables that contain information about the page being rendered... -->
- <xsl:apply-templates mode="markup" select="/root/env/param[not(starts-with(@name, 'stack_') or @name = 'ps_nav_source' or @name = 'ps_nav_stack' or @name = 'm' or @name = 'ps_nav_op')]"/>
- </xsl:variable>
- <xsl:value-of select="xtsext:cafaction( concat('sign_wrap_setpassportid_', $passport), xtsext:web64encode( string( $markup ), true() ))"/>
- </param>
- </xts:append>
-
- <!-- Update the navigation stack .. -->
- <xts:replace select="/root/env/param[@name='ps_nav_stack']">
- <xsl:choose>
- <xsl:when test="$current-nav-stack = ''">
- <!-- There is nothing on the stack. Initialize it with the name of the source template. -->
- <param name="ps_nav_stack">
- <xsl:value-of select="$nav-source"/>
- </param>
- </xsl:when>
- <xsl:otherwise>
- <!-- There is something in the navigation stack. Push the name of the source template on it. -->
- <param name="ps_nav_stack">
- <xsl:value-of select="concat($nav-source, $nav-stack-delimiter, $current-nav-stack ) "/>
- </param>
- </xsl:otherwise>
- </xsl:choose>
- </xts:replace>
- </xsl:when>
-
- <!-- Stack Down ================================================= -->
- <xsl:when test="$op = 'pop' or $op = 'stack-down'">
- <!-- setup stacking data... -->
- <xsl:if test="$current-stack-level > -1">
- <!-- we don't want to overwrite variables that contain information about the page being rendered... -->
- <xts:delete select="/root/env/param[not( starts-with( @name, 'stack_' ) or @name = 'ps_nav_stack' or @name = 'm' or @name = 'ps_nav_op')]"/>
- <xsl:variable name="xml-encoded-stack" select="xtsext:web64decode( xtsext:cafaction( 'sign_unwrap', string( /root/env/param[@name = $current-stack-name] )), true())"/>
- <xsl:if test="$xml-encoded-stack != ''">
- <xts:append select="/root/env">
- <xts:transform name="XMLDecode">
- <xsl:value-of select="$xml-encoded-stack"/>
- </xts:transform>
- </xts:append>
- </xsl:if>
- <xts:delete select="/root/env/param[@name = '{$current-stack-name}']"/>
-
- <xsl:choose>
- <xsl:when test="$current-stack-level = 0">
- <!-- Get rid of the navigation stack. UTML will insert a new one in. -->
- <xts:delete select="/root/env/param[@name = 'ps_nav_stack']"/>
- </xsl:when>
- <xsl:otherwise>
- <!-- Pop the navigation stack -->
- <xts:replace select="/root/env/param[@name='ps_nav_stack']">
- <param name="ps_nav_stack">
- <xsl:value-of select="substring-after(/root/env/param[@name = 'ps_nav_stack'], $nav-stack-delimiter)"/>
- </param>
- </xts:replace>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
- </xsl:when>
-
- <!-- Stack Down Save ========================================== -->
- <xsl:when test="$op = 'drop' or $op = 'stack-down-save'">
- <xsl:if test="$current-stack-level > -1">
- <xts:delete select="/root/env/param[@name = '{$current-stack-name}']"/>
- <xsl:choose>
- <xsl:when test="$current-stack-level = 0">
- <!-- Get rid of the navigation stack. UTML will insert a new one in. -->
- <xts:delete select="/root/env/param[@name = 'ps_nav_stack']"/>
- </xsl:when>
- <xsl:otherwise>
- <!-- Pop the navigation stack. -->
- <xts:replace select="/root/env/param[@name='ps_nav_stack']">
- <param name="ps_nav_stack">
- <xsl:value-of select="substring-after(/root/env/param[@name = 'ps_nav_stack'], $nav-stack-delimiter)"/>
- </param>
- </xts:replace>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
- </xsl:when>
-
- </xsl:choose>
-
- <!-- We place the value in the "m" variable in the "ps_nav_source" for future navigation. -->
- <xts:replace select="/root/env/param[@name='ps_nav_source']">
- <param name="ps_nav_source">
- <xsl:value-of select=" /root/env/param[@name='m'] "/>
- </param>
- </xts:replace>
-
- <!-- Reset the operation. UTML logic will automatically insert a new (blank) field for this in the generated utml:form . -->
- <xts:delete select="/root/env/param[@name = 'ps_nav_op']"/>
-
- <!-- If ui.backURL is passed in, replace any backURL value with it -->
- <xsl:if test="/root/env/param[@name='ui.backURL'] and /root/env/param[@name='ui.backURL'] != ''">
- <xsl:choose>
- <xsl:when test="/root/env/param[@name='backURL']">
- <xts:replace select="/root/env/param[@name='backURL']">
- <param name="backURL"><xsl:value-of select="/root/env/param[@name='ui.backURL']"/></param>
- </xts:replace>
- </xsl:when>
- <xsl:otherwise>
- <xts:append select="/root/env">
- <param name="backURL"><xsl:value-of select="/root/env/param[@name='ui.backURL']"/></param>
- </xts:append>
- </xsl:otherwise>
- </xsl:choose>
- <xts:delete select="/root/env/param[@name='ui.backURL']"/>
- </xsl:if>
-
- <!-- If we are supposed to ensure that any passed back url is in the same domain as CRN then make that check and replace it if necessary -->
- <xsl:if test=" /root/system/param[@name = 'allowExternalURLs'] = 'false' and /root/env/param[@name = 'backURL'] and not(starts-with(/root/env/param[@name = 'backURL'], /root/http/param[@name='SCRIPT_NAME'])) ">
- <xts:replace select="/root/env/param[@name = 'backURL']">
- <param name="backURL"><xsl:value-of select="/root/http/param[@name='SCRIPT_NAME']"/>?<xsl:value-of select="/root/system/param[@name = 'COGNOSHome']"/></param>
- </xts:replace>
- </xsl:if>
-
- <!-- If this request is not carrying a caf contextid and caf_extendedContextId is true then make sure it does from now on. -->
- <xsl:if test="not(/root/env/param[@name='ui.cafcontextid']) and xtsext:cafaction('get_extendedcontextid', '') = 'true'">
- <xts:append select="/root/env">
- <param name="ui.cafcontextid"><xsl:value-of select="xtsext:cafaction(concat('get_contextid_settemplatename_formlogicinitxslt_setcomponent_ps_setpassportid_', $passport), '')"/></param>
- </xts:append>
- </xsl:if>
- </xts:sequence>
- </xsl:template>
- <!-- TODO: MOVE THE BELOW TO AN EXTENSTION FUNCTION...IT'S TOO SLOW!!!! -->
- <!-- generate text for simple element -->
- <xsl:template match="*" mode="markup">
- <xsl:text><</xsl:text>
- <xsl:value-of select="name()"/>
- <xsl:apply-templates select="@*" mode="markup"/>
- <xsl:text>/></xsl:text>
- </xsl:template>
- <!-- generate text for an element with children or text -->
- <xsl:template match="*[* | text()]" mode="markup">
- <xsl:text><</xsl:text>
- <xsl:value-of select="name()"/>
- <xsl:apply-templates select="@*" mode="markup"/>
- <xsl:text>></xsl:text>
- <xsl:apply-templates select="* | text()" mode="markup"/>
- <xsl:text></</xsl:text>
- <xsl:value-of select="name()"/>
- <xsl:text>></xsl:text>
- </xsl:template>
- <!-- generate text for an attribute -->
- <xsl:template match="@*" mode="markup">
- <xsl:text> </xsl:text>
- <xsl:value-of select="name()"/>
- <xsl:text>="</xsl:text>
- <xsl:value-of select="."/>
- <xsl:text>"</xsl:text>
- </xsl:template>
- <!-- generate text -->
- <xsl:template match="text()" mode="markup">
- <xsl:value-of select="xtsext:xmlencode( string( . ) )"/>
- </xsl:template>
-
- </xsl:stylesheet>
|