Automatically exported from code.google.com/p/planningalerts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

70 lines
2.1 KiB

  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
  3. <xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
  4. <xsl:preserve-space elements="headervalue paramvalue body"/>
  5. <xsl:template name="mimepart">
  6. <xsl:variable name="boundary">
  7. <xsl:for-each select="./header">
  8. <xsl:if test="string(./headername) = 'Content-Type'">
  9. <xsl:for-each select="./parameter">
  10. <xsl:if test="string(./paramname) = 'boundary'">
  11. <xsl:value-of select="paramvalue"/>
  12. </xsl:if>
  13. </xsl:for-each>
  14. </xsl:if>
  15. </xsl:for-each>
  16. </xsl:variable>
  17. <xsl:for-each select="header">
  18. <xsl:value-of select="headername"/>
  19. <xsl:text>: </xsl:text>
  20. <xsl:value-of select="headervalue"/>
  21. <xsl:if test="count(./parameter) = 0">
  22. <xsl:text>&#13;&#10;</xsl:text>
  23. </xsl:if>
  24. <xsl:for-each select="parameter">
  25. <xsl:text>;&#13;&#10;&#09;</xsl:text>
  26. <xsl:value-of select="paramname"/>
  27. <xsl:text>="</xsl:text>
  28. <xsl:value-of select="paramvalue"/>
  29. <xsl:text>"</xsl:text>
  30. </xsl:for-each>
  31. <xsl:if test="count(./parameter) > 0">
  32. <xsl:text>&#13;&#10;</xsl:text>
  33. </xsl:if>
  34. </xsl:for-each>
  35. <xsl:text>&#13;&#10;</xsl:text>
  36. <!-- Which to do, print a body or process subparts? -->
  37. <xsl:choose>
  38. <xsl:when test="count(./mimepart) = 0">
  39. <xsl:value-of select="body"/>
  40. <xsl:text>&#13;&#10;</xsl:text>
  41. </xsl:when>
  42. <xsl:otherwise>
  43. <xsl:for-each select="mimepart">
  44. <xsl:text>--</xsl:text><xsl:value-of select="$boundary"/><xsl:text>&#13;&#10;</xsl:text>
  45. <xsl:call-template name="mimepart"/>
  46. </xsl:for-each>
  47. <xsl:text>--</xsl:text><xsl:value-of select="$boundary"/><xsl:text>--&#13;&#10;</xsl:text>
  48. </xsl:otherwise>
  49. </xsl:choose>
  50. </xsl:template>
  51. <!-- This is where the stylesheet really starts, matching the top level email element -->
  52. <xsl:template match="email">
  53. <xsl:call-template name="mimepart"/>
  54. </xsl:template>
  55. </xsl:stylesheet>