12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?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" encoding="UTF-8" version="1.0" indent="no"/>
- <xsl:template match="/root">
-
- <!-- The list of portlets defined for the page -->
- <xsl:variable name="portletItems">
- <xsl:for-each select="env/param[starts-with(@name, 'm_mp_portlet_')]">
- <xsl:if test=". != ''">
- <xsl:value-of select="concat(' ', substring-after(@name, 'm_mp_portlet_'), ' ')"/>
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
-
- <!-- The list of portlets that exist in the current layout -->
- <xsl:variable name="placedPortletItems">
- <xsl:for-each select="/root/layout/column/portlet">
- <xsl:value-of select="concat(' ', @id, ' ')"/>
- </xsl:for-each>
- </xsl:variable>
-
- <xts:sequence>
- <!-- Remove portlet references in the layout object that no longer exist in the portlet items list -->
- <xts:delete select="/root/layout/column/portlet[not(contains('{$portletItems}', @id))]"/>
-
- <!-- Add references to portletInstances that are not already represented in the layout -->
- <xsl:for-each select="/root/env/param[starts-with(@name, 'm_mp_portlet_')]">
- <xsl:if test="not(contains($placedPortletItems, substring-after(@name, 'm_mp_portlet_')))">
- <xsl:choose>
- <xsl:when test="/root/env/param[@name='m_mp_cmd'] = 'add_portlet_2'">
- <xts:append select="/root/layout/column[2]">
- <portlet id="{substring-after(@name, 'm_mp_portlet_')}"/>
- </xts:append>
- </xsl:when>
- <xsl:when test="/root/env/param[@name='m_mp_cmd'] = 'add_portlet_3'">
- <xts:append select="/root/layout/column[3]">
- <portlet id="{substring-after(@name, 'm_mp_portlet_')}"/>
- </xts:append>
- </xsl:when>
- <xsl:otherwise>
- <xts:append select="/root/layout/column[1]">
- <portlet id="{substring-after(@name, 'm_mp_portlet_')}"/>
- </xts:append>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
- </xsl:for-each>
- </xts:sequence>
- </xsl:template>
- </xsl:stylesheet>
|