123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?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).
- -->
- <!--
- NOTE: The logic to determine the order of the queries MUST match the logic found in dt:generateInitialUIHelpers
- if checkUIHelpers is true, then only build the CM query if the associated UIHelper is empty.
- -->
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- exclude-result-prefixes="xsl">
-
- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
- <xsl:key name="ui-helpers" match="/root/*[local-name()='UIHelpers']/*" use="local-name()"/>
- <xsl:template match="*[local-name()='root']" priority="1">
- <xsl:choose>
- <xsl:when test="not(/root/*[local-name()='queryReply']/*/*[local-name()='options']/*) and /root/jobOptions/*[local-name()='options']/*">
- <xsl:for-each select="/root/jobOptions">
- <xsl:call-template name="genQueries">
- <xsl:with-param name="checkUIHelpers" select="/root/*[local-name()='checkUIHelpers']"/>
- </xsl:call-template>
- </xsl:for-each>
- </xsl:when>
- <xsl:otherwise>
- <xsl:for-each select="/root/*[local-name()='queryReply']/*">
- <xsl:call-template name="genQueries">
- <xsl:with-param name="checkUIHelpers" select="false()"/>
- </xsl:call-template>
- </xsl:for-each>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template name="genQueries">
- <xsl:param name="checkUIHelpers"/>
- <xsl:variable name="typedRecipientsCount" select="count(*[local-name()='options']/*[local-name()='value']/*[local-name()='item' and ./*[local-name()='name' and (.='toAddress' or .='ccAddress' or .='bccAddress')]]/*[local-name()='value']/*[local-name()='item'])"/>
- <xsl:variable name="selectedRecipients" select="*[local-name()='options']/*[local-name()='value']/*[local-name()='item' and ./*[local-name()='name' and (.='to' or .='cc' or .='bcc')]][@xsi:type='bus:deliveryOptionSearchPathMultipleObjectArray']/*[local-name()='value']/*[local-name()='item']"/>
- <xsl:variable name="selectedRecipientsCount" select="count($selectedRecipients)"/>
- <!-- if we only have 1 recipient and it's a reference to another object -->
- <xsl:if test="$typedRecipientsCount = 0 and $selectedRecipientsCount = 1 and (not($checkUIHelpers='true') or key('ui-helpers','emailRecipients')='')">
- <cm:query>
- <cm:search><xsl:value-of select="$selectedRecipients"/></cm:search>
- <cm:properties>
- <cm:property name="defaultName"/>
- <cm:property name="userName"/>
- </cm:properties>
- </cm:query>
- </xsl:if>
-
- <!-- If we don't have any recipients, then make sure there aren't any that are specified in the old runOptions format -->
- <!-- Upgrade from runOptions recipients to deliveryOptions recipients -->
- <xsl:if test="$typedRecipientsCount = 0 and $selectedRecipientsCount = 0">
- <xsl:variable name="old_typedRecipientsCount" select="count(*[local-name()='options']/*[local-name()='value']/*[local-name()='item' and ./*[local-name()='name' and .='emailToAddress']]/*[local-name()='value']/*[local-name()='item'])"/>
- <xsl:variable name="old_selectedRecipients" select="*[local-name()='options']/*[local-name()='value']/*[local-name()='item' and ./*[local-name()='name' and .='emailTo']]/*[local-name()='value']/*[local-name()='item']"/>
- <xsl:variable name="old_selectedRecipientsCount" select="count($old_selectedRecipients)"/>
- <!-- if we only have 1 recipient and it's a reference to another object -->
- <xsl:if test="$old_typedRecipientsCount = 0 and $old_selectedRecipientsCount = 1 and (not($checkUIHelpers='true') or key('ui-helpers','emailRecipients')='')">
- <cm:query>
- <cm:search><xsl:value-of select="$old_selectedRecipients"/></cm:search>
- <cm:properties>
- <cm:property name="defaultName"/>
- <cm:property name="userName"/>
- </cm:properties>
- </cm:query>
- </xsl:if>
- </xsl:if>
-
- <!-- is print set to true and are we referencing a printer object -->
- <xsl:if test="(not($checkUIHelpers='true') or key('ui-helpers','printerSummary')='') and *[local-name()='options']/*[local-name()='value']/*[local-name()='item' and ./*[local-name()='name']='print']/*[local-name()='value'] = 'true' and *[local-name()='options']/*[local-name()='value']/*[local-name()='item' and ./*[local-name()='name']='printer']/*[local-name()='value'] != ''">
- <cm:query>
- <cm:search><xsl:value-of select="*[local-name()='options']/*[local-name()='value']/*[local-name()='item' and ./*[local-name()='name']='printer']/*[local-name()='value']"/></cm:search>
- <cm:properties>
- <cm:property name="defaultName"/>
- <cm:property name="printerAddress"/>
- </cm:properties>
- </cm:query>
- </xsl:if>
-
- <!-- are we saving as a report view -->
- <xsl:if test="(not($checkUIHelpers='true') or key('ui-helpers','saveAsSummary')='') and *[local-name()='options']/*[local-name()='value']/*[local-name()='item' and ./*[local-name()='name']='saveAs']/*[local-name()='parentSearchPath'] != ''">
- <cm:query>
- <cm:search><xsl:value-of select="*[local-name()='options']/*[local-name()='value']/*[local-name()='item' and ./*[local-name()='name']='saveAs']/*[local-name()='parentSearchPath']"/></cm:search>
- <cm:properties>
- <cm:property name="defaultName"/>
- <cm:property name="ancestors"/>
- </cm:properties>
- </cm:query>
- </xsl:if>
- </xsl:template>
-
- <xsl:template match="text()" priority="0"/>
- </xsl:stylesheet>
|