rtview.xslt 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: cpscrn
  5. (C) Copyright IBM Corp. 2005, 2011
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <!--
  9. Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  10. Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  11. -->
  12. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:cclutils="java:com.cognos.portal.utils.CCLLocaleUtils">
  13. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/>
  14. <xsl:variable name="contentLocale" select="/root/preferences/param[@name='contentLocale']"/>
  15. <xsl:variable name="customs" select="/root/customs/param"/>
  16. <xsl:template match="/">
  17. <xsl:call-template name="render-text">
  18. <xsl:with-param name="text" select="$customs[@name='text1']"/>
  19. <xsl:with-param name="style" select="$customs[@name='style1']"/>
  20. </xsl:call-template>
  21. <xsl:call-template name="render-text">
  22. <xsl:with-param name="text" select="$customs[@name='text2']"/>
  23. <xsl:with-param name="style" select="$customs[@name='style2']"/>
  24. </xsl:call-template>
  25. </xsl:template>
  26. <xsl:template name="render-text">
  27. <xsl:param name="text"/>
  28. <xsl:param name="style"/>
  29. <xsl:if test="$text/value">
  30. <xsl:variable name="locale">
  31. <xsl:call-template name="select-locale">
  32. <xsl:with-param name="values" select="$text/value"/>
  33. </xsl:call-template>
  34. </xsl:variable>
  35. <div style="{$style}">
  36. <xsl:choose>
  37. <xsl:when test="$text/value[@xml:lang=$locale]">
  38. <xsl:value-of select="$text/value[@xml:lang=$locale]"/>
  39. </xsl:when>
  40. <xsl:otherwise>
  41. <xsl:value-of select="$text/value"/>
  42. </xsl:otherwise>
  43. </xsl:choose>
  44. </div>
  45. </xsl:if>
  46. </xsl:template>
  47. <xsl:template name="select-locale">
  48. <xsl:param name="values"/>
  49. <xsl:variable name="locales">
  50. <xsl:for-each select="$values">
  51. <xsl:value-of select="@xml:lang"/>
  52. <xsl:if test="position() != last()">
  53. <xsl:text>,</xsl:text>
  54. </xsl:if>
  55. </xsl:for-each>
  56. </xsl:variable>
  57. <xsl:value-of select="cclutils:getBestFitLocale($contentLocale, $locales)"/>
  58. </xsl:template>
  59. </xsl:stylesheet>