123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- <?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).
- -->
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:encode="java:com.cognos.portal.utils.EncodingUtils">
- <xsl:output method="text" version="1.0" encoding="UTF-8" indent="no"/>
-
- <xsl:param name="section"/>
-
- <xsl:variable name="sectionList" select="concat(',',$section,',')"/>
-
- <xsl:template match="/">
- <xsl:text>/* (C) Copyright IBM Corp. 2005, 2011. Licensed Material - Property of IBM Corp. IBM, the IBM logo, and Cognos are trademarks of IBM Corp., registered in many jurisdictions worldwide. */ </xsl:text>
- <xsl:apply-templates select="/stringTable/component"/>
- </xsl:template>
-
- <xsl:template match="component">
- <xsl:text>var </xsl:text>
- <xsl:value-of select="@name"/>
- <xsl:text> = { </xsl:text>
- <xsl:for-each select="section[string($section) = '' or contains($sectionList,concat(',',@name,','))]">
- <xsl:if test="position() != 1">
- <xsl:text>, </xsl:text>
- </xsl:if>
- <xsl:text>	</xsl:text>
- <xsl:value-of select="@name"/>
- <xsl:text>: { </xsl:text>
- <xsl:apply-templates select="string"/>
- <xsl:text> 	}</xsl:text>
- </xsl:for-each>
- <xsl:text>,
- /**
- * formatString usage:
- * using param names in message string:
- * formatString(msg, "name1", "value1", "name2", "value2", ...)
- * using indexes in message string:
- * formatString(msg, ["value1", "value2", ...])
- */
- formatString: function(sourceString) {
- var result = sourceString;
- var i, l=arguments.length;
- if (l == 2 && typeof arguments[1] == "object" && arguments[1].length > 0) {
- // second argument is an array of values
- args = arguments[1];
- l = args.length;
- for (i = 0; i < l; i++) {
- result = result.replace(new RegExp("\\^" + i + "\\^"), args[i])
- }
-
- } else {
- for (i = 1; (i + 1) < l; i += 2) {
- result = result.replace(new RegExp("\\^" + arguments[i] + "\\^"), arguments[i + 1])
- }
- }
- return result;
- }
- };
- </xsl:text>
- </xsl:template>
-
- <xsl:template match="string">
- <xsl:if test="position() != 1">
- <xsl:text>, </xsl:text>
- </xsl:if>
- <xsl:text>		</xsl:text>
- <xsl:choose>
- <xsl:when test="@id">
- <xsl:value-of select="@id"/>
- </xsl:when>
- <xsl:when test="@name">
- <xsl:value-of select="../../@name"/>
- <xsl:text>_</xsl:text>
- <xsl:value-of select="../@name"/>
- <xsl:text>_</xsl:text>
- <xsl:value-of select="@name"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:message terminate="yes">Key Generation Error: Missing name or id.</xsl:message>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text>: "</xsl:text>
- <xsl:if test="@errorCode and (not(../@type) or ../@type='Messages')">
- <xsl:value-of select="../../@name"/>
- <xsl:text>-</xsl:text>
- <xsl:value-of select="../@name"/>
- <xsl:text>-</xsl:text>
- <xsl:value-of select="@errorCode"/>
- <xsl:text> </xsl:text>
- </xsl:if>
- <xsl:apply-templates mode="string"/>
- <xsl:text>"</xsl:text>
- </xsl:template>
-
- <xsl:template match="text()" mode="string">
- <xsl:value-of select="encode:javascriptencode(.)"/>
- </xsl:template>
-
- <xsl:template match="param" mode="string">
- <xsl:choose>
- <xsl:when test="@name">
- <xsl:value-of select="concat('^', @name, '^')"/>
- </xsl:when>
- <xsl:when test="@index">
- <xsl:value-of select="concat('^', @index - 1, '^')"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:message terminate="yes">Parameter Substitution Error: Missing name or index.</xsl:message>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template match="text()"/>
- </xsl:stylesheet>
|