switchScriptToLibrary.xslt 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: cogadmin
  5. (C) Copyright IBM Corp. 2005, 2010
  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"
  13. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  14. exclude-result-prefixes="xsl">
  15. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  16. <xsl:key name="env-param" match="/root/env/param" use="@name"/>
  17. <xsl:template match="/root">
  18. <xsl:apply-templates/>
  19. </xsl:template>
  20. <xsl:template match="script[@language != '' and @type='text/javascript' and @src != '']" priority="1">
  21. <xsl:variable name="src">
  22. <xsl:choose>
  23. <xsl:when test="starts-with(@src, '../')"><xsl:value-of select="concat('$WEB$/', substring-after(@src, '../'))"/></xsl:when>
  24. <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
  25. </xsl:choose>
  26. </xsl:variable>
  27. <library type="text/javascript" href="{$src}"/>
  28. </xsl:template>
  29. <xsl:template match="link[@type = 'text/css' and @href != '']" priority="1">
  30. <xsl:variable name="href">
  31. <xsl:choose>
  32. <xsl:when test="starts-with(@href, '../')"><xsl:value-of select="concat('$WEB$/', substring-after(@href, '../'))"/></xsl:when>
  33. <xsl:otherwise><xsl:value-of select="@href"/></xsl:otherwise>
  34. </xsl:choose>
  35. </xsl:variable>
  36. <css type="text/css" media="screen" href="{$href}"/>
  37. </xsl:template>
  38. <xsl:template match="text()" priority="0">
  39. <xsl:copy-of select="."/>
  40. </xsl:template>
  41. <xsl:template match="node()" priority="0">
  42. <xsl:copy>
  43. <xsl:copy-of select="@*"/>
  44. <xsl:apply-templates/>
  45. </xsl:copy>
  46. </xsl:template>
  47. </xsl:stylesheet>