123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: ps
- (C) Copyright IBM Corp. 2013
- US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- -->
- <xsl:stylesheet version="1.0"
- xmlns:xts="http://developer.cognos.com/schemas/xts/"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:set="http://exslt.org/sets"
- xmlns:send="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/brl/1/"
- xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
- exclude-result-prefixes="xts send set xtsext">
- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
-
- <xsl:template match="/">
- <xsl:variable name="distinctTenantIds" select="set:distinct(/root//*[local-name()='queryResponse' or local-name()='response']//*[local-name()='tenantID' and text()!=''] | /root//*[local-name() = 'Property' and @name='TenantID'])"/>
- <xts:sequence>
- <xts:append>
- <xsl:variable name="tenantSearchPath">
- <xsl:text>/directory/tenants[@name='Tenants']/tenant</xsl:text>
- <xsl:for-each select="$distinctTenantIds">
- <xsl:variable name="sq">'</xsl:variable>
- <!-- must escape the ' to '' to make the search expression CM safe. -->
- <xsl:variable name="cmEncodedObjTenantId" select="xtsext:replace(string(.), string($sq), concat($sq,$sq)) "/>
-
- <xsl:if test="position()=1">
- <xsl:text>[</xsl:text>
- </xsl:if>
- <xsl:text>@tenantID='</xsl:text><xsl:value-of select="$cmEncodedObjTenantId"/><xsl:text>'</xsl:text>
- <xsl:if test="not(position()=last())">
- <xsl:text> or </xsl:text>
- </xsl:if>
- <xsl:if test="position()=last()">
- <xsl:text>]</xsl:text>
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
- <tenantIDs>
- <xts:transform src="transforms/CM/post-process.xslt" processor="XSLT">
- <send:request provider="cm">
- <xts:transform src="transforms/CM/pre-process.xslt" processor="XSLT">
- <cm:query xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/">
- <cm:search><xsl:value-of select="normalize-space($tenantSearchPath)"/></cm:search>
- <cm:properties>
- <cm:property name="defaultName"/>
- <cm:property name="tenantID"/>
- </cm:properties>
- <cm:options schemaInfo="false"/>
- </cm:query>
- </xts:transform>
- </send:request>
- </xts:transform>
- </tenantIDs>
- </xts:append>
- </xts:sequence>
- <xsl:for-each select="$distinctTenantIds">
- <xsl:variable name="tenantID" select="."/>
- <xts:sequence>
- <xts:update>
- <xsl:attribute name="select">
- <xsl:text>/root//*[local-name()='queryResponse' or local-name()='response']//*[local-name()='tenantID' and text()='</xsl:text><xsl:value-of select="$tenantID"/><xsl:text>'] | /root//*[local-name() = 'Property' and @name='TenantID' and text()='</xsl:text><xsl:value-of select="$tenantID"/><xsl:text>']</xsl:text>
- </xsl:attribute>
- <tenantID xmlns="http://developer.cognos.com/schemas/xts-cm/1/"><xsl:value-of select="$tenantID"/></tenantID>
- <tenantName xmlns="http://developer.cognos.com/schemas/xts-cm/1/">
- <xts:queryNode>
- <xsl:attribute name="select">
- <xsl:text>/root/*[local-name()='tenantIDs']//*[local-name()='tenantID' and text()='</xsl:text><xsl:value-of select="$tenantID"/><xsl:text>']/../*[local-name()='defaultName']</xsl:text>
- </xsl:attribute>
- </xts:queryNode>
- </tenantName>
- </xts:update>
- </xts:sequence>
- </xsl:for-each>
- </xsl:template>
-
- </xsl:stylesheet>
|