QfwNormalization.xsl 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: rspecupgrade
  5. (C) Copyright IBM Corp. 2005, 2010
  6. US Government Users Restricted Rights - Use, duplication or disclosure
  7. restricted by GSA ADP Schedule Contract with IBM Corp.
  8. -->
  9. <!-- COPYRIGHT_DATA { 'YEAR':[2005, 2009], 'RELEASE':['colorado_wave1'], 'VISIBLE':'YES', 'COMPONENT':'rspecupgrade' }-->
  10. <!--All lines above the COPYRIGHT_DATA line will be replaced when copyright notices are generated. -->
  11. <!--* This stylesheet normalizes text elements so they can compare the same in test cases.
  12. * @see trakker 535507
  13. *
  14. -->
  15. <xsl:stylesheet version="1.0" xmlns="http://developer.cognos.com/schemas/report/2.0/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:baltic="http://developer.cognos.com/schemas/report/1/" xmlns:bering="http://developer.cognos.com/schemas/report/2.0/" xmlns:date="http://exslt.org/dates-and-times" xmlns:exsl="http://exslt.org/common" xmlns:xalan="http://xml.apache.org/xalan" xmlns:java="http://xml.apache.org/xalan/java" extension-element-prefixes="xalan date exsl" exclude-result-prefixes="xalan java baltic date exsl">
  16. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no" xalan:indent-amount="2" omit-xml-declaration="no"/>
  17. <!--
  18. * Remove trailing white space in text.
  19. * @param p_text Text to strip.
  20. * Outputs stripped text.
  21. *
  22. * Named after the perl function chomp.
  23. -->
  24. <xsl:template name="chomp">
  25. <xsl:param name="p_text"/>
  26. <xsl:choose>
  27. <xsl:when test="substring($p_text, string-length($p_text)) = '&#9;' or
  28. substring($p_text, string-length($p_text)) = '&#10;' or
  29. substring($p_text, string-length($p_text)) = '&#13;' or
  30. substring($p_text, string-length($p_text)) = '&#32;' ">
  31. <xsl:call-template name="chomp">
  32. <xsl:with-param name="p_text" select="substring($p_text,1, string-length($p_text)-1)"/>
  33. </xsl:call-template>
  34. </xsl:when>
  35. <xsl:otherwise>
  36. <xsl:value-of select="$p_text"/>
  37. </xsl:otherwise>
  38. </xsl:choose>
  39. </xsl:template>
  40. <!-- -->
  41. <xsl:template match="comment()">
  42. <xsl:comment>
  43. <xsl:value-of select="."/>
  44. </xsl:comment>
  45. </xsl:template>
  46. <!--
  47. * Strip final line feeds.
  48. -->
  49. <xsl:template match="text()">
  50. <xsl:call-template name="chomp">
  51. <xsl:with-param name="p_text" select="."/>
  52. </xsl:call-template>
  53. </xsl:template>
  54. <!-- -->
  55. <xsl:template match="*">
  56. <xsl:element name="{name(.)}" namespace="{namespace-uri(.)}">
  57. <xsl:for-each select="@*">
  58. <xsl:sort select="name(.)"/>
  59. <xsl:copy-of select="."/>
  60. </xsl:for-each>
  61. <xsl:apply-templates select="node()"/>
  62. </xsl:element>
  63. </xsl:template>
  64. <!-- -->
  65. </xsl:stylesheet>