normalizeEmailBody.xslt 1.7 KB

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