123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: cpscrn
- (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).
- -->
- <!-- $Header: //cpscrn/main/templates/cps4/producer/wsrp-impl/transforms/getServiceDescription.xslt#1 $ -->
- <!-- $DateTime: 2008/10/22 11:12:04 $ -->
- <!-- $Change: 25109 $ -->
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types"
- xmlns:exslt="http://exslt.org/sets"
- xmlns:xts="http://developer.cognos.com/schemas/xts/"
- xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
- exclude-result-prefixes="exslt xts">
- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
- <!-- NOTES: -->
- <!-- * Product locales is used for offerred portlets supported languages and metadata (except title, shortTitle and description) -->
- <!-- * Content locales is used for Metadata descriptions (i.e. title, shortTitle and description) -->
- <xsl:variable name="locale">en</xsl:variable>
- <xsl:variable name="locales" select="/root/locale"/>
- <xsl:variable name="product-locales" select="/root/configuration/property[@name='productLocales']/locale"/>
- <xsl:variable name="content-locales" select="/root/configuration/property[@name='contentLocales']/locale"/>
- <xsl:variable name="product-locales-res" select="$product-locales[(id = $locales) and (id != $locale)]"/>
- <xsl:variable name="content-locales-res" select="$content-locales[(id = $locales) and (id != $locale)]"/>
- <xsl:variable name="locale-path" select="concat(substring-before(/root/message, '.xml'), '_', $locale, '.xml')"/>
- <xsl:variable name="locale-pathRL" select="concat(substring-before(/root/message, '.xml'), 'RL_', $locale, '.xml')"/>
-
- <xsl:variable name="locale-strings">
- <xsl:if test="xtsext:resourceExists($locale-path)='true'">
- <xsl:copy-of select="document($locale-path)//string"/>
- </xsl:if>
- <xsl:if test="xtsext:resourceExists($locale-pathRL)='true'">
- <xsl:copy-of select="document($locale-pathRL)//string"/>
- </xsl:if>
- </xsl:variable>
- <xsl:template match="/">
- <xsl:apply-templates select="/root/implementation | /root/portlet"/>
- </xsl:template>
-
- <xsl:template match="implementation">
- <wsrp:getServiceDescriptionResponse xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <wsrp:requiresRegistration>true</wsrp:requiresRegistration>
- <xsl:for-each select="portlet">
- <wsrp:offeredPortlets>
- <xsl:call-template name="gen-portlet"/>
- </wsrp:offeredPortlets>
- </xsl:for-each>
- <xsl:for-each select="./custom-windowstate">
- <wsrp:customWindowStateDescriptions itemName="{ @name }">
- <xsl:call-template name="value">
- <xsl:with-param name="tag" select="'description'"/>
- </xsl:call-template>
- </wsrp:customWindowStateDescriptions>
- </xsl:for-each>
- <xsl:for-each select="./custom-mode">
- <wsrp:customModeDescriptions itemName="{ @name }">
- <xsl:call-template name="value">
- <xsl:with-param name="tag" select="'description'"/>
- </xsl:call-template>
- </wsrp:customModeDescriptions>
- </xsl:for-each>
- <wsrp:requiresInitCookie>
- <xsl:value-of select="./@requiresInitCookie"/>
- </wsrp:requiresInitCookie>
- <xsl:if test="./property-description">
- <wsrp:registrationPropertyDescription xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <xsl:for-each select="./property-description[not(@shared)]">
- <wsrp:propertyDescriptions name="{ @name }" type="{ @type }">
- <xsl:for-each select="label[1]">
- <xsl:call-template name="value">
- <xsl:with-param name="tag" select="'label'"/>
- </xsl:call-template>
- </xsl:for-each>
- <xsl:for-each select="hint[1]">
- <xsl:call-template name="value">
- <xsl:with-param name="tag" select="'hint'"/>
- </xsl:call-template>
- </xsl:for-each>
- <xsl:if test="default">
- <wsrp:extensions>
- <cpsext:defaultValue xmlns:cpsext="http://developer.cognos.com/schemas/cps/wsrp/extensions/1/">
- <xsl:value-of select="default"/>
- </cpsext:defaultValue>
- </wsrp:extensions>
- </xsl:if>
- <xsl:if test="values">
- <wsrp:extensions>
- <cpsext:values xmlns:cpsext="http://developer.cognos.com/schemas/cps/wsrp/extensions/1/">
- <xsl:for-each select="values/value">
- <cpsext:value name="{ @name }">
- <xsl:choose>
- <xsl:when test="@resourceID">
- <xsl:attribute name="xml:lang">
- <xsl:value-of select="$locale"/>
- </xsl:attribute>
- <xsl:attribute name="resourceName"><xsl:value-of select="@resourceID"/></xsl:attribute>
- <xsl:value-of select="$locale-strings/string[@id = current()/@resourceID]"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="xml:lang">
- <xsl:value-of select="$locale"/>
- </xsl:attribute>
- <xsl:value-of select="."/>
- </xsl:otherwise>
- </xsl:choose>
- </cpsext:value>
- </xsl:for-each>
- </cpsext:values>
- </wsrp:extensions>
- </xsl:if>
- </wsrp:propertyDescriptions>
- </xsl:for-each>
- </wsrp:registrationPropertyDescription>
- </xsl:if>
- <xsl:if test="not($locales)">
- <xsl:for-each select="$content-locales">
- <xsl:sort select="id"/>
- <wsrp:locales>
- <xsl:value-of select="id"/>
- </wsrp:locales>
- </xsl:for-each>
- </xsl:if>
- <xsl:if test="$product-locales-res | $content-locales-res">
- <xsl:call-template name="gen-resources">
- <xsl:with-param name="resources" select="exslt:distinct( *[not(@shared='true')]/@resourceID | portlet/*/@resourceID | property-description[not(@shared='true')]//*/@resourceID )"/>
- </xsl:call-template>
- </xsl:if>
- </wsrp:getServiceDescriptionResponse>
- </xsl:template>
- <xsl:template match="portlet">
- <wsrp:getPortletDescriptionResponse xmlns:wsrp="urn:oasis:names:tc:wsrp:v1:types">
- <wsrp:portletDecription>
- <xsl:call-template name="gen-portlet"/>
- </wsrp:portletDecription>
- <xsl:call-template name="gen-resources">
- <xsl:with-param name="resources" select="exslt:distinct( .//*/@resourceID )"/>
- </xsl:call-template>
- </wsrp:getPortletDescriptionResponse>
- </xsl:template>
- <xsl:template name="gen-portlet">
- <wsrp:portletHandle><xsl:value-of select="@handle"/></wsrp:portletHandle>
- <wsrp:markupTypes>
- <xsl:for-each select="mimeType">
- <wsrp:mimeType>
- <xsl:value-of select="."/>
- </wsrp:mimeType>
- </xsl:for-each>
- <xsl:for-each select="mode">
- <wsrp:modes>
- <xsl:value-of select="."/>
- </wsrp:modes>
- </xsl:for-each>
- <xsl:for-each select="windowState">
- <wsrp:windowStates>
- <xsl:value-of select="."/>
- </wsrp:windowStates>
- </xsl:for-each>
- <xsl:choose>
- <!-- implementation.xml can tell us which locales are available -->
- <xsl:when test="locale">
- <xsl:for-each select="locale">
- <wsrp:locales>
- <xsl:value-of select="."/>
- </wsrp:locales>
- </xsl:for-each>
- </xsl:when>
- <!-- inside ReportNet, we use all available product locales -->
- <xsl:when test="$product-locales">
- <xsl:for-each select="$product-locales">
- <wsrp:locales>
- <xsl:value-of select="id"/>
- </wsrp:locales>
- </xsl:for-each>
- </xsl:when>
- <!-- only English is available -->
- <xsl:otherwise>
- <wsrp:locales>en</wsrp:locales>
- </xsl:otherwise>
- </xsl:choose>
- </wsrp:markupTypes>
- <wsrp:groupID><xsl:value-of select="@groupID"/></wsrp:groupID>
- <xsl:for-each select="description[1]">
- <xsl:call-template name="value">
- <xsl:with-param name="tag" select="'description'"/>
- </xsl:call-template>
- </xsl:for-each>
- <xsl:for-each select="shortTitle[1]">
- <xsl:call-template name="value">
- <xsl:with-param name="tag" select="'shortTitle'"/>
- </xsl:call-template>
- </xsl:for-each>
- <xsl:for-each select="title[1]">
- <xsl:call-template name="value">
- <xsl:with-param name="tag" select="'title'"/>
- </xsl:call-template>
- </xsl:for-each>
- <wsrp:usesMethodGet>false</wsrp:usesMethodGet>
- <wsrp:defaultMarkupSecure>false</wsrp:defaultMarkupSecure>
- <wsrp:onlySecure>false</wsrp:onlySecure>
- <wsrp:userContextStoredInSession>false</wsrp:userContextStoredInSession>
- <wsrp:templatesStoredInSession>false</wsrp:templatesStoredInSession>
- <wsrp:hasUserSpecificState>true</wsrp:hasUserSpecificState>
- <wsrp:doesUrlTemplateProcessing>false</wsrp:doesUrlTemplateProcessing>
- <xsl:if test="requiredCapabilities">
- <wsrp:extensions>
- <cpsext:meta xmlns:cpsext="http://developer.cognos.com/schemas/cps/wsrp/extensions/1/">
- <cpsext:requiredCapabilities>
- <xsl:value-of select="requiredCapabilities"/>
- </cpsext:requiredCapabilities>
- </cpsext:meta>
- </wsrp:extensions>
- </xsl:if>
- </xsl:template>
- <xsl:template name="gen-resources">
- <xsl:param name="resources"/>
- <xsl:if test="$resources">
- <wsrp:resourceList>
- <xsl:variable name="strings">
- <xsl:for-each select="exslt:distinct($product-locales-res/id | $content-locales-res/id)">
- <xsl:variable name="locale-res" select="."/>
- <xsl:variable name="path" select="concat(substring-before(/root/message, '.xml'), '_', $locale-res, '.xml')"/>
- <xsl:variable name="pathRL" select="concat(substring-before(/root/message, '.xml'), 'RL_', $locale-res, '.xml')"/>
- <xsl:choose>
- <xsl:when test="$product-locales-res[id = $locale-res] and $content-locales-res[id = $locale-res] and xtsext:resourceExists($path) and xtsext:resourceExists($pathRL)">
- <xsl:variable name="docs" select="document($path) | document($pathRL)"/>
- <xsl:if test="$docs/*">
- <locale id="{ $locale-res }">
- <xsl:copy-of select="$docs//string[@id = $resources]"/>
- </locale>
- </xsl:if>
- </xsl:when>
- <xsl:when test="$content-locales-res[id = $locale-res] and xtsext:resourceExists($pathRL)">
- <xsl:variable name="docs" select="document($pathRL)"/>
- <xsl:if test="$docs/*">
- <locale id="{ $locale-res }">
- <xsl:copy-of select="$docs//string[@id = $resources]"/>
- </locale>
- </xsl:if>
- </xsl:when>
- <xsl:when test="xtsext:resourceExists($path)">
- <xsl:variable name="docs" select="document($path)"/>
- <xsl:if test="$docs/*">
- <locale id="{ $locale-res }">
- <xsl:copy-of select="$docs//string[@id = $resources]"/>
- </locale>
- </xsl:if>
- </xsl:when>
- </xsl:choose>
- </xsl:for-each>
- </xsl:variable>
- <xsl:for-each select="$resources">
- <xsl:variable name="resource-id" select="."/>
- <xsl:if test="$strings/locale/string[@id = $resource-id]">
- <wsrp:resources resourceName="{ $resource-id }">
- <xsl:for-each select="$strings/locale[string[@id = $resource-id]]">
- <wsrp:values xml:lang="{ @id }">
- <wsrp:value>
- <xsl:value-of select="string[@id = $resource-id]"/>
- </wsrp:value>
- </wsrp:values>
- </xsl:for-each>
- </wsrp:resources>
- </xsl:if>
- </xsl:for-each>
- </wsrp:resourceList>
- </xsl:if>
- </xsl:template>
- <xsl:template name="value">
- <xsl:param name="tag"/>
- <xsl:choose>
- <xsl:when test="@resourceID">
- <xsl:element name="wsrp:{ $tag }" namespace="urn:oasis:names:tc:wsrp:v1:types">
- <xsl:attribute name="xml:lang">
- <xsl:value-of select="$locale"/>
- </xsl:attribute>
- <xsl:attribute name="resourceName"><xsl:value-of select="@resourceID"/></xsl:attribute>
- <wsrp:value>
- <xsl:value-of select="$locale-strings/string[@id = current()/@resourceID]"/>
- </wsrp:value>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <xsl:element name="wsrp:{ $tag }" namespace="urn:oasis:names:tc:wsrp:v1:types">
- <xsl:attribute name="xml:lang">
- <xsl:value-of select="$locale"/>
- </xsl:attribute>
- <wsrp:value>
- <xsl:value-of select="."/>
- </wsrp:value>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- </xsl:stylesheet>
|