upgradeSkeleton.xslt 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. <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">
  9. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  10. <xsl:param name="mapfile"/>
  11. <xsl:param name="comments" select="true()"/>
  12. <xsl:preserve-space elements="set"/>
  13. <xsl:variable name="mapdoc" select="document( $mapfile )"/>
  14. <xsl:variable name="mapItems" select="$mapdoc/skinUpgrade/item"/>
  15. <xsl:template match="/">
  16. <xsl:call-template name="emitBrandingHeader"/>
  17. <xsl:apply-templates/>
  18. </xsl:template>
  19. <xsl:template match="css">
  20. <xsl:copy>
  21. <xsl:call-template name="emitBrandingHeaderForCss"/>
  22. <xsl:apply-templates select="import | class | comment"/>
  23. </xsl:copy>
  24. </xsl:template>
  25. <xsl:template match="class">
  26. <xsl:value-of select="@name"/>
  27. <xsl:if test="@comment and $comments='true'">
  28. <xsl:text> /* </xsl:text>
  29. <xsl:value-of select="@comment"/>
  30. <xsl:text> */</xsl:text>
  31. </xsl:if>
  32. <xsl:text> {&#10;</xsl:text>
  33. <xsl:call-template name="gen-attributes"/>
  34. <xsl:text>}&#10;</xsl:text>
  35. </xsl:template>
  36. <xsl:template name="gen-attributes">
  37. <xsl:variable name="uses" select="concat(' ', @uses, ' ')"/>
  38. <xsl:apply-templates select="set | /css/type[ contains($uses, concat(' ',@name,' ')) ]/set"/>
  39. </xsl:template>
  40. <xsl:template match="set">
  41. <xsl:text>&#9;</xsl:text>
  42. <xsl:value-of select="@name"/>
  43. <xsl:text>: </xsl:text>
  44. <xsl:apply-templates mode="attribute"/>
  45. <xsl:text>;</xsl:text>
  46. <xsl:text>&#10;</xsl:text>
  47. </xsl:template>
  48. <xsl:template match="color" mode="attribute">
  49. <xsl:call-template name="emitReferenceToSkin">
  50. <xsl:with-param name="section" select="'colors/color'"/>
  51. </xsl:call-template>
  52. </xsl:template>
  53. <xsl:template match="value" mode="attribute">
  54. <xsl:call-template name="emitReferenceToSkin">
  55. <xsl:with-param name="section" select="'values/value'"/>
  56. </xsl:call-template>
  57. </xsl:template>
  58. <xsl:template match="image" mode="attribute">
  59. <xsl:call-template name="emitReferenceToSkin">
  60. <xsl:with-param name="section" select="'images/image'"/>
  61. </xsl:call-template>
  62. </xsl:template>
  63. <xsl:template name="emitReferenceToSkin">
  64. <xsl:param name="section"/>
  65. <xsl:variable name="oldXPath">/skin/<xsl:value-of select="$section"/>[@name='<xsl:value-of select="@name"/>']</xsl:variable>
  66. <xsl:variable name="mappingItem" select="$mapItems[@oldXpath=$oldXPath]"/>
  67. <xsl:choose>
  68. <xsl:when test="$mappingItem[ @newXpath ]">
  69. <xsl:element name="skinValue">
  70. <xsl:attribute name="path">
  71. <xsl:value-of select="$mappingItem/@newXpath"/>
  72. </xsl:attribute>
  73. </xsl:element>
  74. </xsl:when>
  75. <xsl:when test="$mappingItem[ @newValue ]">
  76. <xsl:value-of select="$mappingItem/@newValue"/>
  77. </xsl:when>
  78. <xsl:otherwise>
  79. <xsl:text>/* WARNING: A reference to an old skin could not have been upgraded. Failed to find mapping data for the following old XPath: </xsl:text>
  80. <xsl:value-of select="$oldXPath"/>
  81. <xsl:text> */</xsl:text>
  82. </xsl:otherwise>
  83. </xsl:choose>
  84. </xsl:template>
  85. <xsl:template match="comment">
  86. <xsl:if test="$comments='true'">
  87. <xsl:text>&#10;/* </xsl:text>
  88. <xsl:value-of select="."/>
  89. <xsl:text> */&#10;</xsl:text>
  90. </xsl:if>
  91. </xsl:template>
  92. <xsl:template match="import">
  93. <xsl:text>@import url(</xsl:text>
  94. <xsl:value-of select="."/>
  95. <xsl:text>);&#10;</xsl:text>
  96. </xsl:template>
  97. <xsl:template match="remove"/>
  98. <xsl:template name="emitBrandingHeader">
  99. <xsl:comment>
  100. Licensed Materials - Property of IBM
  101. IBM Cognos Products: cpscrn
  102. (C) Copyright IBM Corp. 2005, 2012
  103. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  104. </xsl:comment>
  105. <xsl:text>&#10;</xsl:text>
  106. </xsl:template>
  107. <xsl:template name="emitBrandingHeaderForCss">
  108. <xsl:text>
  109. /********************************
  110. * Licensed Materials - Property of IBM
  111. *
  112. * IBM Cognos Products: cpscrn
  113. *
  114. * (C) Copyright IBM Corp. 2005, 2012
  115. *
  116. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  117. ********************************/
  118. </xsl:text>
  119. </xsl:template>
  120. </xsl:stylesheet>