skeletonmap.xslt 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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:xtsext="xalan://com.cognos.xts.ext.XTSExt" exclude-result-prefixes="xtsext">
  13. <xsl:output method="text" version="1.0" encoding="UTF-8" indent="no"/>
  14. <xsl:param name="skinfile"/>
  15. <xsl:param name="overrides_path"/>
  16. <xsl:param name="comments" select="true()"/>
  17. <xsl:param name="debug" select="false()"/>
  18. <xsl:param name="webcontent"/>
  19. <xsl:param name="cgi"/>
  20. <xsl:param name="skin"/>
  21. <xsl:preserve-space elements="set"/>
  22. <xsl:variable name="skindoc">
  23. <xsl:if test="string($skinfile) != ''">
  24. <xsl:copy-of select="document($skinfile)"/>
  25. </xsl:if>
  26. </xsl:variable>
  27. <xsl:variable name="classWithVariable">
  28. <xsl:copy-of select="/css/class[.//color] | /css/class[.//value] | /css/class[.//image]"/>
  29. </xsl:variable>
  30. <xsl:variable name="overrides_doc">
  31. <xsl:if test="string($overrides_path) !=''">
  32. <xsl:copy-of select="document($overrides_path)"/>
  33. </xsl:if>
  34. </xsl:variable>
  35. <xsl:variable name="classes" select="$overrides_doc/cssskin/class"/>
  36. <xsl:variable name="images" select="$skindoc/skin/images/image"/>
  37. <xsl:template match="/">
  38. <xsl:text>/*&#10; (C) Copyright IBM Corp. 2005, 2011.&#10; Licensed Material - Property of IBM Corp. IBM, the IBM logo, and Cognos are trademarks of IBM Corp., registered in many jurisdictions worldwide.&#10;*/&#10;</xsl:text>
  39. <xsl:text>&#10;/*****************************************************************************************&#10;</xsl:text>
  40. <xsl:text> This is a generated file. Any changes you make to it will not be upgraded.</xsl:text>
  41. <xsl:text>&#10;/*****************************************************************************************/&#10;</xsl:text>
  42. <xsl:variable name="excludes" select="/css/class/@name"/>
  43. <xsl:text>[</xsl:text>
  44. <xsl:apply-templates select="$classWithVariable" mode="top"/>
  45. <xsl:text>&#10;]</xsl:text>
  46. </xsl:template>
  47. <xsl:template match="comment"/>
  48. <xsl:template match="import"/>
  49. <xsl:template match="class" mode="top">
  50. <xsl:if test="position()&gt;1">
  51. <xsl:text>,</xsl:text>
  52. </xsl:if>
  53. <xsl:text>&#10;&#9;{&#10;</xsl:text>
  54. <xsl:text>&#9;&#9;"selector": "</xsl:text>
  55. <xsl:value-of select="@name"/>
  56. <xsl:text>",&#10;</xsl:text>
  57. <xsl:variable name="redefines" select="$classes[@name=current()/@name]"/>
  58. <xsl:text>&#9;&#9;"styles": [</xsl:text>
  59. <xsl:choose>
  60. <xsl:when test="$redefines">
  61. <xsl:call-template name="gen-attributes">
  62. <xsl:with-param name="adds" select="$redefines/set"/>
  63. <xsl:with-param name="removes" select="$redefines/remove"/>
  64. </xsl:call-template>
  65. </xsl:when>
  66. <xsl:otherwise>
  67. <xsl:call-template name="gen-attributes"/>
  68. </xsl:otherwise>
  69. </xsl:choose>
  70. <xsl:text>&#10;&#9;&#9;]&#10;&#9;}</xsl:text>
  71. </xsl:template>
  72. <xsl:template name="gen-attributes">
  73. <xsl:param name="tag" select="."/>
  74. <xsl:param name="adds" select=".[false()]"/>
  75. <xsl:param name="removes" select=".[false()]"/>
  76. <xsl:variable name="uses" select="concat(' ', @uses, ' ')"/>
  77. <xsl:variable name="sets" select="/css/type[contains($uses, concat(' ',@name,' '))]/set | $tag/set"/>
  78. <xsl:variable name="list" select="$sets[not(@name=$adds/@name or @name=$removes/@name)]"/>
  79. <xsl:apply-templates select="$list | $adds"/>
  80. </xsl:template>
  81. <xsl:template match="set">
  82. <xsl:if test="position()&gt;1">
  83. <xsl:text>,</xsl:text>
  84. </xsl:if>
  85. <xsl:text>&#10;&#9;&#9;&#9;{</xsl:text>
  86. <xsl:text>"attribute": "</xsl:text>
  87. <xsl:value-of select="@name"/>
  88. <xsl:text>", value:"</xsl:text>
  89. <xsl:apply-templates mode="attribute"/>
  90. <xsl:text>"</xsl:text>
  91. <xsl:text>, variables:{</xsl:text>
  92. <xsl:for-each select="color|image|value">
  93. <xsl:if test="position()&gt;1">
  94. <xsl:text>,</xsl:text>
  95. </xsl:if>
  96. <xsl:text>"</xsl:text>
  97. <xsl:value-of select="@name"/>
  98. <xsl:text>":{</xsl:text>
  99. <xsl:text>parameters:{</xsl:text>
  100. <xsl:text>path:"</xsl:text>
  101. <xsl:choose>
  102. <xsl:when test="local-name() = 'color'">
  103. <xsl:text>/skin/colors/color[@name='</xsl:text>
  104. <xsl:value-of select="@name"/>
  105. <xsl:text>']</xsl:text>
  106. </xsl:when>
  107. <xsl:when test="local-name() = 'image'">
  108. <xsl:text>/skin/images/image[@name='</xsl:text>
  109. <xsl:value-of select="@name"/>
  110. <xsl:text>']</xsl:text>
  111. </xsl:when>
  112. <xsl:when test="local-name() = 'value'">
  113. <xsl:text>/skin/values/value[@name='</xsl:text>
  114. <xsl:value-of select="@name"/>
  115. <xsl:text>']</xsl:text>
  116. </xsl:when>
  117. </xsl:choose>
  118. <xsl:text>"</xsl:text>
  119. <xsl:text>}</xsl:text>
  120. <xsl:text>}</xsl:text>
  121. </xsl:for-each>
  122. <xsl:text>}</xsl:text>
  123. <xsl:text>}</xsl:text>
  124. </xsl:template>
  125. <xsl:template match="remove"/>
  126. <xsl:template match="color|value|image" mode="attribute">
  127. <xsl:text>#</xsl:text>
  128. <xsl:value-of select="@name"/>
  129. <!--xsl:text>$</xsl:text-->
  130. </xsl:template>
  131. <xsl:template name="gen-text" match="text()" mode="attribute">
  132. <xsl:param name="text" select="."/>
  133. <xsl:value-of select="."/>
  134. </xsl:template>
  135. </xsl:stylesheet>