touch_up.xslt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: ps
  5. (C) Copyright IBM Corp. 2005, 2014
  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:out="dummy-uri">
  13. <!-- This logicsheet simply adds onmouseover and onmouseout attributes to all <a> tags.
  14. Include this one last for best results. ;-) -->
  15. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  16. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  17. <xsl:template match="img">
  18. <xsl:copy>
  19. <xsl:copy-of select="@*"/>
  20. <xsl:choose>
  21. <xsl:when test="child::*[local-name() = 'attribute' and @name = 'alt'] and not(child::*[local-name() = 'attribute' and @name = 'title'])">
  22. <out:attribute name="title">
  23. <xsl:copy-of select="child::*[local-name() = 'attribute' and @name = 'alt']/*"/>
  24. </out:attribute>
  25. </xsl:when>
  26. <xsl:when test="@alt and not(@title)">
  27. <xsl:attribute name="title"><xsl:value-of select="@alt"/></xsl:attribute>
  28. </xsl:when>
  29. </xsl:choose>
  30. <!-- A11Y support, add empty alt to img tag with spaces -->
  31. <xsl:choose>
  32. <xsl:when test="(child::*[local-name() = 'attribute' and @name = 'src'] and contains(child::*[local-name() = 'attribute' and @name = 'src'] , '/space.gif')) and not(child::*[local-name() = 'attribute' and @name = 'alt'])">
  33. <xsl:attribute name="alt"></xsl:attribute>
  34. </xsl:when>
  35. <xsl:when test="(@src and contains(@src,'/space.gif')) and not(@alt)">
  36. <xsl:attribute name="alt"></xsl:attribute>
  37. </xsl:when>
  38. </xsl:choose>
  39. <xsl:apply-templates/>
  40. </xsl:copy>
  41. </xsl:template>
  42. <!-- A11Y support, table columns that contain the defaultName of an object should be read in the content locale -->
  43. <xsl:template match="td[ancestor::table[@class='cctable'] and not(@lang) and descendant::*[local-name()='value-of' and (contains(@select,'cm:defaultName') or (contains(@select,'xtsext:formatDateFromUTC') and contains(@select, '$contentLocale')))]]">
  44. <xsl:copy>
  45. <xsl:copy-of select="@*"/>
  46. <xsl:attribute name="lang">{/root/user/param[@name='contentLocale']}</xsl:attribute>
  47. <xsl:apply-templates/>
  48. </xsl:copy>
  49. </xsl:template>
  50. <!-- A11Y support, close markers should be buttons -->
  51. <xsl:template match="a[descendant::img[contains(@src, 'close.gif')]]">
  52. <xsl:copy>
  53. <xsl:copy-of select="@*"/>
  54. <xsl:if test="not(@role)">
  55. <xsl:attribute name="role">button</xsl:attribute>
  56. </xsl:if>
  57. <xsl:apply-templates/>
  58. </xsl:copy>
  59. </xsl:template>
  60. <xsl:template match="*">
  61. <xsl:copy>
  62. <xsl:copy-of select="@*"/>
  63. <xsl:apply-templates/>
  64. </xsl:copy>
  65. </xsl:template>
  66. </xsl:stylesheet>