normalizeEmailBody.xslt 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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, 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. Convert all Element tags to uppercase and all attributres to lowercase
  12. before sending to Validation transform.
  13. -->
  14. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  15. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  16. exclude-result-prefixes="xts">
  17. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  18. <!-- variables used for conversion to and from lowercase to uppercase characters -->
  19. <xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable>
  20. <xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
  21. <!-- match on entire HTML email body -->
  22. <xsl:template match="/" priority="1">
  23. <xsl:apply-templates/>
  24. </xsl:template>
  25. <!-- match elements and convert all to uppercase -->
  26. <xsl:template match="*">
  27. <xsl:variable name="ucElement">
  28. <xsl:value-of select="translate(local-name(),$lcletters,$ucletters)"/>
  29. </xsl:variable>
  30. <xsl:element name="{$ucElement}">
  31. <xsl:apply-templates select="@*"/> <!-- apply templates to attibutes -->
  32. <xsl:apply-templates/> <!-- apply templates to children -->
  33. </xsl:element>
  34. </xsl:template>
  35. <!-- match attributes and convert all to lowercase -->
  36. <xsl:template match="@*">
  37. <xsl:variable name="lcAttribute">
  38. <xsl:value-of select="translate(local-name(),$ucletters,$lcletters)"/>
  39. </xsl:variable>
  40. <xsl:attribute name="{$lcAttribute}">
  41. <xsl:value-of select="."/>
  42. </xsl:attribute>
  43. </xsl:template>
  44. </xsl:stylesheet>